chiark / gitweb /
turn on a bunch of warnings
[innduct.git] / innduct.c
index 445157da1527c16fe557d2da91b97ae65cf78ae6..5755855978910d14c31634706be020057b3e2a25 100644 (file)
--- 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(done<conn->xmitu);
       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; i<gl.gl_pathc; i++) {
-      const char *path= gl.gl_pathv[i];
+    for (ui=0; ui<gl.gl_pathc; ui++) {
+      const char *path= gl.gl_pathv[ui];
 
       if (strchr(path,'#') || strchr(path,'~')) {
        dbg("backlog file search skipping %s", path);
@@ -3003,7 +3010,7 @@ static void search_backlog_file(void) {
       preterminate();
       notice("feed dropped and our work is complete");
 
-      int r= unlink(path_cli);
+      r= unlink(path_cli);
       if (r && errno!=ENOENT)
        syswarn("failed to unlink cli socket for old feed");
 
@@ -3551,7 +3558,7 @@ static void parse_options(const Option *options, char ***argvp) {
       if (a=='-') {
        arg++;
        char *equals= strchr(arg,'=');
-       int len= equals ? (equals - arg) : strlen(arg);
+       unsigned len= equals ? (size_t)(equals - arg) : strlen(arg);
        for (o=options; o->shrt || 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);