INN commit: trunk (13 files)

INN Commit rra at isc.org
Tue Jul 7 16:31:53 UTC 2015


    Date: Tuesday, July 7, 2015 @ 09:31:52
  Author: iulius
Revision: 9913

Clean build with -Wmissing-format-attribute

Add format attributes on various internal functions and a few
utility functions that take va_arg arguments so that all code
builds cleanly with -Wmissing-format-attribute.

Modified:
  trunk/Makefile.global.in
  trunk/include/inn/buffer.h
  trunk/include/inn/messages.h
  trunk/include/inn/xmalloc.h
  trunk/innfeed/misc.h
  trunk/lib/asprintf.c
  trunk/lib/messages.c
  trunk/nnrpd/nnrpd.c
  trunk/tests/lib/buffer-t.c
  trunk/tests/lib/messages-t.c
  trunk/tests/lib/xmalloc.c
  trunk/tests/tap/messages.c
  trunk/tests/tap/string.h

------------------------+
 Makefile.global.in     |    3 ++-
 include/inn/buffer.h   |    4 ++--
 include/inn/messages.h |   19 ++++++++++---------
 include/inn/xmalloc.h  |    2 +-
 innfeed/misc.h         |    3 ++-
 lib/asprintf.c         |    3 ++-
 lib/messages.c         |    2 +-
 nnrpd/nnrpd.c          |    2 +-
 tests/lib/buffer-t.c   |    4 ++--
 tests/lib/messages-t.c |    5 +++--
 tests/lib/xmalloc.c    |    2 +-
 tests/tap/messages.c   |    4 ++--
 tests/tap/string.h     |    2 +-
 13 files changed, 30 insertions(+), 25 deletions(-)

Modified: Makefile.global.in
===================================================================
--- Makefile.global.in	2015-07-06 22:37:32 UTC (rev 9912)
+++ Makefile.global.in	2015-07-07 16:31:52 UTC (rev 9913)
@@ -93,7 +93,7 @@
 ##  on glibc functions on Linux, as well as more object size checking,
 ##  which catches a few more issues.
 ##  -Wswitch-enum, -Wfloat-equal, -Wlogical-op,
-##  "-Wconversion -Wno-sign-conversion", -Wmissing-format-attribute
+##  "-Wconversion -Wno-sign-conversion",
 ##  -Wunreachable-code, -Wstack-protector, -Wdeclaration-after-statement
 
 WARNINGS	= -g -O2 -DDEBUG=1 -Werror -Wall -Wextra -Wformat=2 \
@@ -103,6 +103,7 @@
 		  -Wjump-misses-init -Wstrict-prototypes \
 		  -Wold-style-definition \
 		  -Wmissing-prototypes -Wmissing-declarations \
+		  -Wmissing-format-attribute \
 		  -Wnormalized=nfc -Wnested-externs -Winline \
 		  -Winvalid-pch -Wvla
 

Modified: include/inn/buffer.h
===================================================================
--- include/inn/buffer.h	2015-07-06 22:37:32 UTC (rev 9912)
+++ include/inn/buffer.h	2015-07-07 16:31:52 UTC (rev 9913)
@@ -95,7 +95,7 @@
 void buffer_sprintf(struct buffer *, const char *, ...)
     __attribute__((__format__(printf, 2, 3), __nonnull__));
 void buffer_vsprintf(struct buffer *, const char *, va_list)
-    __attribute__((__nonnull__));
+    __attribute__((__format__(printf, 2, 0), __nonnull__));
 
 /* Append data to the buffer. */
 void buffer_append(struct buffer *, const char *data, size_t length)
@@ -105,7 +105,7 @@
 void buffer_append_sprintf(struct buffer *, const char *, ...)
     __attribute__((__format__(printf, 2, 3), __nonnull__));
 void buffer_append_vsprintf(struct buffer *, const char *, va_list)
-    __attribute__((__nonnull__));
+    __attribute__((__format__(printf, 2, 0), __nonnull__));
 
 /* Swap the contents of two buffers. */
 void buffer_swap(struct buffer *, struct buffer *)

Modified: include/inn/messages.h
===================================================================
--- include/inn/messages.h	2015-07-06 22:37:32 UTC (rev 9912)
+++ include/inn/messages.h	2015-07-07 16:31:52 UTC (rev 9913)
@@ -82,24 +82,25 @@
  * argument list, and the errno setting if any.
  */
 void message_log_stdout(size_t, const char *, va_list, int)
-    __attribute__((__nonnull__));
+    __attribute__((__format__(printf, 2, 0), __nonnull__));
 void message_log_stderr(size_t, const char *, va_list, int)
-    __attribute__((__nonnull__));
+    __attribute__((__format__(printf, 2, 0), __nonnull__));
 void message_log_syslog_debug(size_t, const char *, va_list, int)
-    __attribute__((__nonnull__));
+    __attribute__((__format__(printf, 2, 0), __nonnull__));
 void message_log_syslog_info(size_t, const char *, va_list, int)
-    __attribute__((__nonnull__));
+    __attribute__((__format__(printf, 2, 0), __nonnull__));
 void message_log_syslog_notice(size_t, const char *, va_list, int)
-    __attribute__((__nonnull__));
+    __attribute__((__format__(printf, 2, 0), __nonnull__));
 void message_log_syslog_warning(size_t, const char *, va_list, int)
-    __attribute__((__nonnull__));
+    __attribute__((__format__(printf, 2, 0), __nonnull__));
 void message_log_syslog_err(size_t, const char *, va_list, int)
-    __attribute__((__nonnull__));
+    __attribute__((__format__(printf, 2, 0), __nonnull__));
 void message_log_syslog_crit(size_t, const char *, va_list, int)
-    __attribute__((__nonnull__));
+    __attribute__((__format__(printf, 2, 0), __nonnull__));
 
 /* The type of a message handler. */
-typedef void (*message_handler_func)(size_t, const char *, va_list, int);
+typedef void (*message_handler_func)(size_t, const char *, va_list, int)
+    __attribute__((__format__(printf, 2, 0)));
 
 /* If non-NULL, called before exit and its return value passed to exit. */
 extern int (*message_fatal_cleanup)(void);

Modified: include/inn/xmalloc.h
===================================================================
--- include/inn/xmalloc.h	2015-07-06 22:37:32 UTC (rev 9912)
+++ include/inn/xmalloc.h	2015-07-07 16:31:52 UTC (rev 9913)
@@ -88,7 +88,7 @@
 char *x_strndup(const char *, size_t, const char *, int)
     __attribute__((__malloc__, __nonnull__));
 void x_vasprintf(char **, const char *, va_list, const char *, int)
-    __attribute__((__nonnull__));
+    __attribute__((__nonnull__, __format__(printf, 2, 0)));
 
 /* asprintf special case. */
 #if INN_HAVE_C99_VAMACROS || INN_HAVE_GNU_VAMACROS

Modified: innfeed/misc.h
===================================================================
--- innfeed/misc.h	2015-07-06 22:37:32 UTC (rev 9912)
+++ innfeed/misc.h	2015-07-07 16:31:52 UTC (rev 9913)
@@ -73,7 +73,8 @@
     __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);
+void error_log_stderr_date(int len, const char *fmt, va_list args, int err)
+    __attribute__((__format__(printf, 2, 0)));
 
 /* Do cleanup and then abort, for use with die. */
 void dump_core(void)

Modified: lib/asprintf.c
===================================================================
--- lib/asprintf.c	2015-07-06 22:37:32 UTC (rev 9912)
+++ lib/asprintf.c	2015-07-07 16:31:52 UTC (rev 9913)
@@ -36,7 +36,8 @@
 # define vasprintf test_vasprintf
 int test_asprintf(char **, const char *, ...)
     __attribute__((__format__(printf, 2, 3)));
-int test_vasprintf(char **, const char *, va_list);
+int test_vasprintf(char **, const char *, va_list)
+    __attribute__((__format__(printf, 2, 0)));
 #endif
 
 

Modified: lib/messages.c
===================================================================
--- lib/messages.c	2015-07-06 22:37:32 UTC (rev 9912)
+++ lib/messages.c	2015-07-07 16:31:52 UTC (rev 9913)
@@ -226,7 +226,7 @@
  * This needs further attention on Windows.  For example, it currently doesn't
  * log the errno information.
  */
-static void
+static void __attribute__((__format__(printf, 3, 0)))
 message_log_syslog(int pri, size_t len, const char *fmt, va_list args, int err)
 {
     char *buffer;

Modified: nnrpd/nnrpd.c
===================================================================
--- nnrpd/nnrpd.c	2015-07-06 22:37:32 UTC (rev 9912)
+++ nnrpd/nnrpd.c	2015-07-07 16:31:52 UTC (rev 9913)
@@ -695,7 +695,7 @@
 /*
 **  Send formatted output, possibly with debugging output.
 */
-static void
+static void __attribute__((__format__(printf, 1, 0)))
 VPrintf(const char *fmt, va_list args, int dotrace)
 {
     char buff[2048], *p;

Modified: tests/lib/buffer-t.c
===================================================================
--- tests/lib/buffer-t.c	2015-07-06 22:37:32 UTC (rev 9912)
+++ tests/lib/buffer-t.c	2015-07-07 16:31:52 UTC (rev 9913)
@@ -35,7 +35,7 @@
 /*
  * Test buffer_vsprintf.  Wrapper needed to generate the va_list.
  */
-static void
+static void __attribute__((__format__(printf, 2, 3)))
 test_vsprintf(struct buffer *buffer, const char *format, ...)
 {
     va_list args;
@@ -49,7 +49,7 @@
 /*
  * Likewise for buffer_append_vsprintf.
  */
-static void
+static void __attribute__((__format__(printf, 2, 3)))
 test_append_vsprintf(struct buffer *buffer, const char *format, ...)
 {
     va_list args;

Modified: tests/lib/messages-t.c
===================================================================
--- tests/lib/messages-t.c	2015-07-06 22:37:32 UTC (rev 9912)
+++ tests/lib/messages-t.c	2015-07-07 16:31:52 UTC (rev 9913)
@@ -6,7 +6,7 @@
  * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle at eyrie.org>
- * Copyright 2002, 2004, 2005 Russ Allbery <eagle at eyrie.org>
+ * Copyright 2002, 2004, 2005, 2015 Russ Allbery <eagle at eyrie.org>
  * Copyright 2009, 2010, 2011, 2012
  *     The Board of Trustees of the Leland Stanford Junior University
  *
@@ -95,7 +95,8 @@
     sysdie("fatal");
 }
 
-static void log_msg(size_t len, const char *format, va_list args, int error) {
+static void __attribute__((__format__(printf, 2, 0)))
+log_msg(size_t len, const char *format, va_list args, int error) {
     fprintf(stderr, "%lu %d ", (unsigned long) len, error);
     vfprintf(stderr, format, args);
     fprintf(stderr, "\n");

Modified: tests/lib/xmalloc.c
===================================================================
--- tests/lib/xmalloc.c	2015-07-06 22:37:32 UTC (rev 9912)
+++ tests/lib/xmalloc.c	2015-07-07 16:31:52 UTC (rev 9913)
@@ -267,7 +267,7 @@
 
 
 /* Wrapper around vasprintf to do the va_list stuff. */
-static void
+static void __attribute__((__format__(printf, 2, 3)))
 xvasprintf_wrapper(char **strp, const char *format, ...)
 {
     va_list args;

Modified: tests/tap/messages.c
===================================================================
--- tests/tap/messages.c	2015-07-06 22:37:32 UTC (rev 9912)
+++ tests/tap/messages.c	2015-07-07 16:31:52 UTC (rev 9913)
@@ -9,7 +9,7 @@
  * The canonical version of this file is maintained in the rra-c-util package,
  * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
- * Copyright 2002, 2004, 2005 Russ Allbery <eagle at eyrie.org>
+ * Copyright 2002, 2004, 2005, 2015 Russ Allbery <eagle at eyrie.org>
  * Copyright 2006, 2007, 2009, 2012, 2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
@@ -48,7 +48,7 @@
  * An error handler that appends all errors to the errors global.  Used by
  * error_capture.
  */
-static void
+static void __attribute__((__format__(printf, 2, 0)))
 message_log_buffer(int len UNUSED, const char *fmt, va_list args,
                    int error UNUSED)
 {

Modified: tests/tap/string.h
===================================================================
--- tests/tap/string.h	2015-07-06 22:37:32 UTC (rev 9912)
+++ tests/tap/string.h	2015-07-07 16:31:52 UTC (rev 9913)
@@ -43,7 +43,7 @@
 void basprintf(char **, const char *, ...)
     __attribute__((__nonnull__, __format__(printf, 2, 3)));
 void bvasprintf(char **, const char *, va_list)
-    __attribute__((__nonnull__));
+    __attribute__((__nonnull__, __format__(printf, 2, 0)));
 
 END_DECLS
 



More information about the inn-committers mailing list