summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2014-02-21 10:20:14 -0500
committerAnthony G. Basile <blueness@gentoo.org>2014-02-21 10:20:31 -0500
commit306c786fdcca7e75268ed9903367b0fd32db5502 (patch)
tree33cf9c5e2c8d28edeed8436f2737f77fa67e7eec /src
parent4e8d48be86ced6c8f8a85cccd63f494d5bcc0fb2 (diff)
macro: introduce a nice macro for disabling -Wformat-nonliteral temporarily
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r--src/libudev/log.c5
-rw-r--r--src/libudev/macro.h5
-rw-r--r--src/udev/udev-builtin-input_id.c8
3 files changed, 11 insertions, 7 deletions
diff --git a/src/libudev/log.c b/src/libudev/log.c
index 75157083c6..73bba69853 100644
--- a/src/libudev/log.c
+++ b/src/libudev/log.c
@@ -531,22 +531,21 @@ int log_meta(
return r;
}
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
static void log_assert(int level, const char *text, const char *file, int line, const char *func, const char *format) {
static char buffer[LINE_MAX];
if (_likely_(LOG_PRI(level) > log_max_level))
return;
+ DISABLE_WARNING_FORMAT_NONLITERAL;
snprintf(buffer, sizeof(buffer), format, text, file, line, func);
+ REENABLE_WARNING;
char_array_0(buffer);
log_abort_msg = buffer;
log_dispatch(level, file, line, func, NULL, NULL, buffer);
}
-#pragma GCC diagnostic pop
noreturn void log_assert_failed(const char *text, const char *file, int line, const char *func) {
log_assert(LOG_CRIT, text, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Aborting.");
diff --git a/src/libudev/macro.h b/src/libudev/macro.h
index 835610caf3..088fcd2640 100644
--- a/src/libudev/macro.h
+++ b/src/libudev/macro.h
@@ -39,6 +39,11 @@
#define _public_ __attribute__ ((visibility("default")))
#define _cleanup_(x) __attribute__((cleanup(x)))
+
+#define DISABLE_WARNING_FORMAT_NONLITERAL \
+ _Pragma("GCC diagnostic push"); \
+ _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
+
/* Rounds up */
#define ALIGN4(l) (((l) + 3) & ~3)
diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c
index 9b99d1ff9f..828b349d9c 100644
--- a/src/udev/udev-builtin-input_id.c
+++ b/src/udev/udev-builtin-input_id.c
@@ -38,8 +38,6 @@
#define LONG(x) ((x)/BITS_PER_LONG)
#define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
/*
* Read a capability attribute and return bitmask.
* @param dev udev_device
@@ -84,11 +82,13 @@ static void get_cap_mask(struct udev_device *dev,
/* skip over leading zeros */
while (bitmask[val-1] == 0 && val > 0)
--val;
- for (i = 0; i < val; ++i)
+ for (i = 0; i < val; ++i) {
+ DISABLE_WARNING_FORMAT_NONLITERAL;
log_debug(text, i * BITS_PER_LONG, bitmask[i]);
+ REENABLE_WARNING;
+ }
}
}
-#pragma GCC diagnostic pop
/* pointer devices */
static void test_pointers (struct udev_device *dev,