]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: printf bugfixes & improvement
authorQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 30 Jun 2017 16:18:20 +0000 (16:18 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 30 Jun 2017 16:18:20 +0000 (16:18 +0000)
* Fix bad format specifier in thread.[ch]
* Move PRINTF_ATTRIBUTE macro to zebra.h
* Use PRINTF_ATTRIBUTE on termtable printers

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/termtable.h
lib/thread.c
lib/vty.h
lib/zebra.h

index 6953002e9009272ede96fd9772536d32c863a39e..9ecb41659e340e4edc9b1d24e06676a1f05a4081 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef _TERMTABLE_H_
 #define _TERMTABLE_H_
 
+#include <zebra.h>
+
 enum ttable_align {
        LEFT,
        RIGHT,
@@ -131,7 +133,8 @@ void ttable_cell_del(struct ttable_cell *cell);
  * columns were specified
  */
 struct ttable_cell *ttable_insert_row(struct ttable *tt, unsigned int row,
-                                     const char *format, ...);
+                                     const char *format, ...)
+                                     PRINTF_ATTRIBUTE(3, 4);
 /**
  * Inserts a new row at the end of the table.
  *
@@ -156,7 +159,8 @@ struct ttable_cell *ttable_insert_row(struct ttable *tt, unsigned int row,
  * @return pointer to the first cell in the created row, or NULL if not enough
  * columns were specified
  */
-struct ttable_cell *ttable_add_row(struct ttable *tt, const char *format, ...);
+struct ttable_cell *ttable_add_row(struct ttable *tt, const char *format, ...)
+                                  PRINTF_ATTRIBUTE(2, 3);
 
 /**
  * Removes a row from the table.
index 801168a79944ef448247ebc3a5af24f13aa1775d..71b0bb2aed4dc69f4cf7dcd2a551e37bf934e6b9 100644 (file)
@@ -271,7 +271,7 @@ DEFUN (show_thread_cpu,
     filter = parse_filter (argv[idx]->arg);
     if (!filter) {
       vty_outln(vty, "Invalid filter \"%s\" specified; must contain at least"
-                     "one of 'RWTEXB'%s", argv[idx]->arg);
+                     "one of 'RWTEXB'", argv[idx]->arg);
       return CMD_WARNING;
     }
   }
@@ -295,7 +295,7 @@ DEFUN (clear_thread_cpu,
     filter = parse_filter (argv[idx]->arg);
     if (!filter) {
       vty_outln(vty, "Invalid filter \"%s\" specified; must contain at least"
-                     "one of 'RWTEXB'%s", argv[idx]->arg);
+                     "one of 'RWTEXB'", argv[idx]->arg);
       return CMD_WARNING;
     }
   }
index 6ef11ab98c3623f6c5e70266b310b4c5246c2b44..a76b9f5a17ea9771f4a5e2d5c3e07f200a7afabe 100644 (file)
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -197,13 +197,6 @@ struct vty_arg
 #define IS_DIRECTORY_SEP(c) ((c) == DIRECTORY_SEP)
 #endif
 
-/* GCC have printf type attribute check.  */
-#ifdef __GNUC__
-#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
-#else
-#define PRINTF_ATTRIBUTE(a,b)
-#endif /* __GNUC__ */
-
 /* Exported variables */
 extern char integrate_default[];
 
index 2cc433a863fe16cd8712b95656a04446db870f94..901a49073dbd550917c7932dac37f0e01c64c945 100644 (file)
@@ -247,6 +247,12 @@ size_t strlcpy (char *__restrict dest, const char *__restrict src, size_t size);
 #endif /* HAVE_BROKEN_CMSG_FIRSTHDR */
 
 
+/* GCC have printf type attribute check.  */
+#ifdef __GNUC__
+#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
+#else
+#define PRINTF_ATTRIBUTE(a,b)
+#endif /* __GNUC__ */
 
 /* 
  * RFC 3542 defines several macros for using struct cmsghdr.