diff options
author | crunchy <crunchy> | 2003-03-20 13:34:05 +0000 |
---|---|---|
committer | crunchy <crunchy> | 2003-03-20 13:34:05 +0000 |
commit | 3bb2564b5112878aff0ea4de28b1ecbddce6cbad (patch) | |
tree | fe76e08168f5f4bb48fe1556a4576c5d6d85960e | |
parent | 0a4eb210f776132be8f6e421bf950516d3693f69 (diff) | |
download | mpiosh-3bb2564b5112878aff0ea4de28b1ecbddce6cbad.tar.gz mpiosh-3bb2564b5112878aff0ea4de28b1ecbddce6cbad.tar.bz2 mpiosh-3bb2564b5112878aff0ea4de28b1ecbddce6cbad.zip |
next try to fix the bug in debug.c
-rw-r--r-- | libmpio/debug.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/libmpio/debug.c b/libmpio/debug.c index 2596e9d..c1ead3e 100644 --- a/libmpio/debug.c +++ b/libmpio/debug.c @@ -4,7 +4,7 @@ * Authors: Dirk Meyer <dmeyer@tzi.de> * Andreas Büsching <crunchy@tzi.de> * - * $Id: debug.c,v 1.2 2003/03/19 16:41:57 crunchy Exp $ + * $Id: debug.c,v 1.3 2003/03/20 13:34:05 crunchy Exp $ */ #include "debug.h" @@ -20,6 +20,8 @@ #define DSUFFIX "_debug" #define LEVEL_HEXDUMP 5 +#define CHECK_FD if (__debug_fd == NULL) return; + char *__debug_color = NULL; int __debug_level = 0; FILE *__debug_fd = NULL; @@ -127,6 +129,8 @@ _hexdump (const char *package, const char* file, int line, char buf[17]; int i; + CHECK_FD; + if (_use_debug(LEVEL_HEXDUMP)) { fprintf (__debug_fd, "%s%s:\033[m %s(%d): %s: data=%p len=%d\n", __debug_color, package, file, line, function, data, len); @@ -154,6 +158,8 @@ _hexdump_n (const char *package, const int n, const char* file, int line, char buf[17]; int i; + CHECK_FD; + if (_use_debug(n)) { fprintf (__debug_fd, "%s%s:\033[m %s(%d): %s: data=%p len=%d\n", __debug_color, package, file, line, function, data, len); @@ -180,6 +186,8 @@ _hexdump_text (const char *text, const char *package, const char *file, int line, const char *function, const char *data, int len) { + CHECK_FD; + if (_use_debug(LEVEL_HEXDUMP)) { fprintf(__debug_fd, "%s%s: %s(%d): %s: %s\033[m", __debug_color, package, file, line, function, text); @@ -195,8 +203,12 @@ _error(const char *package, const char *file, int line, { char foo[2048]; va_list ap; + + CHECK_FD; + va_start(ap, format); + vsnprintf(foo, sizeof(foo) - strlen(format) - 1, format, ap); if (_use_debug(0)) fprintf(__debug_fd, "\033[31m%s: %s(%d): %s: %s\033[m", @@ -222,6 +234,8 @@ _debug(const char *package, const char *file, int line, va_list ap; va_start(ap, format); + CHECK_FD; + vsnprintf(foo, sizeof(foo) - strlen(format) - 1, format, ap); if (_use_debug(0)) { @@ -242,6 +256,8 @@ _debug_n(const char *package, const int n, const char *file, va_list ap; va_start(ap, format); + CHECK_FD; + vsnprintf(foo, sizeof(foo) - strlen(format) - 1, format, ap); if (_use_debug(n)) { @@ -259,6 +275,8 @@ _octetstr(const char *package, const char *file, int line, const char *function, const uint8_t *str, const unsigned int len, const char *what) { + CHECK_FD; + if (_use_debug(LEVEL_HEXDUMP)) { unsigned int i; @@ -277,7 +295,8 @@ int _use_debug(int level) { if (__debug_level == -1) return 0; - if (__debug_fd == NULL) return 0; + + CHECK_FD; if (level <= __debug_level) { return 1; |