diff options
author | David Kalnischkies <david@kalnischkies.de> | 2017-10-05 14:49:27 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2017-10-05 17:30:25 +0200 |
commit | 50920fca5eff021f810d5de0cc9d2fa4d6068c50 (patch) | |
tree | 045df93cbce56169a49bb1a0ebb83489a5b469b5 | |
parent | 012932793ba0ea9398a9acd80593bed8e77cfbfc (diff) |
remove pointless va_copy to avoid cleanup dance
A va_copy call needs to be closed in all branches with va_end, so these
functions would need to be reworked slightly, but we don't actually need
to copy the va_list as we don't work on it, we just push it forward, so
dropping the copy and everyone is happy.
Reported-By: cppcheck
Gbp-Dch: Ignore
-rw-r--r-- | test/interactive-helper/libnoprofile.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/test/interactive-helper/libnoprofile.c b/test/interactive-helper/libnoprofile.c index 2cba6dc8b..f11b89899 100644 --- a/test/interactive-helper/libnoprofile.c +++ b/test/interactive-helper/libnoprofile.c @@ -7,17 +7,14 @@ #include <stdio.h> int vprintf(const char *format, va_list ap) { - static int (*func_fprintf)(const char *format, va_list ap) = NULL; - if (func_fprintf == NULL) - func_fprintf = (int (*) (const char *format, va_list ap)) dlsym(RTLD_NEXT, "vprintf"); - - va_list ap2; - va_copy(ap2, ap); if (strncmp(format, "profiling:", strlen("profiling:")) == 0) return 0; - int res = func_fprintf(format, ap2); - va_end(ap2); - return res; + + static int (*func_fprintf)(const char *format, va_list ap) = NULL; + if (func_fprintf == NULL) + func_fprintf = (int (*)(const char *format, va_list ap))dlsym(RTLD_NEXT, "vprintf"); + + return func_fprintf(format, ap); } int printf(const char *format, ...) { va_list ap; @@ -28,17 +25,14 @@ int printf(const char *format, ...) { } int vfprintf(FILE *stream, const char *format, va_list ap) { - static int (*func_vfprintf)(FILE *stream, const char *format, va_list ap) = NULL; - if (func_vfprintf == NULL) - func_vfprintf = (int (*) (FILE *stream, const char *format, va_list ap)) dlsym(RTLD_NEXT, "vfprintf"); - - va_list ap2; - va_copy(ap2, ap); if (strncmp(format, "profiling:", strlen("profiling:")) == 0) return 0; - int res = func_vfprintf(stream, format, ap2); - va_end(ap2); - return res; + + static int (*func_vfprintf)(FILE * stream, const char *format, va_list ap) = NULL; + if (func_vfprintf == NULL) + func_vfprintf = (int (*)(FILE * stream, const char *format, va_list ap))dlsym(RTLD_NEXT, "vfprintf"); + + return func_vfprintf(stream, format, ap); } int fprintf(FILE *stream, const char *format, ...) { |