]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Fix for MSC compiler
authorDongsheng Song <songdongsheng@live.cn>
Sat, 4 May 2013 05:43:05 +0000 (13:43 +0800)
committerDongsheng Song <songdongsheng@live.cn>
Sat, 4 May 2013 05:43:05 +0000 (13:43 +0800)
src/rrd_cgi.c
src/rrd_client.h
src/rrd_create.c
src/rrd_graph.h
src/rrd_graph_helper.c
src/rrd_tool.c
src/rrd_tool.h
src/rrd_update.c
src/rrd_xport.c
src/rrdupdate.c

index b403ca61fc60fc7ee3d641613c5df9344a5456fd..9ae6bff7dafd1c81e6557f278edd0804db74aa61 100644 (file)
@@ -435,7 +435,7 @@ static int readfile(
                   (totalcnt - writecnt) * sizeof(char), input);
         if (writecnt >= totalcnt) {
             totalcnt += MEMBLK;
-            if (((*buffer) =
+            if (((*buffer) = (char *)
                  rrd_realloc((*buffer),
                              (totalcnt + 4) * sizeof(char))) == NULL) {
                 perror("Realloc Buffer:");
@@ -589,7 +589,7 @@ char     *rrdsetenv(
 {
     if (argc >= 2) {
         const size_t len = strlen(args[0]) + strlen(args[1]) + 2;
-        char *xyz = malloc(len);
+        char *xyz = (char *) malloc(len);
 
         if (xyz == NULL) {
             return stralloc("[ERROR: allocating setenv buffer]");
@@ -783,7 +783,7 @@ char     *includefile(
         readfile(filename, &buffer, 0);
         if (rrd_test_error()) {
             const size_t len = strlen(rrd_get_error()) + DS_NAM_SIZE;
-            char *err = malloc(len);
+            char *err = (char *) malloc(len);
 
             snprintf(err, len, "[ERROR: %s]", rrd_get_error());
             rrd_clear_error();
@@ -837,7 +837,7 @@ char     *cgigetq(
         for (c = buf; *c != '\0'; c++)
             if (*c == '"')
                 qc++;
-        if ((buf2 = malloc((strlen(buf) + 4 * qc + 4))) == NULL) {
+        if ((buf2 = (char *) malloc((strlen(buf) + 4 * qc + 4))) == NULL) {
             perror("Malloc Buffer");
             exit(1);
         };
@@ -883,7 +883,7 @@ char     *cgigetqp(
         return NULL;
     }
 
-    buf2 = malloc(strlen(buf) + 1);
+    buf2 = (char *) malloc(strlen(buf) + 1);
     if (!buf2) {
         perror("cgigetqp(): Malloc Path Buffer");
         exit(1);
@@ -950,7 +950,7 @@ char     *drawgraph(
     } else {
         if (rrd_test_error()) {
             const size_t len = strlen(rrd_get_error()) + DS_NAM_SIZE;
-            char *err = malloc(len);
+            char *err = (char *) malloc(len);
             snprintf(err, len, "[ERROR: %s]", rrd_get_error());
             rrd_clear_error();
             return err;
@@ -983,7 +983,7 @@ char     *printtimelast(
     char     *buf;
 
     if (argc == 2) {
-        buf = malloc(255);
+        buf = (char *) malloc(255);
         if (buf == NULL) {
             return stralloc("[ERROR: allocating strftime buffer]");
         };
@@ -993,7 +993,7 @@ char     *printtimelast(
         last = rrd_last(argc, (char **) args - 1);
         if (rrd_test_error()) {
             const size_t len = strlen(rrd_get_error()) + DS_NAM_SIZE;
-            char *err = malloc(len);
+            char *err = (char *) malloc(len);
             snprintf(err, len, "[ERROR: %s]", rrd_get_error());
             rrd_clear_error();
             return err;
@@ -1014,7 +1014,7 @@ char     *printtimenow(
     char     *buf;
 
     if (argc == 1) {
-        buf = malloc(255);
+        buf = (char *) malloc(255);
         if (buf == NULL) {
             return stralloc("[ERROR: allocating strftime buffer]");
         };
@@ -1158,7 +1158,7 @@ char     *scanargs(
         if (argc == argsz) {
             /* resize argument array */
             argsz *= 2;
-            argv = rrd_realloc(argv, argsz * sizeof(char *));
+            argv = (char **) rrd_realloc(argv, argsz * sizeof(char *));
             if (*argv == NULL) {
                 return NULL;
             }
@@ -1275,7 +1275,7 @@ int parse(
         /* make sure we do not shrink the mallocd block */
         size_t    newbufsize = i + strlen(end) + valln + 1;
 
-        *buf = rrd_realloc(*buf, newbufsize);
+        *buf = (char *) rrd_realloc(*buf, newbufsize);
 
         if (*buf == NULL) {
             perror("Realoc buf:");
index a57cdb74487952078d9e6cb9eea6b903c860fd0a..ee488f1e4ab566e1a39c596b39d0d784bd448752 100644 (file)
 #ifndef __RRD_CLIENT_H
 #define __RRD_CLIENT_H 1
 
-#ifndef WIN32
 # ifdef HAVE_STDINT_H
 #  include <stdint.h>
-# else
-#   ifdef HAVE_INTTYPES_H
-#      include <inttypes.h>
-#   else
-#      error "you should have stdint.h or inttypes.h to compile this"
-#   endif
 # endif
-#else
+
+# ifdef HAVE_INTTYPES_H
+#  include <inttypes.h>
+# endif
+
+# if !(defined(HAVE_STDINT_H) || defined(HAVE_INTTYPES_H))
 #      include <stdlib.h>
        typedef signed char     int8_t;
        typedef unsigned char   uint8_t;
@@ -47,7 +45,7 @@
        typedef unsigned long int       uint32_t;
        typedef signed long long int    int64_t;
        typedef unsigned long long int  uint64_t;
-#endif
+# endif
 
 /* max length of socket command or response */
 #define RRD_CMD_MAX 4096
index fd7b9e1b05749801fe50efa7f59e1ddbca0e125a..10f0b24e9c4b8ce6c64c05d174b0f11c6e26b663 100644 (file)
@@ -12,7 +12,7 @@
 #include "rrd_rpncalc.h"
 #include "rrd_hw.h"
 #include "rrd_client.h"
-#include "../rrd_config.h"
+#include "rrd_config.h"
 
 #include "rrd_is_thread_safe.h"
 
index e96f957d09a10a825b82c2daed9bb1c3ab601756..397c5b2c7e3a908db27fbd1ef4cfbc6c0f870b14 100644 (file)
@@ -7,13 +7,7 @@
 
 /* this may configure __EXTENSIONS__ without which pango will fail to compile
    so load this early */
-#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
-#include "../win32/config.h"
-#else
-#ifdef HAVE_CONFIG_H
-#include "../rrd_config.h"
-#endif
-#endif
+#include "rrd_config.h"
 
 #include <cairo.h>
 #include <cairo-pdf.h>
index 114722872e0572ac33f90ea39e654507863bc8ee..aad4706f66193b77b7e26d0a2ad98d5cfa3d21bf 100644 (file)
@@ -81,7 +81,7 @@ char* checkUnusedValues(parsedargs_t* pa){
       const size_t vlen = strlen(pa->kv_args[i].value);
       const size_t len = res ? strlen(res) : 0;
 
-      char *t = realloc(res,len + 3 + klen + vlen);
+      char *t = (char *) realloc(res,len + 3 + klen + vlen);
       if (! t) { return res; }
       res=t;
       strncat(res,pa->kv_args[i].key, klen);
@@ -166,7 +166,7 @@ int getDouble(const char* v, double *val,char**extra) {
 
 int addToArguments(parsedargs_t* pa, char*key, char*value, int cnt) {
   /* resize the field */
-  keyvalue_t* t=realloc(pa->kv_args,(pa->kv_cnt+1)*sizeof(keyvalue_t));
+  keyvalue_t * t = (keyvalue_t *) realloc(pa->kv_args, (pa->kv_cnt + 1) * sizeof(keyvalue_t));
   if (!t) { 
     rrd_set_error("could not realloc memory"); 
     return -1;
@@ -211,7 +211,7 @@ int parseArguments(const char* origarg, parsedargs_t* pa) {
       }
       break;
     case 0:
-    case ':':
+    case ':': {
       /* null and : separate the string */
       *pos=0;
       /* handle the case where we have got an = */
@@ -259,7 +259,7 @@ int parseArguments(const char* origarg, parsedargs_t* pa) {
       }
 
       /* and reset field */
-      field=NULL;
+      field=NULL; }
       break;
     default:
       break;
@@ -735,7 +735,7 @@ graph_desc_t* newGraphDescription(image_desc_t *const im,enum gf_en gf,parsedarg
     gdp->cf=cf_conv(cf);
     if (((int)gdp->cf)==-1) { 
       rrd_set_error("bad CF: %s",cf); return NULL; }
-  } else { if (bitscmp(PARSE_CF)) {gdp->cf=-1;}}
+  } else { if (bitscmp(PARSE_CF)) { gdp->cf = (cf_en) -1; }}
   if ((color)&&(parse_color(color,&(gdp->col)))) { return NULL; }
   if ((color2)&&(parse_color(color2,&(gdp->col2)))) { return NULL; }
   if (rpn) {gdp->rpn=rpn;}
@@ -1388,7 +1388,7 @@ void rrd_graph_script(
        }
 
        /* convert to enum but handling LINE special*/
-       enum gf_en gf=-1;
+       enum gf_en gf = (gf_en) -1;
        gf=gf_conv(cmd);
        if ((int)gf == -1) {
          if (strncmp("LINE",cmd,4)==0) {
index 8c1b67479b517396d3b5f2739f1af59fb28e00f0..ea585abd5dbe4d0450e76b0a909489c346c4c9b6 100644 (file)
@@ -4,16 +4,13 @@
  * rrd_tool.c  Startup wrapper
  *****************************************************************************/
 
+#include "rrd_config.h"
+
 #if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) && !defined(HAVE_CONFIG_H)
-#include "../win32/config.h"
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <io.h>
 #include <fcntl.h>
-#else
-#ifdef HAVE_CONFIG_H
-#include "../rrd_config.h"
-#endif
 #endif
 
 #include "rrd_tool.h"
@@ -376,7 +373,7 @@ static char *fgetslong(
 
     if (feof(stream))
         return *aLinePtr = 0;
-    if (!(linebuf = malloc(bufsize))) {
+    if (!(linebuf = (char *) malloc(bufsize))) {
         perror("fgetslong: malloc");
         exit(1);
     }
@@ -386,7 +383,7 @@ static char *fgetslong(
         if (linebuf[eolpos - 1] == '\n')
             return *aLinePtr = linebuf;
         bufsize += MAX_LENGTH;
-        if (!(linebuf = realloc(linebuf, bufsize))) {
+        if (!(linebuf = (char *) realloc(linebuf, bufsize))) {
             free(linebuf);
             perror("fgetslong: realloc");
             exit(1);
index 40a484601e021f78b3b3af7f081dc82968e105e6..7df1971a8daa33dd9698cd848e4fbf6c9275be79 100644 (file)
@@ -10,13 +10,7 @@ extern    "C" {
 #ifndef _RRD_TOOL_H
 #define _RRD_TOOL_H
 
-#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
-#include "../win32/config.h"
-#else
-#ifdef HAVE_CONFIG_H
-#include "../rrd_config.h"
-#endif
-#endif
+#include "rrd_config.h"
 
 #include "rrd.h"
 
index 9e28b2ddf0a3834a3c3c262ade1b7a0d752a6832..1529772a6800f1830653da58c54a6795aa2b2bf3 100644 (file)
@@ -14,8 +14,6 @@
 #endif
 
 #include <locale.h>
-
-#include <inttypes.h>
 #include <stdint.h>
 
 #include "rrd_hw.h"
index ebe72aad40b28e6627d63851245cf4c84fa0daff..f7aa3383329de4307c26e4ef2534101742038bf1 100644 (file)
@@ -487,7 +487,7 @@ int addToBuffer(stringbuffer_t * sb,char* data,size_t len) {
     sb->allocated+=8192;
     sb->allocated-=(sb->allocated%8192);    
     /* and allocate it */
-    sb->data=malloc(sb->allocated); 
+    sb->data = (unsigned char *) malloc(sb->allocated);
     if (! sb->data) { 
       rrd_set_error("malloc issue");
       return 1;
@@ -880,7 +880,7 @@ int rrd_xport_format_addprints(int flags,stringbuffer_t *buffer,image_desc_t *im
     char* entry;
     switch (im->gdes[i].gf) {
     case GF_PRINT:
-    case GF_GPRINT:
+    case GF_GPRINT: {
       /* PRINT and GPRINT can now print VDEF generated values.
        * There's no need to do any calculations on them as these
        * calculations were already made.
@@ -961,7 +961,7 @@ int rrd_xport_format_addprints(int flags,stringbuffer_t *buffer,image_desc_t *im
       } else {
        snprintf(buf,sizeof(buf),"        <%s>%s</%s>\n",usetag,dbuf,usetag);
       }
-      addToBuffer(usebuffer,buf,0);
+      addToBuffer(usebuffer,buf,0); }
       break;
     case GF_COMMENT:
       if (json) {
index cfd1894c3d84d9c79deb02920d36b803d5ca82de..bcebdede836d543215d9c4782cbe48f6e252591f 100644 (file)
@@ -6,13 +6,7 @@
  * $Id$
  *****************************************************************************/
 
-#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) && !defined(HAVE_CONFIG_H)
-#include "../win32/config.h"
-#else
-#ifdef HAVE_CONFIG_H
-#include "../rrd_config.h"
-#endif
-#endif
+#include "rrd_config.h"
 
 #include "rrd.h"
 #include "plbasename.h"