[CRIU] [PATCH 4/4] compel std_printf: annotate with printf
Kir Kolyshkin
kir at openvz.org
Mon Feb 13 14:21:15 PST 2017
On 02/13/2017 01:12 AM, Dmitry Safonov wrote:
> 2017-02-12 14:34 GMT+03:00 Kir Kolyshkin <kir at openvz.org>:
>> This function works like printf, and it helps the compiler
>> to know that, so it can check whether arguments fit the
>> format string.
>>
>> Signed-off-by: Kir Kolyshkin <kir at openvz.org>
>> ---
>> compel/plugins/include/uapi/std/string.h | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/compel/plugins/include/uapi/std/string.h b/compel/plugins/include/uapi/std/string.h
>> index ddc1ea3..5129017 100644
>> --- a/compel/plugins/include/uapi/std/string.h
>> +++ b/compel/plugins/include/uapi/std/string.h
>> @@ -14,7 +14,9 @@
>> extern void __std_putc(int fd, char c);
>> extern void __std_puts(int fd, const char *s);
>> extern void __std_printk(int fd, const char *format, va_list args);
> BTW, as we're already here: printk() version looks misnamed: it's vprintf().
> Care to fix that too?
Good catch!
After a second look, I think we can do some more renaming
and argument reordering, as what we have is basically
standard fputc/fputs with arguments swapped.
Here's what I propose:
__std_putc(int fd, char c) --> std_fputc(int c, int fd)
__std_puts(int fd, const char *s) --> std_fputs(const char *s, int fd)
__std_printk(int fd, const char *format, va_list args) --> std_vdprintf(int fd, const char *format, va_list args)
I'll send a separate patch.
>
>> -extern void __std_printf(int fd, const char *format, ...);
>> +extern void __std_printf(int fd, const char *format, ...)
>> + __attribute__ ((__format__ (__printf__, 2, 3)));
>> +
>>
>> #define std_printf(fmt, ...) __std_printf(STDOUT_FILENO, fmt, ##__VA_ARGS__)
>> #define std_puts(s) __std_puts(STDOUT_FILENO, s)
>> --
>> 2.9.3
>
More information about the CRIU
mailing list