From: Zbigniew Jędrzejewski-Szmek Date: Thu, 20 Apr 2017 18:15:28 +0000 (-0400) Subject: tree-wide: mark log_struct with _printf_ and fix fallout X-Git-Tag: chiark/234.4-1+devuan1.1+iwj1~160 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=14d2a81c8c1d4c06458c2ddcf89df28bc1de3602;ds=sidebyside tree-wide: mark log_struct with _printf_ and fix fallout log_struct takes multiple format strings, each one followed by arguments. The _printf_ annotation is not sufficiently flexible to express this, but we can still annotate the first format string, though not its arguments (because their number is unknown). With the annotation, the places which specified the message id or similar as the first pattern cause a warning from -Wformat-nonliteral. This can be trivially fixed by putting the MESSAGE= first. This change will help find issues where a non-literal is erroneously used as the pattern. --- diff --git a/src/basic/log.h b/src/basic/log.h index b232fe1fc..d4bc3a934 100644 --- a/src/basic/log.h +++ b/src/basic/log.h @@ -139,7 +139,7 @@ int log_format_iovec( bool newline_separator, int error, const char *format, - va_list ap); + va_list ap) _printf_(6, 0); /* This modifies the buffer passed! */ int log_dump_internal(