From 9c8b4f051ae56fa7ec4b30ed45836e9715fb3cc9 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sat, 28 Jan 2006 19:22:08 +0000 Subject: Fix compile time warnings. --- common/compat.c | 3 ++- common/config-parser.c | 1 - common/config-parser.h | 2 +- common/hash.c | 1 + common/server-mainloop.c | 18 +++++++----------- configure.in | 2 ++ daemon/Makefile.am | 2 +- daemon/config.c | 7 +++++-- daemon/rrd-update.c | 4 +++- daemon/rrdbotd.c | 14 +++++++++++--- daemon/snmp-engine.c | 5 +++-- mib/parse-compat.inc.c | 6 +++--- mib/parse.c | 1 + mibs/Makefile | 2 +- tools/rrdbot-create.c | 12 ++++++++---- 15 files changed, 49 insertions(+), 31 deletions(-) diff --git a/common/compat.c b/common/compat.c index 247560e..67d3997 100644 --- a/common/compat.c +++ b/common/compat.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include "usuals.h" @@ -238,7 +239,7 @@ xcalloc(size_t size) { register void* value = calloc(1, size); if(value == NULL) - errx("out of memory"); + errx(1, "out of memory"); return value; } diff --git a/common/config-parser.c b/common/config-parser.c index 5c1aa98..10bf20f 100644 --- a/common/config-parser.c +++ b/common/config-parser.c @@ -121,7 +121,6 @@ cfg_parse_file(const char* filename, void* data, char** memory) int ret = -1; char* p; char* t; - int pos; ASSERT(filename); diff --git a/common/config-parser.h b/common/config-parser.h index 94d96c9..174bac2 100644 --- a/common/config-parser.h +++ b/common/config-parser.h @@ -41,7 +41,7 @@ /* Callbacks must be defined by the caller */ extern int cfg_value(const char* filename, const char* header, const char* name, char* value, void* data); -extern int cfg_errcallback(const char* filename, const char* errmsg, void* data); +extern int cfg_error(const char* filename, const char* errmsg, void* data); /* Calling these will call the callbacks above */ int cfg_parse_dir(const char* dirname, void* data); diff --git a/common/hash.c b/common/hash.c index 789e85c..c99a689 100644 --- a/common/hash.c +++ b/common/hash.c @@ -53,6 +53,7 @@ #include #include +#include #include "hash.h" #define KEY_DATA(he) ((he)->key) diff --git a/common/server-mainloop.c b/common/server-mainloop.c index 07f02b2..6ea8985 100644 --- a/common/server-mainloop.c +++ b/common/server-mainloop.c @@ -97,18 +97,14 @@ timeval_compare(struct timeval* t1, struct timeval* t2) #define timeval_to_ms(tv) \ ((((uint64_t)(tv).tv_sec) * 1000L) + (((uint64_t)(tv).tv_usec) / 1000L)) -static int -timeval_dump(struct timeval* tv) -{ - fprintf(stderr, "{ %d:%d }", tv->tv_sec, tv->tv_usec / 1000); -} +#define timeval_dump(tv) \ + (fprintf(stderr, "{ %d:%d }", (uint)((tv)->tv_sec), (uint)((tv)->tv_usec / 1000)) static int add_timer(int ms, int oneshot, server_timer_callback callback, void* arg) { struct timeval interval; timer_callback* cb; - int i; ASSERT(ms > 0); ASSERT(callback != NULL); @@ -150,10 +146,9 @@ remove_timer(timer_callback* timcb) { timer_callback* cb; timer_callback* next; - int i; if(!ctx.timers) - return; + return NULL; /* First in list */; if(ctx.timers == timcb) @@ -175,6 +170,9 @@ remove_timer(timer_callback* timcb) return cb->next; } } + + /* Couldn't remove, return self */ + return timcb; } void @@ -232,7 +230,7 @@ server_run() timer_callback* timcb; socket_callback* sockcb; fd_set rfds, wfds; - int r, i; + int r; /* No watches have been set */ ASSERT(ctx.max_fd > -1); @@ -346,7 +344,6 @@ int server_watch(int fd, int type, server_socket_callback callback, void* arg) { socket_callback* cb; - int i; ASSERT(type != 0); ASSERT(fd != -1); ASSERT(callback != NULL); @@ -380,7 +377,6 @@ void server_unwatch(int fd) { socket_callback* cb; - int i; ASSERT(fd != -1); diff --git a/configure.in b/configure.in index 9dc3570..7c0468f 100644 --- a/configure.in +++ b/configure.in @@ -8,6 +8,8 @@ CFLAGS="$CFLAGS -I/usr/local/include" AC_CONFIG_SRCDIR([daemon/rrdbotd.c]) AM_CONFIG_HEADER([config.h]) +CFLAGS="$CFLAGS -Wall" + # Debug mode AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], diff --git a/daemon/Makefile.am b/daemon/Makefile.am index dda6ceb..466353b 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -1,7 +1,7 @@ sbin_PROGRAMS = rrdbotd -rrdbotd_SOURCES = rrdbotd.c rrdbotd.h config.c usuals.h \ +rrdbotd_SOURCES = rrdbotd.c rrdbotd.h config.c \ snmp-help.c snmp-engine.c rrd-update.c \ ../common/server-mainloop.c ../common/server-mainloop.h \ ../common/sock-any.h ../common/sock-any.c \ diff --git a/daemon/config.c b/daemon/config.c index 8c20c4a..ce6e397 100644 --- a/daemon/config.c +++ b/daemon/config.c @@ -42,8 +42,10 @@ #include #include #include +#include #include "rrdbotd.h" +#include "config-parser.h" /* * These routines parse the configuration files and setup the in memory @@ -279,7 +281,7 @@ parse_item(const char* field, char* uri, config_ctx *ctx) { rb_message(LOG_WARNING, "couldn't resolve host address (ignoring): %s", host); free(rhost); - return; + return NULL; } /* And add it to the list */ @@ -305,6 +307,8 @@ parse_item(const char* field, char* uri, config_ctx *ctx) /* And add it to the list */ ritem->next = ctx->items; ctx->items = ritem; + + return ritem; } static void @@ -349,7 +353,6 @@ config_value(const char* header, const char* name, char* value, /* If it starts with "field." */ else if(strncmp(name, CONFIG_FIELD, KL(CONFIG_FIELD)) == 0) { - rb_poller* poll; const char* field; const char* t; diff --git a/daemon/rrd-update.c b/daemon/rrd-update.c index 295eea6..ca8d71b 100644 --- a/daemon/rrd-update.c +++ b/daemon/rrd-update.c @@ -43,6 +43,8 @@ #include #include +#include + #include "rrdbotd.h" #define MAX_NUMLEN 40 @@ -120,7 +122,7 @@ void rb_rrd_update(rb_poller *poll) rb_messagex(LOG_DEBUG, "> values: %s", items); rrd_clear_error(); - r = rrd_update(5, argv); + r = rrd_update(5, (char**)argv); if(r != 0) rb_messagex(LOG_ERR, "couldn't update rrd file: %s: %s", diff --git a/daemon/rrdbotd.c b/daemon/rrdbotd.c index c28825d..261955d 100644 --- a/daemon/rrdbotd.c +++ b/daemon/rrdbotd.c @@ -42,11 +42,13 @@ #include #include #include +#include #include #include #include "rrdbotd.h" +#include "server-mainloop.h" /* The default command line options */ #define DEFAULT_CONFIG CONF_PREFIX "/rrdbot" @@ -72,11 +74,12 @@ static int debug_level = LOG_ERR; #include "mib/parse.h" +#ifdef TEST + static void test(int argc, char* argv[]) { struct snmp_value val; - mib_node n, n2; debug_level = 4; @@ -98,6 +101,8 @@ test(int argc, char* argv[]) exit(1); } +#endif /* TEST */ + /* ----------------------------------------------------------------------------- * LOGGING */ @@ -211,7 +216,10 @@ main(int argc, char* argv[]) char ch; char* t; - /* test(argc, argv); */ +#ifdef TEST + test(argc, argv); + return 1; +#endif /* Initialize the state stuff */ memset(&g_state, 0, sizeof(g_state)); @@ -310,7 +318,7 @@ main(int argc, char* argv[]) { /* Fork a daemon nicely */ if(daemon(0, 0) == -1) - err("couldn't fork as a daemon"); + err(1, "couldn't fork as a daemon"); rb_messagex(LOG_DEBUG, "running as a daemon"); daemonized = 1; diff --git a/daemon/snmp-engine.c b/daemon/snmp-engine.c index 66cc047..37637ab 100644 --- a/daemon/snmp-engine.c +++ b/daemon/snmp-engine.c @@ -38,7 +38,9 @@ #include "usuals.h" #include +#include #include +#include #include #include @@ -121,7 +123,7 @@ new_req() { rb_request* req = NULL; uint num; - int i, first, overlap = 0; + int i, overlap = 0; if(nrequests) { @@ -335,7 +337,6 @@ respond_req(rb_request* req, struct snmp_pdu* pdu, mstime when) struct snmp_value* value; rb_poller* poll = req->poll; rb_item* item; - int incomplete = 0; int i; ASSERT(req->id == pdu->request_id); diff --git a/mib/parse-compat.inc.c b/mib/parse-compat.inc.c index 56b42d4..8f8fc0d 100644 --- a/mib/parse-compat.inc.c +++ b/mib/parse-compat.inc.c @@ -56,7 +56,7 @@ static int initialized = 0; #define TRUE 1 /* No need to implement these */ -#define DEBUGMSGTL +#define DEBUGMSGTL(x) #define set_function(tp) /* Just return the tree head */ @@ -102,7 +102,7 @@ netsnmp_ds_get_int(int dummy, int var) #define netsnmp_ds_set_boolean(a, b, c) #define netsnmp_ds_toggle_boolean(a, b) -static int +static void snmp_log(int level, const char* msg, ...) { va_list ap; @@ -116,7 +116,7 @@ snmp_log(int level, const char* msg, ...) } /* Only used to open files */ -static int +static void snmp_log_perror(const char* file) { rb_message(LOG_ERR, "couldn't open file: %s", file); diff --git a/mib/parse.c b/mib/parse.c index d4987d3..aeb449f 100644 --- a/mib/parse.c +++ b/mib/parse.c @@ -63,6 +63,7 @@ SOFTWARE. #include #include #include +#include #include #include diff --git a/mibs/Makefile b/mibs/Makefile index eed2516..a785979 100644 --- a/mibs/Makefile +++ b/mibs/Makefile @@ -65,7 +65,7 @@ AUTOMAKE = ${SHELL} /data/projects/rrdbot/missing --run automake-1.9 AWK = mawk CC = gcc CCDEPMODE = depmode=gcc3 -CFLAGS = -I/usr/local/include -g -O0 +CFLAGS = -I/usr/local/include -Wall -g -O0 CPP = gcc -E CPPFLAGS = CYGPATH_W = echo diff --git a/tools/rrdbot-create.c b/tools/rrdbot-create.c index 6e2f143..73a5541 100644 --- a/tools/rrdbot-create.c +++ b/tools/rrdbot-create.c @@ -40,6 +40,11 @@ #include #include #include +#include + +#include + +#include "config-parser.h" /* ----------------------------------------------------------------------------- * CONSTANTS @@ -143,7 +148,7 @@ create_file(create_ctx* ctx, const char* rrd) opterr = 0; rrd_clear_error(); - r = rrd_create(argc, argv); + r = rrd_create(argc, (char**)argv); if(r != 0) warnx("couldn't create rrd file: %s: %s", rrd, rrd_get_error()); @@ -276,7 +281,7 @@ cfg_value(const char* filename, const char* header, const char* name, /* Only process this section */ if(strcmp(header, CONFIG_CREATE) != 0) - return; + return 0; /* The rra option */ if(strcmp(name, CONFIG_RRA) == 0) @@ -296,7 +301,7 @@ cfg_value(const char* filename, const char* header, const char* name, warnx("%s: the '%s' field name must only contain characters, digits, underscore and dash", ctx->confname, field); ctx->skip = 1; - return; + return 0; } add_field(ctx, field, value); @@ -345,7 +350,6 @@ main(int argc, char* argv[]) const char* confdir = DEFAULT_CONFIG; create_ctx ctx; char ch; - char* t; memset(&ctx, 0, sizeof(ctx)); ctx.workdir = DEFAULT_WORK; -- cgit v1.2.3