[PATCH 04/18] Ignore a couple of format-nonliteral warnings

Keith Packard keithp at keithp.com
Mon Jan 13 10:17:44 PST 2014


These are generated in code which uses sprintf as a convenient way to
construct strings from various pieces.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 hw/xfree86/os-support/linux/lnx_init.c | 1 +
 os/log.c                               | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index e2e8d08..46438e6 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -155,6 +155,7 @@ xf86OpenConsole(void)
 
         i = 0;
         while (vcs[i] != NULL) {
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
             snprintf(vtname, sizeof(vtname), vcs[i], xf86Info.vtno);    /* /dev/tty1-64 */
             if ((xf86Info.consoleFd = open(vtname, O_RDWR | O_NDELAY, 0)) >= 0)
                 break;
diff --git a/os/log.c b/os/log.c
index 792b79e..8deb810 100644
--- a/os/log.c
+++ b/os/log.c
@@ -195,6 +195,7 @@ LogInit(const char *fname, const char *backup)
     char *logFileName = NULL;
 
     if (fname && *fname) {
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
         if (asprintf(&logFileName, fname, display) == -1)
             FatalError("Cannot allocate space for the log file name\n");
 
@@ -205,6 +206,7 @@ LogInit(const char *fname, const char *backup)
                 char *suffix;
                 char *oldLog;
 
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
                 if ((asprintf(&suffix, backup, display) == -1) ||
                     (asprintf(&oldLog, "%s%s", logFileName, suffix) == -1))
                     FatalError("Cannot allocate space for the log file name\n");
-- 
1.8.5.2



More information about the xorg-devel mailing list