diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-09-24 23:22:19 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-09-24 23:26:46 +0200 |
commit | 963ddb917de3140308ee62fb642b2307a577a39e (patch) | |
tree | edfad917a0360b81c69a5030fe13b5716a687e46 /src/shared/macro.h | |
parent | 1920e37ef9fec04a1fd882f66bfa7a9a5b91c536 (diff) |
log: fix repeated invocation of vsnprintf()/vaprintf() in log_struct()
https://bugs.freedesktop.org/show_bug.cgi?id=55213
Diffstat (limited to 'src/shared/macro.h')
-rw-r--r-- | src/shared/macro.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/shared/macro.h b/src/shared/macro.h index c7ce7c87d0..0dd210afa7 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -193,4 +193,47 @@ static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) { #define _cleanup_closedir_ __attribute__((cleanup(closedirp))) #define _cleanup_umask_ __attribute__((cleanup(umaskp))) +#define VA_FORMAT_ADVANCE(format, ap) do { \ + int _argtypes[64]; \ + size_t _i, _k; \ + _k = parse_printf_format((format), ELEMENTSOF(_argtypes), _argtypes); \ + for (_i = 0; _i < _k; _i++) { \ + if (_argtypes[_i] & PA_FLAG_PTR) { \ + (void) va_arg(ap, void*); \ + continue; \ + } \ + \ + switch (_argtypes[_i]) { \ + case PA_INT: \ + case PA_INT|PA_FLAG_SHORT: \ + case PA_CHAR: \ + (void) va_arg(ap, int); \ + break; \ + case PA_INT|PA_FLAG_LONG: \ + (void) va_arg(ap, long int); \ + break; \ + case PA_INT|PA_FLAG_LONG_LONG: \ + (void) va_arg(ap, long long int); \ + break; \ + case PA_WCHAR: \ + (void) va_arg(ap, wchar_t); \ + break; \ + case PA_WSTRING: \ + case PA_STRING: \ + case PA_POINTER: \ + (void) va_arg(ap, void*); \ + break; \ + case PA_FLOAT: \ + case PA_DOUBLE: \ + (void) va_arg(ap, double); \ + break; \ + case PA_DOUBLE|PA_FLAG_LONG_DOUBLE: \ + (void) va_arg(ap, long double); \ + break; \ + default: \ + assert_not_reached("Unknown format string argument."); \ + } \ + } \ +} while(false) + #include "log.h" |