From: oetiker Date: Wed, 26 May 2004 22:11:12 +0000 (+0000) Subject: reduce compiler warnings. Many small fixes. -- Mike Slifcak X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=0c87c2676bb826f8defb40d7d45e771ecd40550c;p=rrdtool.git reduce compiler warnings. Many small fixes. -- Mike Slifcak git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@277 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/src/fnv.h b/src/fnv.h index 205e5a8..22f6ff6 100644 --- a/src/fnv.h +++ b/src/fnv.h @@ -99,4 +99,10 @@ typedef unsigned long Fnv32_t; */ #define FNV1_32_INIT ((Fnv32_t)0x811c9dc5) +Fnv32_t fnv_32_buf(void *, size_t, Fnv32_t); + +Fnv32_t fnv_32_str(char *, Fnv32_t ); + +unsigned long FnvHash(char *); + #endif /* __FNV_H__ */ diff --git a/src/parsetime.c b/src/parsetime.c index e5a297c..775a40a 100644 --- a/src/parsetime.c +++ b/src/parsetime.c @@ -234,25 +234,24 @@ static struct SpecialToken TimeMultipliers[] = { */ static struct SpecialToken *Specials; -static char **scp; /* scanner - pointer at arglist */ +static const char **scp; /* scanner - pointer at arglist */ static char scc; /* scanner - count of remaining arguments */ -static char *sct; /* scanner - next char pointer in current argument */ +static const char *sct; /* scanner - next char pointer in current argument */ static int need; /* scanner - need to advance to next argument */ static char *sc_token=NULL; /* scanner - token buffer */ static size_t sc_len; /* scanner - length of token buffer */ static int sc_tokid; /* scanner - token id */ -static int need_to_free = 0; /* means that we need deallocating memory */ - /* Local functions */ +static void EnsureMemFree (void); -void EnsureMemFree () +static void EnsureMemFree (void) { - if( need_to_free ) + if( sc_token ) { free(sc_token); - need_to_free = 0; + sc_token = NULL; } } @@ -368,7 +367,7 @@ parse_token(char *arg) * init_scanner() sets up the scanner to eat arguments */ static char * -init_scanner(int argc, char **argv) +init_scanner(int argc, const char **argv) { scp = argv; scc = argc; @@ -380,7 +379,6 @@ init_scanner(int argc, char **argv) sc_token = (char *) malloc(sc_len*sizeof(char)); if( sc_token == NULL ) return "Failed to allocate memory"; - need_to_free = 1; return TIME_OK; } /* init_scanner */ @@ -561,7 +559,7 @@ tod(struct rrd_time_value *ptv) int tlen; /* save token status in case we must abort */ int scc_sv = scc; - char *sct_sv = sct; + const char *sct_sv = sct; int sc_tokid_sv = sc_tokid; tlen = strlen(sc_token); @@ -785,7 +783,7 @@ day(struct rrd_time_value *ptv) * the pointer to the error message in the case of problems */ char * -parsetime(char *tspec, struct rrd_time_value *ptv) +parsetime(const char *tspec, struct rrd_time_value *ptv) { time_t now = time(NULL); int hr = 0; diff --git a/src/pngsize.c b/src/pngsize.c index 41ff16a..e60b6fa 100644 --- a/src/pngsize.c +++ b/src/pngsize.c @@ -5,6 +5,7 @@ *****************************************************************************/ #include +#include "rrd_tool.h" int PngSize(FILE *fd, long *width, long *height) diff --git a/src/rrd.h b/src/rrd.h index 902f72a..7509540 100644 --- a/src/rrd.h +++ b/src/rrd.h @@ -5,6 +5,9 @@ ***************************************************************************** * $Id$ * $Log$ + * Revision 1.8 2004/05/26 22:11:12 oetiker + * reduce compiler warnings. Many small fixes. -- Mike Slifcak + * * Revision 1.7 2003/11/12 22:14:26 oetiker * allow to pass an open filehandle into rrd_graph as an extra argument * @@ -62,7 +65,7 @@ int rrd_fetch(int, char **, time_t *, time_t *, unsigned long *, int rrd_restore(int, char **); int rrd_dump(int, char **); int rrd_tune(int, char **); -time_t rrd_last(int, char **); +time_t rrd_last(int, const char **); int rrd_resize(int, char **); int rrd_xport(int, char **, int *, time_t *, time_t *, unsigned long *, unsigned long *, @@ -77,7 +80,7 @@ int rrd_create_r(char *filename, int rrd_update_r(char *filename, char *_template, int argc, char **argv); int rrd_dump_r(char *filename); -time_t rrd_last_r(char *filename); +time_t rrd_last_r(const char *filename); /* Transplanted from parsetime.h */ typedef enum { @@ -104,7 +107,7 @@ struct rrd_context { /* returns the current per-thread rrd_context */ struct rrd_context *rrd_get_context(void); -char *parsetime(char *spec, struct rrd_time_value *ptv); +char *parsetime(const char *spec, struct rrd_time_value *ptv); /* END parsetime.h */ int proc_start_end (struct rrd_time_value *, struct rrd_time_value *, time_t *, time_t *); diff --git a/src/rrd_afm.c b/src/rrd_afm.c index 6134036..c9996d0 100644 --- a/src/rrd_afm.c +++ b/src/rrd_afm.c @@ -4,12 +4,18 @@ * rrd_afm.h Parsing afm tables to find width of strings. ****************************************************************************/ +#include "config.h" + #include "rrd_afm.h" #include "rrd_afm_data.h" #include #include +#ifdef HAVE_STRING_H +#include +#endif + #if 0 # define DEBUG 1 # define DLOG(x) fprintf x @@ -201,21 +207,21 @@ double afm_get_text_width ( double start, const char* font, double size, #ifdef __APPLE__ const unsigned char afm_mac2iso[128] = { - '\xC4', '\xC5', '\xC7', '\xC9', '\xD1', '\xD6', '\xDC', '\xE1', // 80 - '\xE0', '\xE2', '\xE4', '\xE3', '\xE5', '\xE7', '\xE9', '\xE8', // 88 - '\xEA', '\xEB', '\xED', '\xEC', '\xEE', '\xEF', '\xF1', '\xF3', // 90 - '\xF2', '\xF4', '\xF6', '\xF5', '\xFA', '\xF9', '\xFB', '\xFC', // 98 - '\xDD', '\xB0', '\xA2', '\xA3', '\xA7', ' ', '\xB6', '\xDF', // A0 - '\xAE', '\xA9', ' ', '\xB4', '\xA8', ' ', '\xC6', '\xD8', // A8 - ' ', '\xB1', '\xBE', ' ', '\xA5', '\xB5', ' ', ' ', // B0 - '\xBD', '\xBC', ' ', '\xAA', '\xBA', ' ', '\xE6', '\xF8', // B8 - '\xBF', '\xA1', '\xAC', ' ', ' ', ' ', ' ', '\xAB', // C0 - '\xBB', ' ', '\xA0', '\xC0', '\xC3', '\xD5', ' ', '\xA6', // C8 - '\xAD', ' ', '"', '"', '\'', '\'', '\xF7', '\xD7', // D0 - '\xFF', ' ', ' ', '\xA4', '\xD0', '\xF0', '\xDE', '\xFE', // D8 - '\xFD', '\xB7', ' ', ' ', ' ', '\xC2', '\xCA', '\xC1', // E0 - '\xCB', '\xC8', '\xCD', '\xCE', '\xCF', '\xCC', '\xD3', '\xD4', // E8 - ' ', '\xD2', '\xDA', '\xDB', '\xD9', ' ', ' ', ' ', // F0 - '\xAF', ' ', ' ', ' ', '\xB8', ' ', ' ', ' ', // F8 + '\xC4', '\xC5', '\xC7', '\xC9', '\xD1', '\xD6', '\xDC', '\xE1', /* 80 */ + '\xE0', '\xE2', '\xE4', '\xE3', '\xE5', '\xE7', '\xE9', '\xE8', /* 88 */ + '\xEA', '\xEB', '\xED', '\xEC', '\xEE', '\xEF', '\xF1', '\xF3', /* 90 */ + '\xF2', '\xF4', '\xF6', '\xF5', '\xFA', '\xF9', '\xFB', '\xFC', /* 98 */ + '\xDD', '\xB0', '\xA2', '\xA3', '\xA7', ' ', '\xB6', '\xDF', /* A0 */ + '\xAE', '\xA9', ' ', '\xB4', '\xA8', ' ', '\xC6', '\xD8', /* A8 */ + ' ', '\xB1', '\xBE', ' ', '\xA5', '\xB5', ' ', ' ', /* B0 */ + '\xBD', '\xBC', ' ', '\xAA', '\xBA', ' ', '\xE6', '\xF8', /* B8 */ + '\xBF', '\xA1', '\xAC', ' ', ' ', ' ', ' ', '\xAB', /* C0 */ + '\xBB', ' ', '\xA0', '\xC0', '\xC3', '\xD5', ' ', '\xA6', /* C8 */ + '\xAD', ' ', '"', '"', '\'', '\'', '\xF7', '\xD7', /* D0 */ + '\xFF', ' ', ' ', '\xA4', '\xD0', '\xF0', '\xDE', '\xFE', /* D8 */ + '\xFD', '\xB7', ' ', ' ', ' ', '\xC2', '\xCA', '\xC1', /* E0 */ + '\xCB', '\xC8', '\xCD', '\xCE', '\xCF', '\xCC', '\xD3', '\xD4', /* E8 */ + ' ', '\xD2', '\xDA', '\xDB', '\xD9', ' ', ' ', ' ', /* F0 */ + '\xAF', ' ', ' ', ' ', '\xB8', ' ', ' ', ' ', /* F8 */ }; #endif diff --git a/src/rrd_afm_data.c b/src/rrd_afm_data.c index 043968d..41ebce0 100644 --- a/src/rrd_afm_data.c +++ b/src/rrd_afm_data.c @@ -3319,6 +3319,6 @@ const afm_fontinfo afm_fontinfolist[] = { afm_Times_Roman_kerning_data, afm_Times_Roman_highchars_index, 220, afm_Times_Roman_ligatures, 1}, - { 0, 0, 0 } + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; const int afm_fontinfo_count = 14; diff --git a/src/rrd_afm_data.h b/src/rrd_afm_data.h index c3446e6..f301f21 100644 --- a/src/rrd_afm_data.h +++ b/src/rrd_afm_data.h @@ -135,18 +135,7 @@ Implementation design: unicode char1, char2, resultingchar; } - Font-global info is stored in a - struct { - char *fullname; // e.g. "Futura Bold Oblique" - char *postscript_name; // e.g. "Futura-BoldOblique" - uint8 *widths; - sint16 *kerning_index; - sint8 *kerning_data; - uint16 *highchars_index; - uint16 highchars_count; - unicode *ligatures; - uint16 ligatures_count; - } + Font-global info is stored in a struct afm_fontinfo (see below). The highchars_index and ligatures structures are flattened to a simple array to avoid accidental padding between @@ -177,8 +166,8 @@ typedef const afm_sint16 afm_csint16; typedef const afm_unicode afm_cunicode; typedef struct afm_fontinfo { - const char *fullname; // e.g. "Futura Bold Oblique" - const char *postscript_name; // e.g. "Futura-BoldOblique" + const char *fullname; /* e.g. "Futura Bold Oblique" */ + const char *postscript_name; /* e.g. "Futura-BoldOblique" */ afm_cuint8 *widths; afm_csint16 *kerning_index; afm_cuint8 *kerning_data; diff --git a/src/rrd_cgi.c b/src/rrd_cgi.c index 5a47dc2..d72879f 100644 --- a/src/rrd_cgi.c +++ b/src/rrd_cgi.c @@ -14,11 +14,11 @@ #define DEBUG_VARS*/ /* global variable for libcgi */ -s_cgi **cgiArg; +s_cgi *cgiArg; /* in arg[0] find tags beginning with arg[1] call arg[2] on them and replace by result of arg[2] call */ -int parse(char **, long, char *, char *(*)(long , char **)); +int parse(char **, long, char *, char *(*)(long , const char **)); /**************************************************/ /* tag replacers ... they are called from parse */ @@ -26,43 +26,43 @@ int parse(char **, long, char *, char *(*)(long , char **)); /**************************************************/ /* return cgi var named arg[0] */ -char* cgiget(long , char **); +char* cgiget(long , const char **); /* return a quoted cgi var named arg[0] */ -char* cgigetq(long , char **); +char* cgigetq(long , const char **); /* return a quoted and sanitized cgi variable */ -char* cgigetqp(long , char **); +char* cgigetqp(long , const char **); /* call rrd_graph and insert appropriate image tag */ char* drawgraph(long, char **); /* return PRINT functions from last rrd_graph call */ -char* drawprint(long, char **); +char* drawprint(long, const char **); /* pretty-print the value for some.rrd via strftime() */ -char* printtimelast(long, char **); +char* printtimelast(long, const char **); /* pretty-print current time */ -char* printtimenow(long,char **); +char* printtimenow(long, const char **); /* set an environment variable */ -char* rrdsetenv(long, char **); +char* rrdsetenv(long, const char **); /* get an environment variable */ -char* rrdgetenv(long, char **); +char* rrdgetenv(long, const char **); /* include the named file at this point */ -char* includefile(long, char **); +char* includefile(long, const char **); /* for how long is the output of the cgi valid ? */ -char* rrdgoodfor(long, char **); +char* rrdgoodfor(long, const char **); char* rrdstrip(char *buf); char* scanargs(char *line, int *argc, char ***args); /* format at-time specified times using strftime */ -char* printstrftime(long, char**); +char* printstrftime(long, const char**); /** HTTP protocol needs special format, and GMT time **/ char *http_time(time_t *); @@ -72,9 +72,9 @@ char *stralloc(const char *); /* rrd interface to the variable functions {put,get}var() */ -char* rrdgetvar(long argc, char **args); -char* rrdsetvar(long argc, char **args); -char* rrdsetvarconst(long argc, char **args); +char* rrdgetvar(long argc, const char **args); +char* rrdsetvar(long argc, const char **args); +char* rrdsetvarconst(long argc, const char **args); /* variable store: put/get key-value pairs */ @@ -117,7 +117,7 @@ donevar() { int i; if (varheap) { - for (i=0; i %s -->\n", name, varheap[i].value); @@ -157,7 +157,7 @@ static const char* putvar(const char* name, const char* value, int is_const) { int i; - for (i=0; i < varheap_size && varheap[i].name; i++) { + for (i=0; i < (int)varheap_size && varheap[i].name; i++) { if (0 == strcmp(name, varheap[i].name)) { /* overwrite existing entry */ if (varheap[i].is_const) { @@ -180,7 +180,7 @@ putvar(const char* name, const char* value, int is_const) } /* no existing variable found by that name, add it */ - if (i == varheap_size) { + if (i == (int)varheap_size) { /* ran out of heap: resize heap to double size */ size_t new_size = varheap_size * 2; varheap = (vardata*)(realloc(varheap, sizeof(vardata) * new_size)); @@ -372,7 +372,7 @@ int main(int argc, char *argv[]) { /* remove occurrences of .. this is a general measure to make paths which came in via cgi do not go UP ... */ -char* rrdsetenv(long argc, char **args) { +char* rrdsetenv(long argc, const char **args) { if (argc >= 2) { char *xyz = malloc((strlen(args[0]) + strlen(args[1]) + 2)); if (xyz == NULL) { @@ -390,7 +390,7 @@ char* rrdsetenv(long argc, char **args) { /* rrd interface to the variable function putvar() */ char* -rrdsetvar(long argc, char **args) +rrdsetvar(long argc, const char **args) { if (argc >= 2) { @@ -407,7 +407,7 @@ rrdsetvar(long argc, char **args) /* rrd interface to the variable function putvar() */ char* -rrdsetvarconst(long argc, char **args) +rrdsetvarconst(long argc, const char **args) { if (argc >= 2) { @@ -422,7 +422,7 @@ rrdsetvarconst(long argc, char **args) "were defined]"); } -char* rrdgetenv(long argc, char **args) { +char* rrdgetenv(long argc, const char **args) { char buf[128]; const char* envvar; if (argc != 1) { @@ -438,7 +438,7 @@ char* rrdgetenv(long argc, char **args) { } } -char* rrdgetvar(long argc, char **args) { +char* rrdgetvar(long argc, const char **args) { char buf[128]; const char* value; if (argc != 1) { @@ -454,7 +454,7 @@ char* rrdgetvar(long argc, char **args) { } } -char* rrdgoodfor(long argc, char **args){ +char* rrdgoodfor(long argc, const char **args){ if (argc == 1) { goodfor = atol(args[0]); } else { @@ -472,7 +472,7 @@ char* rrdgoodfor(long argc, char **args){ * start and end times, because, either might be relative to the other. * */ #define MAX_STRFTIME_SIZE 256 -char* printstrftime(long argc, char **args){ +char* printstrftime(long argc, const char **args){ struct rrd_time_value start_tv, end_tv; char *parsetime_error = NULL; char formatted[MAX_STRFTIME_SIZE]; @@ -524,11 +524,10 @@ char* printstrftime(long argc, char **args){ } } -char* includefile(long argc, char **args){ +char* includefile(long argc, const char **args){ char *buffer; if (argc >= 1) { - char* filename = args[0]; - readfile(filename, &buffer, 0); + readfile(args[0], &buffer, 0); if (rrd_test_error()) { char *err = malloc((strlen(rrd_get_error())+DS_NAM_SIZE)); sprintf(err, "[ERROR: %s]",rrd_get_error()); @@ -566,7 +565,7 @@ char* rrdstrip(char *buf) { return buf; } -char* cgigetq(long argc, char **args){ +char* cgigetq(long argc, const char **args){ if (argc>= 1){ char *buf = rrdstrip(cgiGetValue(cgiArg,args[0])); char *buf2; @@ -604,7 +603,7 @@ char* cgigetq(long argc, char **args){ /* remove occurrences of .. this is a general measure to make paths which came in via cgi do not go UP ... */ -char* cgigetqp(long argc, char **args){ +char* cgigetqp(long argc, const char **args){ if (argc>= 1) { char *buf = rrdstrip(cgiGetValue(cgiArg,args[0])); char *buf2; @@ -657,7 +656,7 @@ char* cgigetqp(long argc, char **args){ } -char* cgiget(long argc, char **args){ +char* cgiget(long argc, const char **args){ if (argc>= 1) return rrdstrip(cgiGetValue(cgiArg,args[0])); else @@ -691,7 +690,7 @@ char* drawgraph(long argc, char **args){ return NULL; } -char* drawprint(long argc, char **args){ +char* drawprint(long argc, const char **args){ if (argc==1 && calcpr){ long i=0; while (calcpr[i] != NULL) i++; /*determine number lines in calcpr*/ @@ -701,7 +700,7 @@ char* drawprint(long argc, char **args){ return stralloc("[ERROR: RRD::PRINT argument error]"); } -char* printtimelast(long argc, char **args) { +char* printtimelast(long argc, const char **args) { time_t last; struct tm tm_last; char *buf; @@ -727,7 +726,7 @@ char* printtimelast(long argc, char **args) { return stralloc("[ERROR: not enough arguments for RRD::TIME::LAST]"); } -char* printtimenow(long argc, char **args) { +char* printtimenow(long argc, const char **args) { time_t now = time(NULL); struct tm tm_now; char *buf; @@ -929,7 +928,7 @@ parse( char **buf, /* buffer */ long i, /* offset in buffer */ char *tag, /* tag to handle */ - char *(*func)(long argc, char **args) /* function to call for 'tag' */ + char *(*func)(long , const char **) /* function to call for 'tag' */ ) { /* the name of the vairable ... */ diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index c06e061..12607d4 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -313,8 +313,7 @@ double gfx_get_text_width_libart ( gfx_canvas_t *canvas, return text_width/64; } -static void gfx_libart_close_path(gfx_canvas_t *canvas, - gfx_node_t *node, ArtVpath **vec) +static void gfx_libart_close_path(gfx_node_t *node, ArtVpath **vec) { /* libart must have end==start for closed paths, even if using ART_MOVETO and not ART_MOVETO_OPEN @@ -326,8 +325,7 @@ static void gfx_libart_close_path(gfx_canvas_t *canvas, art_vpath_add_point (vec, &points, &points_max, ART_END, 0, 0); } -static void gfx_round_scaled_coordinates(gfx_canvas_t *canvas, - gfx_node_t *node, ArtVpath *vec) +static void gfx_round_scaled_coordinates(ArtVpath *vec) { while (vec->code != ART_END) { vec->x = floor(vec->x - LINEOFFSET + 0.5) + LINEOFFSET; @@ -503,8 +501,8 @@ int gfx_render_png (gfx_canvas_t *canvas, art_affine_scale(dst,canvas->zoom,canvas->zoom); vec = art_vpath_affine_transform(node->path,dst); if (node->closed_path) - gfx_libart_close_path(canvas, node, &vec); - gfx_round_scaled_coordinates(canvas, node, vec); + gfx_libart_close_path(node, &vec); + gfx_round_scaled_coordinates(vec); if(node->type == GFX_LINE){ svp = art_svp_vpath_stroke ( vec, ART_PATH_STROKE_JOIN_ROUND, ART_PATH_STROKE_CAP_ROUND, @@ -602,13 +600,13 @@ int gfx_render_png (gfx_canvas_t *canvas, gr = bit->bitmap.num_grays -1; for (iy=0; iy < bit->bitmap.rows; iy++){ long buf_y = iy+(pen_y+0.5)-bit->top; - if (buf_y < 0 || buf_y >= pys_height) continue; + if (buf_y < 0 || buf_y >= (long)pys_height) continue; buf_y *= rowstride; for (ix=0;ix < bit->bitmap.width;ix++){ long buf_x = ix + (pen_x + 0.5) + (double)bit->left ; art_u8 font_alpha; - if (buf_x < 0 || buf_x >= pys_width) continue; + if (buf_x < 0 || buf_x >= (long)pys_width) continue; buf_x *= bytes_per_pixel ; font_alpha = *(bit->bitmap.buffer + iy * bit->bitmap.width + ix); font_alpha = (art_u8)((double)font_alpha / gr * falpha); diff --git a/src/rrd_graph.c b/src/rrd_graph.c index a7bc3f2..a44cb09 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -601,7 +601,7 @@ printf("row_cnt after: %lu\n",row_cnt); ** into one interval for the destination. */ - for (dst_row=0;row_cnt>=reduce_factor;dst_row++) { + for (dst_row=0;(long int)row_cnt>=reduce_factor;dst_row++) { for (col=0;col<(*ds_cnt);col++) { rrd_value_t newval=DNAN; unsigned long validval=0; @@ -681,11 +681,11 @@ for (col=0;colgdes_c;i++){ + for (i=0;i< (int)im->gdes_c;i++){ /* only GF_DEF elements fetch data */ if (im->gdes[i].gf != GF_DEF) continue; @@ -744,7 +744,7 @@ data_fetch(image_desc_t *im ) } /* lets see if the required data source is really there */ - for(ii=0;iigdes[i].ds_cnt;ii++){ + for(ii=0;ii<(int)im->gdes[i].ds_cnt;ii++){ if(strcmp(im->gdes[i].ds_namv[ii],im->gdes[i].ds_nam) == 0){ im->gdes[i].ds=ii; } } @@ -1015,8 +1015,8 @@ data_proc( image_desc_t *im ){ ** the time of the graph. Beware. */ vidx = im->gdes[ii].vidx; - if ( (gr_time >= im->gdes[vidx].start) && - (gr_time <= im->gdes[vidx].end) ) { + if ( ((long int)gr_time >= (long int)im->gdes[vidx].start) && + ((long int)gr_time <= (long int)im->gdes[vidx].end) ) { value = im->gdes[vidx].data[ (unsigned long) floor( (double)(gr_time - im->gdes[vidx].start) @@ -1908,9 +1908,8 @@ grid_paint(image_desc_t *im) /* horrible hack until we can actually print vertically */ { int n; - int l=strlen(im->ylegend); char s[2]; - for (n=0;nylegend);n++) { + for (n=0;n< (int)strlen(im->ylegend);n++) { s[0]=im->ylegend[n]; s[1]='\0'; gfx_new_text(im->canvas,7,im->text_prop[TEXT_PROP_AXIS].size*(n+1), @@ -2853,13 +2852,13 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) &im->xlab_user.precis, &stroff) == 7 && stroff != 0){ strncpy(im->xlab_form, optarg+stroff, sizeof(im->xlab_form) - 1); - if((im->xlab_user.gridtm = tmt_conv(scan_gtm)) == -1){ + if((int)(im->xlab_user.gridtm = tmt_conv(scan_gtm)) == -1){ rrd_set_error("unknown keyword %s",scan_gtm); return; - } else if ((im->xlab_user.mgridtm = tmt_conv(scan_mtm)) == -1){ + } else if ((int)(im->xlab_user.mgridtm = tmt_conv(scan_mtm)) == -1){ rrd_set_error("unknown keyword %s",scan_mtm); return; - } else if ((im->xlab_user.labtm = tmt_conv(scan_ltm)) == -1){ + } else if ((int)(im->xlab_user.labtm = tmt_conv(scan_ltm)) == -1){ rrd_set_error("unknown keyword %s",scan_ltm); return; } @@ -2936,7 +2935,7 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) im->imginfo = optarg; break; case 'a': - if((im->canvas->imgformat = if_conv(optarg)) == -1) { + if((int)(im->canvas->imgformat = if_conv(optarg)) == -1) { rrd_set_error("unsupported graphics format '%s'",optarg); return; } @@ -3167,12 +3166,12 @@ char *str; n=0; sscanf(str,"%le,%29[A-Z]%n",¶m,func,&n); - if (n==strlen(str)) { /* matched */ + if (n== (int)strlen(str)) { /* matched */ ; } else { n=0; sscanf(str,"%29[A-Z]%n",func,&n); - if (n==strlen(str)) { /* matched */ + if (n== (int)strlen(str)) { /* matched */ param=DNAN; } else { rrd_set_error("Unknown function string '%s' in VDEF '%s'" diff --git a/src/rrd_graph_helper.c b/src/rrd_graph_helper.c index ef1e8e7..a15c0ed 100644 --- a/src/rrd_graph_helper.c +++ b/src/rrd_graph_helper.c @@ -2,6 +2,27 @@ #define dprintf if (gdp->debug) printf +/* Define prototypes for the parsing methods. + Inputs: + char *line - pointer to base of input source + unsigned int eaten - index to next input character (INPUT/OUTPUT) + graph_desc_t *gdp - pointer to a graph description + image_desc_t *im - pointer to an image description +*/ + +int rrd_parse_find_gf (char *, unsigned int *, graph_desc_t *); +int rrd_parse_legend (char *, unsigned int *, graph_desc_t *); +int rrd_parse_color (char *, graph_desc_t *); +int rrd_parse_CF (char *, unsigned int *, graph_desc_t *); +int rrd_parse_print (char *, unsigned int *, graph_desc_t *, image_desc_t *); +int rrd_parse_PVHLAST (char *, unsigned int *, graph_desc_t *, image_desc_t *); +int rrd_parse_vname (char *, unsigned int *, graph_desc_t *, image_desc_t *); +int rrd_parse_def (char *, unsigned int *, graph_desc_t *, image_desc_t *); +int rrd_parse_vdef (char *, unsigned int *, graph_desc_t *, image_desc_t *); +int rrd_parse_cdef (char *, unsigned int *, graph_desc_t *, image_desc_t *); + + + int rrd_parse_find_gf(char *line, unsigned int *eaten, graph_desc_t *gdp) { char funcname[11],c1=0,c2=0; diff --git a/src/rrd_last.c b/src/rrd_last.c index 78ba5a3..ad8075e 100644 --- a/src/rrd_last.c +++ b/src/rrd_last.c @@ -9,23 +9,19 @@ #include "rrd_tool.h" time_t -rrd_last(int argc, char **argv) +rrd_last(int argc, const char **argv) { - time_t lastup; - if(argc < 2){ rrd_set_error("please specify an rrd"); return(-1); } - lastup = rrd_last_r(argv[1]); - - return(lastup); + return( rrd_last_r(argv[1]) ); } time_t -rrd_last_r(char *filename) +rrd_last_r(const char *filename) { FILE *in_file; time_t lastup; diff --git a/src/rrd_open.c b/src/rrd_open.c index 443a1a5..66d1865 100644 --- a/src/rrd_open.c +++ b/src/rrd_open.c @@ -5,6 +5,9 @@ ***************************************************************************** * $Id$ * $Log$ + * Revision 1.10 2004/05/26 22:11:12 oetiker + * reduce compiler warnings. Many small fixes. -- Mike Slifcak + * * Revision 1.9 2003/04/29 21:56:49 oetiker * readline in rrd_open.c reads the file in 8 KB blocks, and calls realloc for * each block. realloc is very slow in Mac OS X for huge blocks, e.g. when @@ -66,7 +69,7 @@ /* positioned to the first cdp in the first rra */ int -rrd_open(char *file_name, FILE **in_file, rrd_t *rrd, int rdwr) +rrd_open(const char *file_name, FILE **in_file, rrd_t *rrd, int rdwr) { @@ -190,7 +193,7 @@ void rrd_freemem(void *mem) if (mem) free(mem); } -int readfile(char *file_name, char **buffer, int skipfirst){ +int readfile(const char *file_name, char **buffer, int skipfirst){ long writecnt=0,totalcnt = MEMBLK; long offset = 0; FILE *input=NULL; diff --git a/src/rrd_resize.c b/src/rrd_resize.c index ddbf9ec..3e67af7 100644 --- a/src/rrd_resize.c +++ b/src/rrd_resize.c @@ -69,7 +69,7 @@ rrd_resize(int argc, char **argv) } if (modify < 0) - if (rrdold.rra_def[target_rra].row_cnt <= -modify) { + if ((long)rrdold.rra_def[target_rra].row_cnt <= -modify) { rrd_set_error("This RRA is not that big"); rrd_free(&rrdold); fclose(infile); @@ -145,7 +145,7 @@ rrd_resize(int argc, char **argv) signed long int remove_end=0; remove_end=(rrdnew.rra_ptr[target_rra].cur_row-modify)%rrdnew.rra_def[target_rra].row_cnt; - if (remove_end <= rrdnew.rra_ptr[target_rra].cur_row) { + if (remove_end <= (signed long int)rrdnew.rra_ptr[target_rra].cur_row) { while (remove_end >= 0) { fseek(infile,sizeof(rrd_value_t)*rrdnew.stat_head->ds_cnt,SEEK_CUR); rrdnew.rra_ptr[target_rra].cur_row--; diff --git a/src/rrd_restore.c b/src/rrd_restore.c index e759c1c..3e55490 100644 --- a/src/rrd_restore.c +++ b/src/rrd_restore.c @@ -169,7 +169,7 @@ int xml2rrd(char* buf, rrd_t* rrd, char rc){ read_tag(&ptr2,"type",DST_FMT,rrd->ds_def[rrd->stat_head->ds_cnt-1].dst); /* test for valid type */ - if(dst_conv(rrd->ds_def[rrd->stat_head->ds_cnt-1].dst) == -1) return -1; + if( (int)dst_conv(rrd->ds_def[rrd->stat_head->ds_cnt-1].dst) == -1) return -1; if (dst_conv(rrd->ds_def[rrd->stat_head->ds_cnt-1].dst) != DST_CDEF) { @@ -211,7 +211,7 @@ int xml2rrd(char* buf, rrd_t* rrd, char rc){ read_tag(&ptr2,"cf",CF_NAM_FMT,rrd->rra_def[rrd->stat_head->rra_cnt-1].cf_nam); /* test for valid type */ - if(cf_conv(rrd->rra_def[rrd->stat_head->rra_cnt-1].cf_nam) == -1) return -1; + if( (int)cf_conv(rrd->rra_def[rrd->stat_head->rra_cnt-1].cf_nam) == -1) return -1; read_tag(&ptr2,"pdp_per_row","%lu",&(rrd->rra_def[rrd->stat_head->rra_cnt-1].pdp_cnt)); /* support to read RRA parameters */ @@ -265,7 +265,7 @@ int xml2rrd(char* buf, rrd_t* rrd, char rc){ } eat_tag(&ptr2, "/params"); eat_tag(&ptr2,"cdp_prep"); - for(i=0;istat_head->ds_cnt;i++) + for(i=0;i< (int)rrd->stat_head->ds_cnt;i++) { eat_tag(&ptr2,"ds"); /* support to read CDP parameters */ @@ -348,7 +348,7 @@ int xml2rrd(char* buf, rrd_t* rrd, char rc){ rows++; mempool--; rrd->rra_def[rrd->stat_head->rra_cnt-1].row_cnt++; - for(i=0;istat_head->ds_cnt;i++){ + for(i=0;i< (int)rrd->stat_head->ds_cnt;i++){ rrd_value_t * value = &(rrd->rrd_value[(rows-1)*rrd->stat_head->ds_cnt+i]); @@ -387,7 +387,7 @@ int xml2rrd(char* buf, rrd_t* rrd, char rc){ return(-1); } - for(i=0; i stat_head->rra_cnt; i++) { + for(i=0; i < (int)rrd->stat_head->rra_cnt; i++) { /* last row in the xml file is the most recent; as * rrd_update increments the current row pointer, set cur_row * here to the last row. */ diff --git a/src/rrd_tool.c b/src/rrd_tool.c index 6892ac5..6aa53cc 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -84,7 +84,9 @@ void PrintUsage(char *cmd) "\t\t[--resolution|-r resolution]\n" "\t\t[--start|-s start] [--end|-e end]\n\n"; - char help_graph[] = +/* break up very large strings (help_graph, help_tune) for ISO C89 compliance*/ + + char help_graph1[] = "* graph - generate a graph from one or several RRD\n\n" "\trrdtool graph filename [-s|--start seconds] [-e|--end seconds]\n" "\t\t[-x|--x-grid x-axis grid and label]\n" @@ -94,7 +96,8 @@ void PrintUsage(char *cmd) "\t\t[-h|--height pixels] [-o|--logarithmic]\n" "\t\t[-u|--upper-limit value] [-z|--lazy]\n" "\t\t[-l|--lower-limit value] [-r|--rigid]\n" - "\t\t[-g|--no-legend]\n" + "\t\t[-g|--no-legend]\n"; + char help_graph2[] = "\t\t[-j|--only-graph]\n" "\t\t[--font FONTTAG:size:font]\n" "\t\t[--zoom factor]\n" @@ -104,7 +107,8 @@ void PrintUsage(char *cmd) "\t\t[--step seconds]\n" "\t\t[-f|--imginfo printfstr]\n" "\t\t[-a|--imgformat PNG]\n" - "\t\t[-c|--color COLORTAG#rrggbb[aa]] [-t|--title string]\n" + "\t\t[-c|--color COLORTAG#rrggbb[aa]] [-t|--title string]\n"; + char help_graph3[] = "\t\t[DEF:vname=rrd:ds-name:CF]\n" "\t\t[CDEF:vname=rpn-expression]\n" "\t\t[PRINT:vname:CF:format]\n" @@ -115,7 +119,7 @@ void PrintUsage(char *cmd) "\t\t[AREA:vname[#rrggbb[aa][:legend]]]\n" "\t\t[STACK:vname[#rrggbb[aa][:legend]]]\n\n"; - char help_tune[] = + char help_tune1[] = " * tune - Modify some basic properties of an RRD\n\n" "\trrdtool tune filename\n" "\t\t[--heartbeat|-h ds-name:heartbeat]\n" @@ -125,7 +129,9 @@ void PrintUsage(char *cmd) "\t\t[--deltapos scale-value] [--deltaneg scale-value]\n" "\t\t[--failure-threshold integer]\n" "\t\t[--window-length integer]\n" - "\t\t[--alpha adaptation-parameter]\n" + "\t\t[--alpha adaptation-parameter]\n"; + char help_tune2[] = + " * tune - Modify some basic properties of an RRD\n\n" "\t\t[--beta adaptation-parameter]\n" "\t\t[--gamma adaptation-parameter]\n" "\t\t[--gamma-deviation adaptation-parameter]\n" @@ -241,10 +247,13 @@ void PrintUsage(char *cmd) fputs(help_fetch, stdout); break; case C_GRAPH: - fputs(help_graph, stdout); + fputs(help_graph1, stdout); + fputs(help_graph2, stdout); + fputs(help_graph3, stdout); break; case C_TUNE: - fputs(help_tune, stdout); + fputs(help_tune1, stdout); + fputs(help_tune2, stdout); break; case C_RESIZE: fputs(help_resize, stdout); @@ -320,7 +329,7 @@ int main(int argc, char *argv[]) if (strcmp(firstdir,"")){ chdir(firstdir); if (errno!=0){ - fprintf(stderr,"ERROR: %s\n",strerror(errno)); + fprintf(stderr,"ERROR: %s\n",rrd_strerror(errno)); exit(errno); } } @@ -417,7 +426,7 @@ int HandleInputLine(int argc, char **argv, FILE* out) #endif chdir(argv[2]); if (errno!=0){ - printf("ERROR: %s\n",strerror(errno)); + printf("ERROR: %s\n",rrd_strerror(errno)); } return(0); } @@ -435,7 +444,7 @@ int HandleInputLine(int argc, char **argv, FILE* out) #endif mkdir(argv[2],0777); if (errno!=0){ - printf("ERROR: %s\n",strerror(errno)); + printf("ERROR: %s\n",rrd_strerror(errno)); } return(0); } @@ -460,7 +469,7 @@ int HandleInputLine(int argc, char **argv, FILE* out) } } else{ - printf("ERROR: %s\n",strerror(errno)); + printf("ERROR: %s\n",rrd_strerror(errno)); return(errno); } return(0); @@ -530,7 +539,7 @@ int HandleInputLine(int argc, char **argv, FILE* out) else if (strcmp("resize", argv[1]) == 0) rrd_resize(argc-1, &argv[1]); else if (strcmp("last", argv[1]) == 0) - printf("%ld\n",rrd_last(argc-1, &argv[1])); + printf("%ld\n",rrd_last(argc-1, argv[1])); else if (strcmp("update", argv[1]) == 0) rrd_update(argc-1, &argv[1]); else if (strcmp("fetch", argv[1]) == 0) { @@ -606,7 +615,9 @@ int HandleInputLine(int argc, char **argv, FILE* out) } else if (strcmp("graph", argv[1]) == 0) { char **calcpr; +#ifdef notused /*XXX*/ const char *imgfile = argv[2]; /* rrd_graph changes argv pointer */ +#endif int xsize, ysize; int i; int tostdout = (strcmp(argv[2],"-") == 0); diff --git a/src/rrd_tool.h b/src/rrd_tool.h index 92c99ae..dbfb26b 100644 --- a/src/rrd_tool.h +++ b/src/rrd_tool.h @@ -171,10 +171,8 @@ void rrd_free(rrd_t *rrd); void rrd_freemem(void *mem); void rrd_init(rrd_t *rrd); -int rrd_open(char *file_name, FILE **in_file, rrd_t *rrd, int rdwr); -int rrd_open_r(char *file_name, FILE **in_file, rrd_t *rrd, int rdwr); -int readfile(char *file, char **buffer, int skipfirst); -int readfile_r(char *file, char **buffer, int skipfirst); +int rrd_open(const char *file_name, FILE **in_file, rrd_t *rrd, int rdwr); +int readfile(const char *file, char **buffer, int skipfirst); #define RRD_READONLY 0 #define RRD_READWRITE 1 @@ -189,9 +187,6 @@ double rrd_diff(char *a, char *b); thread overwrite the same buffer */ const char *rrd_strerror(int err); -/* just a defensive work-around... */ -#define strerror(x) rrd_strerror(x) - #endif #ifdef __cplusplus diff --git a/src/rrd_tune.c b/src/rrd_tune.c index 2996b92..1b5515d 100644 --- a/src/rrd_tune.c +++ b/src/rrd_tune.c @@ -5,6 +5,9 @@ ***************************************************************************** * $Id$ * $Log$ + * Revision 1.6 2004/05/26 22:11:12 oetiker + * reduce compiler warnings. Many small fixes. -- Mike Slifcak + * * Revision 1.5 2002/02/01 20:34:49 oetiker * fixed version number and date/time * @@ -156,7 +159,7 @@ rrd_tune(int argc, char **argv) fclose(rrd_file); return -1; } - if (dst_conv(dst) == -1){ + if ((int)dst_conv(dst) == -1){ rrd_free(&rrd); fclose(rrd_file); return -1; @@ -277,7 +280,7 @@ rrd_tune(int argc, char **argv) rrd_file); } else { int i; - for(i=0;i< rrd.stat_head->ds_cnt;i++) + for(i=0;i< (int)rrd.stat_head->ds_cnt;i++) if (dst_conv(rrd.ds_def[i].dst) != DST_CDEF) { printf("DS[%s] typ: %s\thbt: %ld\tmin: %1.4f\tmax: %1.4f\n", rrd.ds_def[i].ds_nam, diff --git a/src/rrd_update.c b/src/rrd_update.c index 117de6a..583d9ac 100644 --- a/src/rrd_update.c +++ b/src/rrd_update.c @@ -5,6 +5,9 @@ ***************************************************************************** * $Id$ * $Log$ + * Revision 1.17 2004/05/26 22:11:12 oetiker + * reduce compiler warnings. Many small fixes. -- Mike Slifcak + * * Revision 1.16 2004/05/25 20:52:16 oetiker * fix spelling and syntax, especially in messages that are printed -- Mike Slifcak * @@ -1441,31 +1444,31 @@ int LockRRD(FILE *rrdfile) { int rrd_fd; /* File descriptor for RRD */ - int stat; + int rcstat; rrd_fd = fileno(rrdfile); { #ifndef WIN32 - struct flock lock; + struct flock lock; lock.l_type = F_WRLCK; /* exclusive write lock */ lock.l_len = 0; /* whole file */ lock.l_start = 0; /* start of file */ lock.l_whence = SEEK_SET; /* end of file */ - stat = fcntl(rrd_fd, F_SETLK, &lock); + rcstat = fcntl(rrd_fd, F_SETLK, &lock); #else - struct _stat st; + struct _stat st; - if ( _fstat( rrd_fd, &st ) == 0 ) { - stat = _locking ( rrd_fd, _LK_NBLCK, st.st_size ); - } else { - stat = -1; - } + if ( _fstat( rrd_fd, &st ) == 0 ) { + rcstat = _locking ( rrd_fd, _LK_NBLCK, st.st_size ); + } else { + rcstat = -1; + } #endif } - return(stat); + return(rcstat); } diff --git a/src/rrd_xport.c b/src/rrd_xport.c index c12b783..cceefe2 100644 --- a/src/rrd_xport.c +++ b/src/rrd_xport.c @@ -128,7 +128,7 @@ rrd_xport(int argc, char **argv, int *xsize, char varname[30],*rpnex; gdes_alloc(&im); if(sscanf(argv[i],"%10[A-Z0-9]:%n",symname,&argstart)==1){ - if((im.gdes[im.gdes_c-1].gf=gf_conv(symname))==-1){ + if((int)(im.gdes[im.gdes_c-1].gf=gf_conv(symname))==-1){ im_free(&im); rrd_set_error("unknown function '%s'",symname); return -1; @@ -199,7 +199,7 @@ rrd_xport(int argc, char **argv, int *xsize, im.gdes[im.gdes_c-1].vname); return -1; } - if((im.gdes[im.gdes_c-1].cf=cf_conv(symname))==-1){ + if((int)(im.gdes[im.gdes_c-1].cf=cf_conv(symname))==-1){ im_free(&im); rrd_set_error("unknown cf '%s'",symname); return -1; @@ -396,8 +396,8 @@ rrd_xport_fn(image_desc_t *im, } /* fill data structure */ - for(dst_row = 0; dst_row < row_cnt; dst_row++) { - for(i = 0; i < nof_xports; i++) { + for(dst_row = 0; (int)dst_row < (int)row_cnt; dst_row++) { + for(i = 0; i < (int)nof_xports; i++) { j = ref_list[i]; ii = im->gdes[j].vidx; ds_cnt = &im->gdes[ii].ds_cnt;