diff options
author | Vasilii Chernov <vchernov@inr.ru> | 2016-03-03 10:34:49 +0100 |
---|---|---|
committer | Vasilii Chernov <vchernov@inr.ru> | 2016-03-03 10:34:49 +0100 |
commit | ee16e47966afe180d3c32e2b1d93301052894fac (patch) | |
tree | 56aecf261aaae57e28c08cef573ae6642ec5394d /pcilib/error.c | |
parent | 02d0026e2df2ba5c68c0c1a67aec4437c9e8e8f3 (diff) | |
parent | 195c28f3074486165b6e0935362810f8a1fb9531 (diff) | |
download | pcitool-ee16e47966afe180d3c32e2b1d93301052894fac.tar.gz pcitool-ee16e47966afe180d3c32e2b1d93301052894fac.tar.bz2 pcitool-ee16e47966afe180d3c32e2b1d93301052894fac.tar.xz pcitool-ee16e47966afe180d3c32e2b1d93301052894fac.zip |
Merge with http://ufo.kit.edu/ufo/log/csa/pcitool 369 revision
Diffstat (limited to 'pcilib/error.c')
-rw-r--r-- | pcilib/error.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/pcilib/error.c b/pcilib/error.c index ae8bacb..8d25c82 100644 --- a/pcilib/error.c +++ b/pcilib/error.c @@ -12,8 +12,17 @@ #define PCILIB_LOGGER_HISTORY 16 void pcilib_print_error(void *arg, const char *file, int line, pcilib_log_priority_t prio, const char *msg, va_list va) { - vprintf(msg, va); - printf(" [%s:%d]\n", file, line); + size_t size = strlen(msg) + strlen(file) + 64; + char *stmp = alloca(size * sizeof(char*)); + + if (stmp) { + sprintf(stmp, "%s [%s:%d]\n", msg, file, line); + vprintf(stmp, va); + } else { + // Bad for multithreading... + vprintf(msg, va); + printf(" [%s:%d]\n", file, line); + } } static void *pcilib_logger_argument = NULL; |