]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Fix warnings: different const qualifiers (MSVC)
authorWolfgang Stöggl <c72578@yahoo.de>
Fri, 25 Jan 2019 14:22:23 +0000 (15:22 +0100)
committerTobias Oetiker <tobi@oetiker.ch>
Sun, 3 Feb 2019 12:33:38 +0000 (13:33 +0100)
- Cast affected variables from 'const char **' to 'char **'
- Fixes the following warning:
  C4090: 'function': different 'const' qualifiers
  in: rrd_create.c(248), rrd_modify.c(1312),
  rrd_modify.c(1329), rrd_modify.c(1457), rrd_modify.c(1463)

src/rrd_create.c
src/rrd_modify.c

index d2d372baaf92536adb5a9d9e36895a8381942d52..c2565904f061f0c934cf5d13a733a38f46b90248 100644 (file)
@@ -245,7 +245,7 @@ int rrd_create(
     }
   done:
     if (sources_array != NULL) {
-        free(sources_array);
+        free((char **) sources_array);  /* Cast 'sources_array' from 'const char **' to 'char **' to avoid MSVC warning C4090 */
         sources_array = NULL;
     }
     if (sources != NULL) {
index 0a94b502b1859fb682511d651fb753fbc43858f7..c4037ec097cb26641540c2987b8363abfa0bda17 100644 (file)
@@ -1309,7 +1309,7 @@ int handle_modify(const rrd_t *in, const char *outfilename,
     
     for (i = optidx ; i < argc ; i++) {
        if (strncmp("DEL:", argv[i], 4) == 0 && strlen(argv[i]) > 4) {
-               del = (const char **) realloc(del, (rcnt + 2) * sizeof(char*));
+               del = (const char **) realloc((char **) del, (rcnt + 2) * sizeof(char*));   /* Cast 'del' from 'const char **' to 'char **' to avoid MSVC warning C4090 */
            if (del == NULL) {
                rrd_set_error("out of memory");
                rc = -1;
@@ -1326,7 +1326,7 @@ int handle_modify(const rrd_t *in, const char *outfilename,
            rcnt++;
            del[rcnt] = NULL;
        } else if (strncmp("DS:", argv[i], 3) == 0 && strlen(argv[i]) > 3) {
-               add = (const char **) realloc(add, (acnt + 2) * sizeof(char*));
+               add = (const char **) realloc((char **) add, (acnt + 2) * sizeof(char*));   /* Cast 'add' from 'const char **' to 'char **' to avoid MSVC warning C4090 */
            if (add == NULL) {
                rrd_set_error("out of memory");
                rc = -1;
@@ -1454,13 +1454,13 @@ done:
        for (const char **c = del ; *c ; c++) {
            free((void*) *c);
        }
-       free(del);
+       free((char **) del);    /* Cast 'del' from 'const char **' to 'char **' to avoid MSVC warning C4090 */
     } 
     if (add) {
        for (const char **c = add ; *c ; c++) {
            free((void*) *c);
        }
-       free(add);
+       free((char **) add);    /* Cast 'add' from 'const char **' to 'char **' to avoid MSVC warning C4090 */
     }
     if (rra_ops) {
        for (i = 0 ; i < rraopcnt ; i++) {