From: Dongsheng Song Date: Sat, 4 May 2013 05:43:05 +0000 (+0800) Subject: Fix for MSC compiler X-Git-Tag: v1.5.0-rc1~181^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0dff959d24702fea6350d123f999701ee3a1e55a;p=thirdparty%2Frrdtool-1.x.git Fix for MSC compiler --- diff --git a/src/rrd_cgi.c b/src/rrd_cgi.c index b403ca61..9ae6bff7 100644 --- a/src/rrd_cgi.c +++ b/src/rrd_cgi.c @@ -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:"); diff --git a/src/rrd_client.h b/src/rrd_client.h index a57cdb74..ee488f1e 100644 --- a/src/rrd_client.h +++ b/src/rrd_client.h @@ -27,17 +27,15 @@ #ifndef __RRD_CLIENT_H #define __RRD_CLIENT_H 1 -#ifndef WIN32 # ifdef HAVE_STDINT_H # include -# else -# ifdef HAVE_INTTYPES_H -# include -# else -# error "you should have stdint.h or inttypes.h to compile this" -# endif # endif -#else + +# ifdef HAVE_INTTYPES_H +# include +# endif + +# if !(defined(HAVE_STDINT_H) || defined(HAVE_INTTYPES_H)) # include 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 diff --git a/src/rrd_create.c b/src/rrd_create.c index fd7b9e1b..10f0b24e 100644 --- a/src/rrd_create.c +++ b/src/rrd_create.c @@ -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" diff --git a/src/rrd_graph.h b/src/rrd_graph.h index e96f957d..397c5b2c 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -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 #include diff --git a/src/rrd_graph_helper.c b/src/rrd_graph_helper.c index 11472287..aad4706f 100644 --- a/src/rrd_graph_helper.c +++ b/src/rrd_graph_helper.c @@ -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) { diff --git a/src/rrd_tool.c b/src/rrd_tool.c index 8c1b6747..ea585abd 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -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 #include #include #include -#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); diff --git a/src/rrd_tool.h b/src/rrd_tool.h index 40a48460..7df1971a 100644 --- a/src/rrd_tool.h +++ b/src/rrd_tool.h @@ -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" diff --git a/src/rrd_update.c b/src/rrd_update.c index 9e28b2dd..1529772a 100644 --- a/src/rrd_update.c +++ b/src/rrd_update.c @@ -14,8 +14,6 @@ #endif #include - -#include #include #include "rrd_hw.h" diff --git a/src/rrd_xport.c b/src/rrd_xport.c index ebe72aad..f7aa3383 100644 --- a/src/rrd_xport.c +++ b/src/rrd_xport.c @@ -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\n",usetag,dbuf,usetag); } - addToBuffer(usebuffer,buf,0); + addToBuffer(usebuffer,buf,0); } break; case GF_COMMENT: if (json) { diff --git a/src/rrdupdate.c b/src/rrdupdate.c index cfd1894c..bcebdede 100644 --- a/src/rrdupdate.c +++ b/src/rrdupdate.c @@ -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"