From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> Add helpers for direct write to stderr to consolidate the code and avoid the unused result warning in build. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> --- lib/igt_core.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index 538a4472e209..351859eaa04c 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -1239,7 +1239,7 @@ static const char hex[] = "0123456789abcdef"; static void xputch(int c) { - write(STDERR_FILENO, (const void *) &c, 1); + igt_assert_eq(write(STDERR_FILENO, (const void *) &c, 1), 1); } static int @@ -1384,13 +1384,23 @@ xprintf(const char *fmt, ...) va_end(ap); } +static void __write_stderr(const char *str, size_t len) +{ + igt_assert_eq(write(STDERR_FILENO, str, len), 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); @@ -1899,11 +1909,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)) { -- 2.9.5 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx