Mesa (main): util/log: Don't print an extra \n if the format string had one.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 5 22:15:40 UTC 2022


Module: Mesa
Branch: main
Commit: 0ee0d54985df9a8260a9f0c89d5b2e896bc852f3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ee0d54985df9a8260a9f0c89d5b2e896bc852f3

Author: Emma Anholt <emma at anholt.net>
Date:   Thu Mar 10 12:30:16 2022 -0800

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 <daniels at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15332>

---

 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 e0f2a900c27..140485ff8c6 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



More information about the mesa-commit mailing list