From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8499 Path: news.gmane.org!not-for-mail From: Khem Raj Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] libintl.h: Add format argument attributes to gettext function prototypes Date: Sun, 13 Sep 2015 06:29:04 +0000 Message-ID: <1442125744-27934-1-git-send-email-raj.khem@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1442125771 8577 80.91.229.3 (13 Sep 2015 06:29:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 13 Sep 2015 06:29:31 +0000 (UTC) Cc: Khem Raj To: musl@lists.openwall.com Original-X-From: musl-return-8511-gllmg-musl=m.gmane.org@lists.openwall.com Sun Sep 13 08:29:30 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Zb0n4-0003un-3B for gllmg-musl@m.gmane.org; Sun, 13 Sep 2015 08:29:30 +0200 Original-Received: (qmail 16333 invoked by uid 550); 13 Sep 2015 06:29:27 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 16276 invoked from network); 13 Sep 2015 06:29:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=WLR2L5QBoVZ6EVhTrZEfNz3E8veASBzTeZYU3RSB2Qg=; b=hzADLmTTyqHLR56rrmnrUv3+gD42LivNza8dA2y+2czlLfxLDZpwxdsQ1SFwDZxtX3 QyY3DSUWXe/+iwRUSMTs5MkiBuMAA2JG/6UnUpg0vxn4yNHW06KPgmxyd0Yl0SRX+tPv WpGMDcbznH+W7vUb0KKeMH3qynnAQ3+30FO21vw9h1vb7LtpQzmnie+dQD/70pnOJTHs 9kreDj4D+TyVNTljAWKM2EtOTxuU+BwctLiYQvLKz3p4SxYMimN+bOwHsdVHrsKS6Ucv qlPwCvAV5gmDQppHtImLvraqDB+87NrmsP6pYEUzXgARHq7bc+evzcXjQ5o2JBqpCvX8 JXpw== X-Received: by 10.140.22.139 with SMTP id 11mr11804657qgn.23.1442125751459; Sat, 12 Sep 2015 23:29:11 -0700 (PDT) X-Mailer: git-send-email 2.5.2 Xref: news.gmane.org gmane.linux.lib.musl.general:8499 Archived-At: compiling glib-2.0 clang errors out with error: format string is not a string literal when these functions are used, it can be enforced that the format arguments to these gettext* functions be string literals, so that the compiler knows that it always will be string literals Signed-off-by: Khem Raj --- include/libintl.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/include/libintl.h b/include/libintl.h index a2dada6..6a707bf 100644 --- a/include/libintl.h +++ b/include/libintl.h @@ -8,16 +8,24 @@ extern "C" { #define __USE_GNU_GETTEXT 1 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 1 : -1) -char *gettext(const char *); -char *dgettext(const char *, const char *); -char *dcgettext(const char *, const char *, int); -char *ngettext(const char *, const char *, unsigned long); -char *dngettext(const char *, const char *, const char *, unsigned long); -char *dcngettext(const char *, const char *, const char *, unsigned long, int); +#if __GNUC__ >= 3 +#define __fa(n) __attribute__ ((__format_arg__ (n))) +#else +#define __fa(n) +#endif + +char *gettext(const char *) __fa(1); +char *dgettext(const char *, const char *) __fa(2); +char *dcgettext(const char *, const char *, int) __fa(2); +char *ngettext(const char *, const char *, unsigned long) __fa(1) __fa(2); +char *dngettext(const char *, const char *, const char *, unsigned long) __fa(2) __fa(3); +char *dcngettext(const char *, const char *, const char *, unsigned long, int) __fa(2) __fa(3); char *textdomain(const char *); char *bindtextdomain (const char *, const char *); char *bind_textdomain_codeset(const char *, const char *); +#undef __fa + #ifdef __cplusplus } #endif -- 2.5.2