From patchwork Thu Oct 6 00:58:27 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darren Salt X-Patchwork-Id: 12057 Received: from anchor-post-31.mail.demon.net ([194.217.242.89]) by www.linuxtv.org with esmtp (Exim 4.50) id 1ENKC1-00045p-Dt for vdr@linuxtv.org; Thu, 06 Oct 2005 03:05:05 +0200 Received: from youmustbejoking.demon.co.uk ([212.228.127.8] helo=pentagram.youmustbejoking.demon.co.uk) by anchor-post-31.mail.demon.net with esmtp (Exim 4.42) id 1ENK5w-000Cxd-6N for vdr@linuxtv.org; Thu, 06 Oct 2005 00:58:50 +0000 Received: from [192.168.0.2] (helo=riscpc) by pentagram.youmustbejoking.demon.co.uk with esmtp (Exim 4.50) id 1ENKBs-0006cg-AA for vdr@linuxtv.org; Thu, 06 Oct 2005 02:04:56 +0100 Date: Thu, 06 Oct 2005 01:58:27 +0100 From: Darren Salt To: vdr@linuxtv.org Message-ID: <4DB557C84C%linux@youmustbejoking.demon.co.uk> User-Agent: Messenger-Pro/3.30b1 (MsgServe/3.10) (RISC-OS/4.02) POPstar/2.06-ds.5 X-Editor: Zap 1.47 (06 Aug 2005) [TEST], ZapEmail 0.28.3 (25 Mar 2005) (32) X-SDate: Thu, 4419 Sep 1993 01:58:28 +0100 X-Message-Flag: Outlook Express is broken. Upgrade to mail(1). MIME-Version: 1.0 X-SA-Exim-Connect-IP: 192.168.0.2 X-SA-Exim-Mail-From: linux@youmustbejoking.demon.co.uk X-SA-Exim-Scanned: No (on pentagram.youmustbejoking.demon.co.uk); SAEximRunCond expanded to false Subject: [vdr] [PATCH] Mark up a few functions for format string checking X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Oct 2005 01:05:05 -0000 Status: O X-Status: X-Keywords: X-UID: 5352 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... 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);