From 0ee0d54985df9a8260a9f0c89d5b2e896bc852f3 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Thu, 10 Mar 2022 12:30:16 -0800 Subject: [PATCH] util/log: Don't print an extra \n if the format string had one. You're not supposed to include a '\n' in mesa_log*() messages because android logging will log what you provide on its own line anyway, so each mesa_log() should be the body of a log line. But also, getting everyone to consistently not do that is hopeless because we're all so trained by printf(). So, just detect an existing \n and don't add a new one. Cleans up deqp-vk debug output a bunch from turnip. Acked-by: Daniel Stone Part-of: --- src/util/log.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/log.c b/src/util/log.c index e0f2a90..140485f 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -87,7 +87,8 @@ mesa_log_v(enum mesa_log_level level, const char *tag, const char *format, #endif fprintf(stderr, "%s: %s: ", tag, level_to_str(level)); vfprintf(stderr, format, va); - fprintf(stderr, "\n"); + if (format[strlen(format) - 1] != '\n') + fprintf(stderr, "\n"); #if !DETECT_OS_WINDOWS funlockfile(stderr); #endif -- 2.7.4