[PATCH] Mark up a few functions for format string checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The attached patch allows gcc to do some extra checking on the arguments of
certain functions (variadic ones which call vprintf or similar). It hasn't
caught any problems in vdr, but it may help plugin authors...

-- 
| Darren Salt | nr. Ashington, | d youmustbejoking,demon,co,uk
| Debian,     | Northumberland | s zap,tartarus,org
| RISC OS     | Toon Army      | @
|   We've got Souness, we don't want him

That wouldn't be cricket.
-------------- next part --------------
diff -urNad vdr-1.3.34~/svdrp.h vdr-1.3.34/svdrp.h
--- vdr-1.3.34~/svdrp.h	2005-10-05 19:47:23.779606359 +0100
+++ vdr-1.3.34/svdrp.h	2005-10-05 19:52:16.879173995 +0100
@@ -51,7 +51,7 @@
   time_t lastActivity;
   void Close(bool Timeout = false);
   bool Send(const char *s, int length = -1);
-  void Reply(int Code, const char *fmt, ...);
+  void Reply(int Code, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
   void PrintHelpTopics(const char **hp);
   void CmdCHAN(const char *Option);
   void CmdCLRE(const char *Option);
diff -urNad vdr-1.3.34~/thread.h vdr-1.3.34/thread.h
--- vdr-1.3.34~/thread.h	2005-08-14 12:21:48.000000000 +0100
+++ vdr-1.3.34/thread.h	2005-10-05 19:50:39.421967868 +0100
@@ -106,7 +106,7 @@
        ///< the thread starts and stops. The Start() function must be called 
        ///< to actually start the thread.
   virtual ~cThread();
-  void SetDescription(const char *Description, ...);
+  void SetDescription(const char *Description, ...) __attribute__ ((format (printf, 2, 3)));
   bool Start(void);
        ///< Actually starts the thread.
   bool Active(void);
diff -urNad vdr-1.3.34~/tools.h vdr-1.3.34/tools.h
--- vdr-1.3.34~/tools.h	2005-10-01 13:43:31.000000000 +0100
+++ vdr-1.3.34/tools.h	2005-10-05 19:51:24.438829682 +0100
@@ -81,7 +81,7 @@
   operator const char * () const { return s; } // for use in (const char *) context
   const char * operator*() const { return s; } // for use in (const void *) context (printf() etc.)
   cString &operator=(const cString &String);
-  static cString sprintf(const char *fmt, ...);
+  static cString sprintf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
   };
 
 ssize_t safe_read(int filedes, void *buffer, size_t size);

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux