[PATCH 4/4] os: complain about unsupported pnprintf directives
Peter Hutterer
peter.hutterer at who-t.net
Sun Apr 14 21:02:00 PDT 2013
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
os/log.c | 1 +
test/signal-logging.c | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/os/log.c b/os/log.c
index 074c69c..aa69a35 100644
--- a/os/log.c
+++ b/os/log.c
@@ -461,6 +461,7 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
string[s_idx++] = '%';
break;
default:
+ BUG_WARN_MSG(f[f_idx], "Unsupported printf directive '%c'\n", f[f_idx]);
va_arg(args, char*);
string[s_idx++] = '%';
if (s_idx < size - 1)
diff --git a/test/signal-logging.c b/test/signal-logging.c
index b45d8d4..f6bc85c 100644
--- a/test/signal-logging.c
+++ b/test/signal-logging.c
@@ -206,6 +206,13 @@ static void logging_format(void)
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) test a\n") == 0);
+ /* something unsupported % */
+ LogMessageVerbSigSafe(X_ERROR, -1, "test %Q\n");
+ read_log_msg(logmsg);
+ assert(strstr(logmsg, "BUG") != NULL);
+ LogMessageVerbSigSafe(X_ERROR, -1, "\n");
+ fseek(f, 0, SEEK_END);
+
/* string substitution */
LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", "substituted string");
read_log_msg(logmsg);
--
1.8.1.4
More information about the xorg-devel
mailing list