From a271e3d93c37c90e2109a8cfcdaa845a7fe34e41 Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Fri, 30 May 2008 17:35:53 -0400 Subject: [PATCH] add -Wformat and -Wformat-security warnings and fix up some code I'm still baffled why gcc thinks this is something one needs to *turn* on. --- configure.in | 10 ++++++++++ src/devkit-disks-daemon.c | 2 +- src/devkit-disks-device.c | 2 +- src/devkit-disks-logger.c | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index dec5c59..a0e550d 100644 --- a/configure.in +++ b/configure.in @@ -73,6 +73,16 @@ if test "x$GCC" = "xyes"; then *) CFLAGS="$CFLAGS -Wsign-compare" ;; esac + case " $CFLAGS " in + *[\ \ ]-Wformat[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wformat" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-Wformat-security[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wformat-security" ;; + esac + if test "x$enable_ansi" = "xyes"; then case " $CFLAGS " in *[\ \ ]-ansi[\ \ ]*) ;; diff --git a/src/devkit-disks-daemon.c b/src/devkit-disks-daemon.c index 03e89ea..6042c72 100644 --- a/src/devkit-disks-daemon.c +++ b/src/devkit-disks-daemon.c @@ -914,7 +914,7 @@ throw_error (DBusGMethodInvocation *context, int error_code, const char *format, error = g_error_new (DEVKIT_DISKS_DAEMON_ERROR, error_code, - message); + "%s", message); dbus_g_method_return_error (context, error); g_error_free (error); g_free (message); diff --git a/src/devkit-disks-device.c b/src/devkit-disks-device.c index 4e456b0..5ae347f 100644 --- a/src/devkit-disks-device.c +++ b/src/devkit-disks-device.c @@ -2355,7 +2355,7 @@ throw_error (DBusGMethodInvocation *context, int error_code, const char *format, error = g_error_new (DEVKIT_DISKS_DEVICE_ERROR, error_code, - message); + "%s", message); dbus_g_method_return_error (context, error); g_error_free (error); g_free (message); diff --git a/src/devkit-disks-logger.c b/src/devkit-disks-logger.c index 148a431..86a74fc 100644 --- a/src/devkit-disks-logger.c +++ b/src/devkit-disks-logger.c @@ -275,7 +275,7 @@ throw_error (DBusGMethodInvocation *context, int error_code, const char *format, error = g_error_new (DEVKIT_DISKS_DEVICE_ERROR, error_code, - message); + "%s", message); dbus_g_method_return_error (context, error); g_error_free (error); g_free (message); -- 2.7.4