From 90d4051c0ca3db621c23331beb9c27ea51702948 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 20 May 2010 15:17:51 +0100 Subject: [PATCH] turn on a bunch of warnings --- Makefile.am | 13 +++++++++++++ Makefile.in | 9 ++++++++- innduct.c | 38 ++++++++++++++++++++++---------------- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/Makefile.am b/Makefile.am index 27835cd..e9a82be 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,6 +2,19 @@ AUTOMAKE_OPTIONS=foreign INCLUDES = -I/usr/include/inn +WERROR = -Werror +CMDLINE_CFLAGS = + +WARNINGS= \ + -Wall -Wformat=2 -Wno-format-zero-length \ + -Wshadow -Wpointer-arith -Wbad-function-cast \ + -Wwrite-strings -Wsign-compare -Wstrict-prototypes \ + -Wmissing-prototypes -Wmissing-declarations \ + -Wmissing-format-attribute -Wredundant-decls -Wnested-externs \ + -Wno-pointer-sign + +CFLAGS = @CFLAGS@ $(WARNINGS) $(WERROR) $(CMDLINE_CFLAGS) + bin_PROGRAMS = innduct innduct_SOURCES = innduct.c __oop-read-copy.c innduct_LDADD = -L/usr/lib/news -lstorage -linn -lm -loop diff --git a/Makefile.in b/Makefile.in index 38b4eec..4f839a5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -71,6 +71,14 @@ AUTOMAKE_OPTIONS = foreign INCLUDES = -I/usr/include/inn +WERROR = -Werror +CMDLINE_CFLAGS = + +WARNINGS = -Wall -Wformat=2 -Wno-format-zero-length -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wsign-compare -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wmissing-format-attribute -Wredundant-decls -Wnested-externs -Wno-pointer-sign + + +CFLAGS = @CFLAGS@ $(WARNINGS) $(WERROR) $(CMDLINE_CFLAGS) + bin_PROGRAMS = innduct innduct_SOURCES = innduct.c __oop-read-copy.c innduct_LDADD = -L/usr/lib/news -lstorage -linn -lm -loop @@ -90,7 +98,6 @@ LIBS = @LIBS@ innduct_OBJECTS = innduct.o __oop-read-copy.o innduct_DEPENDENCIES = innduct_LDFLAGS = -CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ diff --git a/innduct.c b/innduct.c index 445157d..5755855 100644 --- a/innduct.c +++ b/innduct.c @@ -594,7 +594,9 @@ static void logv(int sysloglevel, const char *pfx, int errnoval, va_end(al); \ } -#define INNLOGSET_DECLARE(fn, pfx, sysloglevel) \ +#define INNLOGSET_DECLARE(fn, pfx, sysloglevel) \ + static void duct_log_##fn(int l, const char *fmt, va_list al, int errval) \ + PRINTF(3,0); \ static void duct_log_##fn(int l, const char *fmt, va_list al, int errval) { \ logv(sysloglevel, pfx, errval ? errval : -1, fmt, al); \ } @@ -741,8 +743,8 @@ static void xgettimeofday(struct timeval *tv_r) { if (r) syscrash("gettimeofday(2) failed"); } -static void xsetnonblock(int fd, int nonblocking) { - int errnoval= oop_fd_nonblock(fd, nonblocking); +static void xsetnonblock(int fd, int nonb) { + int errnoval= oop_fd_nonblock(fd, nonb); if (errnoval) { errno= errnoval; syscrash("setnonblocking"); } } @@ -910,7 +912,7 @@ POKES("prod ", ccmd_setint_period) static void *cli_rd_ok(oop_source *lp, oop_read *oread, oop_rd_event ev, const char *errmsg, int errnoval, - const char *data, size_t recsz, void *cc_v) { + const char *data, size_t recszu, void *cc_v) { CliConn *cc= cc_v; if (!data) { @@ -919,7 +921,9 @@ static void *cli_rd_ok(oop_source *lp, oop_read *oread, oop_rd_event ev, return OOP_CONTINUE; } - if (recsz == 0) goto prompt; + if (recszu == 0) goto prompt; + assert(recszu <= INT_MAX); + int recsz= recszu; const CliCommand *ccmd; for (ccmd=cli_commands; ccmd->cmd; ccmd++) { @@ -1630,8 +1634,8 @@ static void inputfile_queue_check_expired(InputFile *ipf) { for (;;) { Article *art= LIST_HEAD(ipf->queue); - int exp= article_check_expired(art); - if (!exp) break; + int expd= article_check_expired(art); + if (!expd) break; } check_reading_pause_resume(ipf); } @@ -1737,7 +1741,8 @@ static void *conn_write_some_xmits(Conn *conn) { assert(donexmitu); struct iovec *vp= &conn->xmit[done]; XmitDetails *dp= &conn->xmitd[done]; - if (rs >= vp->iov_len) { + assert(vp->iov_len <= SSIZE_MAX); + if ((size_t)rs >= vp->iov_len) { rs -= vp->iov_len; xmit_free(dp); /* vp->iov_len -= vp->iov_len, etc. */ done++; @@ -1923,7 +1928,8 @@ static void article_done(Article *art, int whichcount) { " " " " " "; - int w= art->blanklen; if (w >= sizeof(spaces)) w= sizeof(spaces)-1; + int nspaces= sizeof(spaces)-1; + int w= art->blanklen; if (w > nspaces) w= nspaces; int r= pwrite(ipf->fd, spaces, w, art->offset); if (r==-1) { if (errno==EINTR) continue; @@ -2200,7 +2206,7 @@ static void *feedfile_got_article(oop_source *lp, oop_read *rd, /*========== tailing input file ==========*/ -static void *tailing_rable_call_time(oop_source *loop, struct timeval tv, +static void *tailing_rable_call_time(oop_source *lp, struct timeval tv, void *user) { /* lifetime of ipf here is OK because destruction will cause * on_cancel which will cancel this callback */ @@ -2951,7 +2957,8 @@ static void search_backlog_file(void) { /* returns non-0 iff there are any backlog files */ glob_t gl; - int r, i; + int r; + unsigned ui; struct stat stab; const char *oldest_path=0; time_t oldest_mtime=0, now; @@ -2968,8 +2975,8 @@ static void search_backlog_file(void) { case GLOB_NOSPACE: die("out of memory expanding backlog pattern %s", globpat_backlog); case 0: - for (i=0; ishrt || o->lng; o++) if (strlen(o->lng) == len && !memcmp(o->lng,arg,len)) goto found_long; @@ -3835,7 +3842,6 @@ int main(int argc, char **argv) { LIST_INIT(conns); if (interactive < 1) { - int i; for (i=3; i<255; i++) /* do this now before we open syslog, etc. */ close(i); -- 2.30.2