From e9551eaf330a891276c4f70d3aaf5f28b11a1f68 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 7 Mar 2024 19:54:22 +0100 Subject: [PATCH] util/u_debug: fix parsing of "all" again The current implementation is incorrect if the string starts with "all" like "RADV_DEBUG=allbos". Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10741 Fixes: 0c42c79edfb ("utils/u_debug: Fix parse of "all,") Signed-off-by: Samuel Pitoiset Part-of: (cherry picked from commit 433a3c262a06c15c2884149d450043ad0ffdb32a) --- .pick_status.json | 2 +- src/util/u_debug.c | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 7f15e1fceba..1c319fc1d7e 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -124,7 +124,7 @@ "description": "util/u_debug: fix parsing of \"all\" again", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "0c42c79edfb031509c9c0cf833d52a6f4c064356", "notes": null diff --git a/src/util/u_debug.c b/src/util/u_debug.c index a86b37a67e9..3a5d3a691a8 100644 --- a/src/util/u_debug.c +++ b/src/util/u_debug.c @@ -423,18 +423,17 @@ parse_debug_string(const char *debug, if (debug != NULL) { for (; control->string != NULL; control++) { - if (!strncmp(debug, "all", strlen("all"))) { - flag |= control->flag; + const char *s = debug; + unsigned n; - } else { - const char *s = debug; - unsigned n; + for (; n = strcspn(s, ", "), *s; s += MAX2(1, n)) { + if (!n) + continue; - for (; n = strcspn(s, ", "), *s; s += MAX2(1, n)) { - if (strlen(control->string) == n && - !strncmp(control->string, s, n)) - flag |= control->flag; - } + if (!strncmp("all", s, n) || + (strlen(control->string) == n && + !strncmp(control->string, s, n))) + flag |= control->flag; } } }