]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-145092: Fix compiler warning for memchr() and wcschr() returning const pointer...
authorRudi Heitbaum <rudi@heitbaum.com>
Sun, 22 Feb 2026 08:01:27 +0000 (19:01 +1100)
committerGitHub <noreply@github.com>
Sun, 22 Feb 2026 08:01:27 +0000 (10:01 +0200)
Objects/stringlib/fastsearch.h
Python/preconfig.c

index b447865c986befc56fcc18220f4283b9dfbb334f..26bb0555ca9b6cf57e6e482c3575df515254a8d9 100644 (file)
@@ -69,8 +69,8 @@ STRINGLIB(find_char)(const STRINGLIB_CHAR* s, Py_ssize_t n, STRINGLIB_CHAR ch)
            and UCS4 representations. */
         if (needle != 0) {
             do {
-                void *candidate = memchr(p, needle,
-                                         (e - p) * sizeof(STRINGLIB_CHAR));
+                const void *candidate = memchr(p, needle,
+                                               (e - p) * sizeof(STRINGLIB_CHAR));
                 if (candidate == NULL)
                     return -1;
                 s1 = p;
index e4cd10d9e3d40d4ba67737beedda37854c85dc43..0fdc0a87317712238d3fbf73d0fee00224968252 100644 (file)
@@ -584,7 +584,7 @@ _Py_get_xoption(const PyWideStringList *xoptions, const wchar_t *name)
     for (Py_ssize_t i=0; i < xoptions->length; i++) {
         const wchar_t *option = xoptions->items[i];
         size_t len;
-        wchar_t *sep = wcschr(option, L'=');
+        const wchar_t *sep = wcschr(option, L'=');
         if (sep != NULL) {
             len = (sep - option);
         }
@@ -615,7 +615,7 @@ preconfig_init_utf8_mode(PyPreConfig *config, const _PyPreCmdline *cmdline)
     const wchar_t *xopt;
     xopt = _Py_get_xoption(&cmdline->xoptions, L"utf8");
     if (xopt) {
-        wchar_t *sep = wcschr(xopt, L'=');
+        const wchar_t *sep = wcschr(xopt, L'=');
         if (sep) {
             xopt = sep + 1;
             if (wcscmp(xopt, L"1") == 0) {