This is an automated email from Gerrit.

"Marc Schink <[email protected]>" just uploaded a new patch set to Gerrit, which you 
can find at https://review.openocd.org/c/openocd/+/9539

-- gerrit

commit fc4cdd546768754feb15e1334f2790cdd8bc2766
Author: Marc Schink <[email protected]>
Date:   Fri Mar 13 13:14:18 2026 +0100

    flash/nor/fm4: Fix build on MSYS2 with Clang
    
    The to{upper,lower} macros on MSYS2 (native) and Cygwin are implemented
    as table lookups and expect values representable as 'unsigned char'.
    Passing a signed char can lead to negative array indices and compile-time
    errors (-Werror=char-subscripts).
    
    Add explicit casts to 'unsigned char' to all affected is* calls, as
    recommended by the TOUPPER(3) manual page.
    
    Checkpatch-ignore: COMMIT_LOG_LONG_LINE
    
    ../src/flash/nor/fm4.c:608:28: error: array subscript is of type 'char' 
[-Werror,-Wchar-subscripts]
      608 |                 if (pattern[i] != 'x' && tolower(s[i]) != 
tolower(pattern[i]))
          |                                          ^~~~~~~~~~~~~
    /usr/include/ctype.h:172:25: note: expanded from macro 'tolower'
      172 |       (void) __CTYPE_PTR[__x]; (tolower) (__x);})
          |                         ^~~~
    ../src/flash/nor/fm4.c:608:45: error: array subscript is of type 'char' 
[-Werror,-Wchar-subscripts]
      608 |                 if (pattern[i] != 'x' && tolower(s[i]) != 
tolower(pattern[i]))
          |                                                           
^~~~~~~~~~~~~~~~~~~
    /usr/include/ctype.h:172:25: note: expanded from macro 'tolower'
      172 |       (void) __CTYPE_PTR[__x]; (tolower) (__x);})
          |                         ^~~~
    
    Change-Id: If9cca0a252d091bf01774ad33224904d807ee16c
    Signed-off-by: Marc Schink <[email protected]>

diff --git a/src/flash/nor/fm4.c b/src/flash/nor/fm4.c
index 2db79ef502..4c8f14c9ac 100644
--- a/src/flash/nor/fm4.c
+++ b/src/flash/nor/fm4.c
@@ -605,7 +605,7 @@ static bool fm4_name_match(const char *s, const char 
*pattern)
                if (!pattern[i])
                        return true;
                /* Use x as wildcard */
-               if (pattern[i] != 'x' && tolower(s[i]) != tolower(pattern[i]))
+               if (pattern[i] != 'x' && tolower((unsigned char)s[i]) != 
tolower((unsigned char)pattern[i]))
                        return false;
                i++;
        }

-- 

Reply via email to