glx: fix const qualifier warnings found with C23 glibc support

glibc master has been C23'fying the functions which is resulting errors

Several functions assigned results of bsearch/strstr/strpbrk/memchr to
non-const pointers, triggering -Wincompatible-pointer-types-discards-qualifiers
under clang/gcc with -Werror. Cast bsearch return values where needed and
propagate const correctness for strstr/strpbrk/memchr results.

Removes build failures with strict warning flags without changing behavior.

Signed-off-by: Khem Raj <raj.khem@gmail.com>

[Eric: changed the glxglvnd.c hunk to add the missing `const` instead of casting it away]

Cc: mesa-stable
(cherry picked from commit 268e19378f)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39969>
This commit is contained in:
Khem Raj 2025-11-22 15:52:23 -08:00 committed by Dylan Baker
parent 90177a9176
commit c930daf705
3 changed files with 3 additions and 3 deletions

View file

@ -1144,7 +1144,7 @@
"description": "glx: fix const qualifier warnings found with C23 glibc support",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -129,7 +129,7 @@ glxSendClientInfo(struct glx_display *glx_dpy, int screen)
const char *haystack = src->serverGLXexts;
while (haystack != NULL) {
char *match = strstr(haystack, "GLX_ARB_create_context");
const char *match = strstr(haystack, "GLX_ARB_create_context");
if (match == NULL)
break;

View file

@ -26,7 +26,7 @@ compare(const void *l, const void *r)
static unsigned FindGLXFunction(const GLubyte *name)
{
const char **match;
const char * const *match;
match = bsearch(name, __glXDispatchTableStrings, DI_FUNCTION_COUNT,
sizeof(const char *), compare);