From 283cb2272085d2cc086ed2d78d7eb24865bda701 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 21 Dec 2025 21:48:57 -0800 Subject: [PATCH] util/u_printf: Fix const correctness in util_printf_next_spec_pos Fix compiler error: ../src/util/u_printf.c:75:13: error: initializing 'char *' with an expression of type 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] 75 | char *spec_pos = strpbrk(str_found, "cdieEfFgGaAosuxXp%"); | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ glibc now provides C23-style type-generic string functions. strpbrk returns const char * when passed a const char * argument. Update spec_pos declaration to match. Fixes: 6d263ff5a3ec ("util: Convert util/u_printf.cpp to util/u_printf.c") Signed-off-by: Vinson Lee Reviewed-by: Yonggang Luo (cherry picked from commit c576d64801de0352cfd9b9e0067758f2283f95dd) Part-of: --- .pick_status.json | 2 +- src/util/u_printf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index a0ce6c5761c..f0c939f72f0 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -844,7 +844,7 @@ "description": "util/u_printf: Fix const correctness in util_printf_next_spec_pos", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "6d263ff5a3ec3352bd5e0b1750d38b173d50a1dc", "notes": null diff --git a/src/util/u_printf.c b/src/util/u_printf.c index 67ff4831c64..fb5fd7dc524 100644 --- a/src/util/u_printf.c +++ b/src/util/u_printf.c @@ -72,7 +72,7 @@ size_t util_printf_next_spec_pos(const char *str, size_t pos) continue; } - char *spec_pos = strpbrk(str_found, "cdieEfFgGaAosuxXp%"); + const char *spec_pos = strpbrk(str_found, "cdieEfFgGaAosuxXp%"); if (spec_pos == NULL) { return -1; } else if (*spec_pos == '%') {