]> mj.ucw.cz Git - pciutils.git/commitdiff
Annotate printf-like functions with format checking attributes.
authorMartin Mares <mj@ucw.cz>
Tue, 12 Feb 2008 09:29:48 +0000 (10:29 +0100)
committerMartin Mares <mj@ucw.cz>
Tue, 12 Feb 2008 09:29:48 +0000 (10:29 +0100)
lib/pci.h
lib/types.h
pciutils.h
setpci.c

index d2c9ab61f33e79199a0169807164dad61944d130..1f1c7ef7099fa3955fbfb1ddfe3e1ec20b1c12a7 100644 (file)
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -52,9 +52,9 @@ struct pci_access {
   int debugging;                       /* Turn on debugging messages */
 
   /* Functions you can override: */
-  void (*error)(char *msg, ...);       /* Write error message and quit */
-  void (*warning)(char *msg, ...);     /* Write a warning message */
-  void (*debug)(char *msg, ...);       /* Write a debugging message */
+  void (*error)(char *msg, ...) PCI_PRINTF(1,2);       /* Write error message and quit */
+  void (*warning)(char *msg, ...) PCI_PRINTF(1,2);     /* Write a warning message */
+  void (*debug)(char *msg, ...) PCI_PRINTF(1,2);       /* Write a debugging message */
 
   struct pci_dev *devices;             /* Devices found on this bus */
 
index f7ab470c86b034528410c05f889b4fa1feb4b6eb..3405bb91317ae96f44674bfe207f46ec378dc3cb 100644 (file)
@@ -57,3 +57,9 @@ typedef u32 pciaddr_t;
 #else
 #define PCIIRQ_FMT "%d"
 #endif
+
+#ifdef __GNUC__
+#define PCI_PRINTF(x,y) __attribute__((format(printf, x, y)))
+#else
+#define PCI_PRINTF(x,y)
+#endif
index 940810200f86b6b93ec57a4dc4aae15e889ce5ac..a1d18904bbf5492ab59910fe677019273ffd1ff4 100644 (file)
@@ -17,7 +17,7 @@
 
 extern const char program_name[];
 
-void die(char *msg, ...) NONRET;
+void die(char *msg, ...) NONRET PCI_PRINTF(1,2);
 void *xmalloc(unsigned int howmuch);
 void *xrealloc(void *ptr, unsigned int howmuch);
 int parse_generic_option(int i, struct pci_access *pacc, char *optarg);
index fc10c1de8459c72c59b1c4e07b83079890139a36..7ed0ac6c46b82a3ab0f11d37477ab48ab6a3d41b 100644 (file)
--- a/setpci.c
+++ b/setpci.c
@@ -246,7 +246,7 @@ static const struct reg_name pci_reg_names[] = {
   { 0x00, 0, NULL }
 };
 
-static void NONRET
+static void NONRET PCI_PRINTF(1,2)
 usage(char *msg, ...)
 {
   va_list args;