diff options
author | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2017-11-08 12:06:52 +0000 |
---|---|---|
committer | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2017-11-22 17:56:14 +0000 |
commit | db31e3c1ca0953b6e6832c25060acd01012a66dd (patch) | |
tree | 7dd9b9404570f9bf69a01be4ef462f900d39e71b /lib/igt_core.c | |
parent | c1fe411c5d0461ffabcf96fd4305bd09f85005fa (diff) |
lib/core: Avoid unused result in backtrace printing
Add helpers for direct write to stderr to consolidate the code
and avoid the unused result warning in build.
v2: Use igt_ignore_warn since it is questionable whether igt_assert
is safe in signal handlers. (Chris Wilson)
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_core.c')
-rw-r--r-- | lib/igt_core.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c index ba4622d6..4fe48c97 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -1262,7 +1262,7 @@ static const char hex[] = "0123456789abcdef"; static void xputch(int c) { - write(STDERR_FILENO, (const void *) &c, 1); + igt_ignore_warn(write(STDERR_FILENO, (const void *) &c, 1)); } static int @@ -1407,13 +1407,23 @@ xprintf(const char *fmt, ...) va_end(ap); } +static void __write_stderr(const char *str, size_t len) +{ + igt_ignore_warn(write(STDERR_FILENO, str, len)); +} + +static void write_stderr(const char *str) +{ + __write_stderr(str, strlen(str)); +} + static void print_backtrace_sig_safe(void) { unw_cursor_t cursor; unw_context_t uc; int stack_num = 0; - write(STDERR_FILENO, "Stack trace: \n", 15); + write_stderr("Stack trace: \n"); unw_getcontext(&uc); unw_init_local(&cursor, &uc); @@ -1922,11 +1932,10 @@ static void fatal_sig_handler(int sig) continue; if (handled_signals[i].name_len) { - igt_assert_eq(write(STDERR_FILENO, "Received signal ", 16), - 16); - igt_assert_eq(write(STDERR_FILENO, handled_signals[i].name, handled_signals[i].name_len), - handled_signals[i].name_len); - igt_assert_eq(write(STDERR_FILENO, ".\n", 2), 2); + write_stderr("Received signal "); + __write_stderr(handled_signals[i].name, + handled_signals[i].name_len); + write_stderr(".\n"); } if (crash_signal(sig)) { |