From 41454622506d2d060cba8c6f1cbe98a359936a2b Mon Sep 17 00:00:00 2001 From: Damien Lespiau Date: Wed, 9 Jul 2014 11:36:27 +0100 Subject: [PATCH] core: Only display the errno message if errno is set Reviewed-by: Daniel Vetter Signed-off-by: Damien Lespiau --- lib/igt_core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index f683c3b..03c1f61 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -575,6 +575,10 @@ void __igt_skip_check(const char *file, const int line, { va_list args; int err = errno; + char *err_str = NULL; + + if (err) + asprintf(&err_str, "Last errno: %i, %s\n", err, strerror(err)); if (f) { static char *buf; @@ -589,13 +593,13 @@ void __igt_skip_check(const char *file, const int line, igt_skip("Test requirement not met in function %s, file %s:%i:\n" "Test requirement: (%s)\n%s" - "Last errno: %i, %s\n", - func, file, line, check, buf, err, strerror(err)); + "%s", + func, file, line, check, buf, err_str ?: ""); } else { igt_skip("Test requirement not met in function %s, file %s:%i:\n" "Test requirement: (%s)\n" - "Last errno: %i, %s\n", - func, file, line, check, err, strerror(err)); + "%s", + func, file, line, check, err_str ?: ""); } } -- 2.7.4