INN commit: branches/2.5 (17 files)

INN Commit rra at isc.org
Thu Dec 3 21:11:00 UTC 2009


    Date: Thursday, December 3, 2009 @ 13:11:00
  Author: iulius
Revision: 8838

Improve gcc warnings on printf-like function calls.

Modified:
  branches/2.5/include/clibrary.h
  branches/2.5/include/inn/buffer.h
  branches/2.5/include/inn/confparse.h
  branches/2.5/include/inn/libinn.h
  branches/2.5/include/inn/nntp.h
  branches/2.5/include/portable/setproctitle.h
  branches/2.5/innd/tinyleaf.c
  branches/2.5/innfeed/misc.h
  branches/2.5/lib/asprintf.c
  branches/2.5/lib/snprintf.c
  branches/2.5/nnrpd/article.c
  branches/2.5/nnrpd/commands.c
  branches/2.5/nnrpd/nnrpd.h
  branches/2.5/storage/cnfs/cnfs.c
  branches/2.5/storage/timecaf/timecaf.c
  branches/2.5/storage/timehash/timehash.c
  branches/2.5/storage/tradspool/tradspool.c

---------------------------------+
 include/clibrary.h              |    3 ++-
 include/inn/buffer.h            |    3 ++-
 include/inn/confparse.h         |    6 ++++--
 include/inn/libinn.h            |    6 ++++--
 include/inn/nntp.h              |   12 ++++++++----
 include/portable/setproctitle.h |    3 ++-
 innd/tinyleaf.c                 |    2 +-
 innfeed/misc.h                  |    7 ++++---
 lib/asprintf.c                  |    3 ++-
 lib/snprintf.c                  |    5 +++--
 nnrpd/article.c                 |   16 ++++++++--------
 nnrpd/commands.c                |    2 +-
 nnrpd/nnrpd.h                   |    6 ++++--
 storage/cnfs/cnfs.c             |    4 ++--
 storage/timecaf/timecaf.c       |    4 ++--
 storage/timehash/timehash.c     |    2 +-
 storage/tradspool/tradspool.c   |    4 ++--
 17 files changed, 52 insertions(+), 36 deletions(-)

Modified: include/clibrary.h
===================================================================
--- include/clibrary.h	2009-12-03 21:08:59 UTC (rev 8837)
+++ include/clibrary.h	2009-12-03 21:11:00 UTC (rev 8838)
@@ -110,7 +110,8 @@
    HAVE_DECL macros for those functions that may be prototyped but
    implemented incorrectly or implemented without a prototype. */
 #if !HAVE_ASPRINTF
-extern int              asprintf(char **, const char *, ...);
+extern int              asprintf(char **, const char *, ...)
+    __attribute__((__format__(printf, 2, 3)));
 extern int              vasprintf(char **, const char *, va_list);
 #endif
 #if !HAVE_MKSTEMP

Modified: include/inn/buffer.h
===================================================================
--- include/inn/buffer.h	2009-12-03 21:08:59 UTC (rev 8837)
+++ include/inn/buffer.h	2009-12-03 21:11:00 UTC (rev 8838)
@@ -52,7 +52,8 @@
 
 /* Print data into the buffer, either appending or replacing the existing
    data.  No trailing nul is added. */
-void buffer_sprintf(struct buffer *, bool append, const char *, ...);
+void buffer_sprintf(struct buffer *, bool append, const char *, ...)
+    __attribute__((__format__(printf, 3, 4)));
 void buffer_vsprintf(struct buffer *, bool append, const char *, va_list);
 
 /* Swap the contents of two buffers. */

Modified: include/inn/confparse.h
===================================================================
--- include/inn/confparse.h	2009-12-03 21:08:59 UTC (rev 8837)
+++ include/inn/confparse.h	2009-12-03 21:11:00 UTC (rev 8838)
@@ -65,9 +65,11 @@
    error at a particular parameter in a config_group and config_error_group
    reports an error at the definition of that group.  The error is reported
    using warn. */
-void config_error_group(struct config_group *, const char *format, ...);
+void config_error_group(struct config_group *, const char *format, ...)
+    __attribute__((__format__(printf, 2, 3)));
 void config_error_param(struct config_group *, const char *key,
-                        const char *format, ...);
+                        const char *format, ...)
+    __attribute__((__format__(printf, 3, 4)));
 
 /* Free all space allocated by the tree rooted at config_group.  One normally
    never wants to do this.  WARNING: This includes the storage allocated for

Modified: include/inn/libinn.h
===================================================================
--- include/inn/libinn.h	2009-12-03 21:08:59 UTC (rev 8837)
+++ include/inn/libinn.h	2009-12-03 21:11:00 UTC (rev 8838)
@@ -73,9 +73,11 @@
 
 /* asprintf special case. */
 #if INN_HAVE_C99_VAMACROS || INN_HAVE_GNU_VAMACROS
-extern int x_asprintf(char **, const char *, int, const char *, ...);
+extern int x_asprintf(char **, const char *, int, const char *, ...)
+    __attribute__((__format__(printf, 4, 5)));
 #else
-extern int x_asprintf(char **, const char *, ...);
+extern int x_asprintf(char **, const char *, ...)
+    __attribute__((__format__(printf, 2, 3)));
 #endif
 
 /* Failure handler takes the function, the size, the file, and the line. */

Modified: include/inn/nntp.h
===================================================================
--- include/inn/nntp.h	2009-12-03 21:08:59 UTC (rev 8837)
+++ include/inn/nntp.h	2009-12-03 21:11:00 UTC (rev 8838)
@@ -227,15 +227,19 @@
 
 /* Send a line to the remote connection.  The output is flushed after sending
    the line unless the noflush variant is used. */
-bool nntp_send_line(struct nntp *, const char *format, ...);
-bool nntp_send_line_noflush(struct nntp *, const char *format, ...);
+bool nntp_send_line(struct nntp *, const char *format, ...)
+    __attribute__((__format__(printf, 2, 3)));
+bool nntp_send_line_noflush(struct nntp *, const char *format, ...)
+    __attribute__((__format__(printf, 2, 3)));
 
 /* Send a response to an NNTP command or an opening banner.  The string may be
    NULL to indicate nothing should follow the response code; otherwise, it is
    a printf-style format.  The noflush variant doesn't flush the output after
    sending it, used for introducing multiline responses. */
-bool nntp_respond(struct nntp *, enum nntp_code, const char *, ...);
-void nntp_respond_noflush(struct nntp *, enum nntp_code, const char *, ...);
+bool nntp_respond(struct nntp *, enum nntp_code, const char *, ...)
+    __attribute__((__format__(printf, 3, 4)));
+void nntp_respond_noflush(struct nntp *, enum nntp_code, const char *, ...)
+    __attribute__((__format__(printf, 3, 4)));
 
 /* Flush NNTP output, returning true on success and false on any error. */
 bool nntp_flush(struct nntp *);

Modified: include/portable/setproctitle.h
===================================================================
--- include/portable/setproctitle.h	2009-12-03 21:08:59 UTC (rev 8837)
+++ include/portable/setproctitle.h	2009-12-03 21:11:00 UTC (rev 8838)
@@ -13,7 +13,8 @@
 #include "config.h"
 
 #if !HAVE_SETPROCTITLE || !HAVE_DECL_SETPROCTITLE
-void setproctitle(const char *format, ...);
+void setproctitle(const char *format, ...)
+    __attribute__((__format__(printf, 1, 2)));
 #endif
 
 #if HAVE_SETPROCTITLE || HAVE_PSTAT

Modified: innd/tinyleaf.c
===================================================================
--- innd/tinyleaf.c	2009-12-03 21:08:59 UTC (rev 8837)
+++ innd/tinyleaf.c	2009-12-03 21:11:00 UTC (rev 8838)
@@ -172,7 +172,7 @@
     nntp_respond_noflush(state->nntp, NNTP_INFO_HELP, "tinyfeed from %s",
                          INN_VERSION_STRING);
     nntp_send_line_noflush(state->nntp, "Supported commands:");
-    nntp_send_line_noflush(state->nntp, "");
+    nntp_send_line_noflush(state->nntp, " ");
     nntp_send_line_noflush(state->nntp, "  IHAVE <message-id>");
     nntp_send_line_noflush(state->nntp, "  HELP");
     nntp_send_line_noflush(state->nntp, "  QUIT");

Modified: innfeed/misc.h
===================================================================
--- innfeed/misc.h	2009-12-03 21:08:59 UTC (rev 8837)
+++ innfeed/misc.h	2009-12-03 21:11:00 UTC (rev 8838)
@@ -49,7 +49,8 @@
 extern unsigned int openfds ;
 
 /* if level <= loggingLevel then print */
-void d_printf (unsigned int level, const char *fmt, ...) __attribute__ ((__format__ (printf, 2, 3)));
+void d_printf (unsigned int level, const char *fmt, ...)
+    __attribute__((__format__ (printf, 2, 3)));
 
 /* for the gethostbyname() error code */
 const char *host_err_str (void) ;
@@ -68,7 +69,7 @@
 
 /* if fp is not NULL then print to it, otherwise syslog at the level. */
 void logOrPrint (int level, FILE *fp, const char *fmt, ...)
-  __attribute__ ((__format__ (printf, 3, 4)));
+    __attribute__((__format__(printf, 3, 4)));
 
 /* Error handling functions for use with warn and die. */
 void error_log_stderr_date(int len, const char *fmt, va_list args, int err);
@@ -78,7 +79,7 @@
 
 /* Alternate die that doesn't invoke an error handler. */
 void logAndExit (int exitVal, const char *fmt, ...)
-  __attribute__ ((__format__ (printf, 2, 3)));
+    __attribute__((__format__(printf, 2, 3)));
 
 /* return true of the file exists and is a regular file */
 bool fileExistsP (const char *filename) ;

Modified: lib/asprintf.c
===================================================================
--- lib/asprintf.c	2009-12-03 21:08:59 UTC (rev 8837)
+++ lib/asprintf.c	2009-12-03 21:11:00 UTC (rev 8838)
@@ -17,7 +17,8 @@
 #if TESTING
 # define asprintf test_asprintf
 # define vasprintf test_vasprintf
-int test_asprintf(char **, const char *, ...);
+int test_asprintf(char **, const char *, ...)
+    __attribute__((__format__(printf, 2, 3)));
 int test_vasprintf(char **, const char *, va_list);
 #endif
 

Modified: lib/snprintf.c
===================================================================
--- lib/snprintf.c	2009-12-03 21:08:59 UTC (rev 8837)
+++ lib/snprintf.c	2009-12-03 21:11:00 UTC (rev 8838)
@@ -119,7 +119,8 @@
 # define LLONG long
 #endif
 
-int snprintf (char *str, size_t count, const char *fmt, ...);
+int snprintf (char *str, size_t count, const char *fmt, ...)
+    __attribute__((__format__(printf, 3, 4)));
 int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
 
 static int dopr (char *buffer, size_t maxlen, const char *format, 
@@ -844,7 +845,7 @@
 
 /* VARARGS3 */
 #ifdef HAVE_STDARGS
-int snprintf (char *str,size_t count,const char *fmt,...)
+int snprintf (char *str, size_t count, const char *fmt, ...)
 #else
 int snprintf (va_alist) va_dcl
 #endif

Modified: nnrpd/article.c
===================================================================
--- nnrpd/article.c	2009-12-03 21:08:59 UTC (rev 8837)
+++ nnrpd/article.c	2009-12-03 21:11:00 UTC (rev 8838)
@@ -772,7 +772,7 @@
         ARTclose();
     } while (msgid == NULL);
 
-    Reply("%d %d %s Article retrieved; request text separately\r\n",
+    Reply("%d %lu %s Article retrieved; request text separately\r\n",
 	   NNTP_OK_STAT, ARTnumber, msgid);
 }
 
@@ -955,7 +955,7 @@
             Reply("%d No articles in %s\r\n",
                   xover ? NNTP_OK_OVER : NNTP_FAIL_BAD_ARTICLE, av[1]);
         else
-            Reply("%d Current article number %d is invalid\r\n",
+            Reply("%d Current article number %lu is invalid\r\n",
                   xover ? NNTP_OK_OVER : NNTP_FAIL_NO_ARTICLE, ARTnumber);
         if (xover)
             Printf(".\r\n");
@@ -999,7 +999,7 @@
                 Reply("%d Overview information for %s follows\r\n",
                       NNTP_OK_OVER, av[1]);
             else
-                Reply("%d Overview information for %d follows\r\n",
+                Reply("%d Overview information for %lu follows\r\n",
                       NNTP_OK_OVER, ARTnumber);
             fflush(stdout);
             HasNotReplied = false;
@@ -1067,7 +1067,7 @@
             Reply("%d No articles in %s\r\n",
                   xover ? NNTP_OK_OVER : NNTP_FAIL_BAD_ARTICLE, av[1]);
         else
-            Reply("%d Current article number %d is invalid\r\n",
+            Reply("%d Current article number %lu is invalid\r\n",
                   xover ? NNTP_OK_OVER : NNTP_FAIL_NO_ARTICLE, ARTnumber);
         if (xover)
             Printf(".\r\n");
@@ -1156,7 +1156,7 @@
         p++;
         if (strncasecmp(header, ":", 1) == 0 && IsValidHeaderName(p)) {
             Reply("%d Unsupported metadata request\r\n",
-                  NNTP_ERR_UNAVAILABLE, header);
+                  NNTP_ERR_UNAVAILABLE);
             return;
         } else if (!IsValidHeaderName(header)) {
             Reply("%d Syntax error in header name\r\n", NNTP_ERR_SYNTAX);
@@ -1263,7 +1263,7 @@
                         Reply("%d No articles in %s\r\n",
                               NNTP_FAIL_BAD_ARTICLE, av[2]);
                     else
-                        Reply("%d Current article number %d is invalid\r\n",
+                        Reply("%d Current article number %lu is invalid\r\n",
                               NNTP_FAIL_NO_ARTICLE, ARTnumber);
                 } else {
                     Reply("%d No header information for %s follows (from articles)\r\n",
@@ -1286,7 +1286,7 @@
                     Reply("%d No articles in %s\r\n",
                           NNTP_FAIL_BAD_ARTICLE, av[2]);
                 else
-                    Reply("%d Current article number %d is invalid\r\n",
+                    Reply("%d Current article number %lu is invalid\r\n",
                           NNTP_FAIL_NO_ARTICLE, ARTnumber);
             } else {
                 Reply("%d No header information for %s follows (from overview)\r\n",
@@ -1343,7 +1343,7 @@
                     Reply("%d No articles in %s\r\n",
                           NNTP_FAIL_BAD_ARTICLE, av[2]);
                 else
-                    Reply("%d Current article number %d is invalid\r\n",
+                    Reply("%d Current article number %lu is invalid\r\n",
                           NNTP_FAIL_NO_ARTICLE, ARTnumber);
             } else {
                 Reply("%d No header or metadata information for %s follows (from overview)\r\n",

Modified: nnrpd/commands.c
===================================================================
--- nnrpd/commands.c	2009-12-03 21:08:59 UTC (rev 8837)
+++ nnrpd/commands.c	2009-12-03 21:11:00 UTC (rev 8838)
@@ -413,7 +413,7 @@
         Reply("%d Can't get time, %s\r\n", NNTP_FAIL_ACTION, strerror(errno));
         return;
     }
-    Reply("%d %04.4d%02.2d%02.2d%02.2d%02.2d%02.2d\r\n",
+    Reply("%d %04d%02d%02d%02d%02d%02d\r\n",
           NNTP_INFO_DATE,
           gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday,
           gmt->tm_hour, gmt->tm_min, gmt->tm_sec);

Modified: nnrpd/nnrpd.h
===================================================================
--- nnrpd/nnrpd.h	2009-12-03 21:08:59 UTC (rev 8837)
+++ nnrpd/nnrpd.h	2009-12-03 21:11:00 UTC (rev 8838)
@@ -229,8 +229,10 @@
 extern bool		PERMmatch(char **Pats, char **list);
 extern bool		ParseDistlist(char ***argvp, char *list);
 extern void 		SetDefaultAccess(ACCESSGROUP*);
-extern void		Reply(const char *fmt, ...);
-extern void             Printf(const char *fmt, ...);
+extern void		Reply(const char *fmt, ...)
+    __attribute__((__format__(printf, 1, 2)));
+extern void             Printf(const char *fmt, ...)
+    __attribute__((__format__(printf, 1, 2)));
 
 extern void             CMDauthinfo     (int ac, char** av);
 extern void             CMDcapabilities (int ac, char** av);

Modified: storage/cnfs/cnfs.c
===================================================================
--- storage/cnfs/cnfs.c	2009-12-03 21:08:59 UTC (rev 8837)
+++ storage/cnfs/cnfs.c	2009-12-03 21:11:00 UTC (rev 8838)
@@ -93,8 +93,8 @@
     memcpy(&block, &token.token[8], sizeof(block));
     memcpy(&cycnum, &token.token[12], sizeof(cycnum));
     xasprintf(&text, "method=cnfs class=%u buffer=%s block=%lu blocksize=%u cycnum=%lu file=%s",
-              (unsigned int) token.class, cycbuffname, ntohl(block), blksz, ntohl(cycnum),
-              cycbuff ? cycbuff->path : "");
+              (unsigned int) token.class, cycbuffname, (unsigned long) ntohl(block),
+              blksz, (unsigned long) ntohl(cycnum), cycbuff ? cycbuff->path : "");
 
     return text;
 }

Modified: storage/timecaf/timecaf.c
===================================================================
--- storage/timecaf/timecaf.c	2009-12-03 21:08:59 UTC (rev 8837)
+++ storage/timecaf/timecaf.c	2009-12-03 21:11:00 UTC (rev 8838)
@@ -121,8 +121,8 @@
     memcpy(&seqnum2, &token.token[6], sizeof(seqnum2));
  
     xasprintf(&text, "method=timecaf class=%u time=%lu seqnum=%lu file=%s/timecaf-%02x/%02x/%02x%02x.CF",
-              (unsigned int) token.class, ntohl(arrival) << 8,
-              ntohs(seqnum1) + (ntohs(seqnum2) << 16),
+              (unsigned int) token.class, ((unsigned long) (ntohl(arrival))) << 8,
+              ((unsigned long) ntohs(seqnum1)) + (((unsigned long) ntohs(seqnum2)) << 16),
               innconf->patharticles, token.class,
               (ntohl(arrival) >> 8) & 0xff,
               (ntohl(arrival) >> 16) & 0xff,

Modified: storage/timehash/timehash.c
===================================================================
--- storage/timehash/timehash.c	2009-12-03 21:08:59 UTC (rev 8837)
+++ storage/timehash/timehash.c	2009-12-03 21:11:00 UTC (rev 8838)
@@ -61,7 +61,7 @@
     memcpy(&seqnum, &token.token[4], sizeof(seqnum));
 
     xasprintf(&text, "method=timehash class=%u time=%lu seqnum=%lu file=%s/time-%02x/%02x/%02x/%04x-%02x%02x",
-              (unsigned int) token.class, ntohl(arrival), ntohs(seqnum),
+              (unsigned int) token.class, (unsigned long) ntohl(arrival), (unsigned long) ntohs(seqnum),
               innconf->patharticles, token.class, (ntohl(arrival) >> 16) & 0xff,
               (ntohl(arrival) >> 8) & 0xff, ntohs(seqnum),
               (ntohl(arrival) >> 24) & 0xff, ntohl(arrival) & 0xff);

Modified: storage/tradspool/tradspool.c
===================================================================
--- storage/tradspool/tradspool.c	2009-12-03 21:08:59 UTC (rev 8837)
+++ storage/tradspool/tradspool.c	2009-12-03 21:11:00 UTC (rev 8838)
@@ -491,8 +491,8 @@
     path = TokenToPath(token);
 
     xasprintf(&text, "method=tradspool class=%u ngnum=%lu artnum=%lu file=%s",
-              (unsigned int) token.class, ntohl(ngnum), ntohl(artnum),
-              path != NULL ? path : "");
+              (unsigned int) token.class, (unsigned long) ntohl(ngnum),
+              (unsigned long) ntohl(artnum), path != NULL ? path : "");
 
     if (path != NULL)
         free(path);




More information about the inn-committers mailing list