Skip to content

Commit

Permalink
Silence gcc on truncation of debug messages
Browse files Browse the repository at this point in the history
Also improve the DEBUG by reporting that messages were truncated.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
  • Loading branch information
simo5 authored and frozencemetery committed Sep 2, 2020
1 parent 99e4263 commit 0cef2b5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/t_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))

#define DEBUG(...) do { \
char msg[4096]; \
snprintf(msg, 4096, __VA_ARGS__); \
fprintf(stderr, "%s[%s:%d]: %s", argv[0], __FUNCTION__, __LINE__, msg); \
char _msg[4096]; \
int _snret; \
_snret = snprintf(_msg, 4096, __VA_ARGS__); \
fprintf(stderr, "%s[%s:%d]: %s", argv[0], __FUNCTION__, __LINE__, _msg); \
if (_snret >= 4096) fprintf(stderr, " [TRUNCATED]\n"); \
fflush(stderr); \
} while(0);

Expand Down

0 comments on commit 0cef2b5

Please sign in to comment.