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/+/9478

-- gerrit

commit b03ea6b3da36951ff31b7b9378b81d7044b85436
Author: Marc Schink <[email protected]>
Date:   Thu Feb 26 05:56:57 2026 -0800

    Fix build issue on MSYS2 and Cygwin
    
    The is* 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 ISALPHA(3) manual page.
    
    Example error message on Cygwin:
    
    ../src/helper/log.c: In function ‘find_nonprint_char’:
    ../src/helper/log.c:525:33: error: array subscript has type ‘char’ 
[-Werror=char-subscripts]
      525 |                 if (!isprint(buf[i]))
    
    Change-Id: I9c7a5cc1085e15fed0f3f974ec943abad44e68a0
    Signed-off-by: Marc Schink <[email protected]>

diff --git a/src/helper/log.c b/src/helper/log.c
index 06d3810557..b2663b9ccf 100644
--- a/src/helper/log.c
+++ b/src/helper/log.c
@@ -526,7 +526,7 @@ void log_socket_error(const char *socket_desc)
 const char *find_nonprint_char(const char *buf, unsigned int buf_len)
 {
        for (unsigned int i = 0; i < buf_len; i++) {
-               if (!isprint(buf[i]))
+               if (!isprint((unsigned char)buf[i]))
                        return buf + i;
        }
        return NULL;
diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c
index 3f94ffec7f..7bf049cd86 100644
--- a/src/jtag/adapter.c
+++ b/src/jtag/adapter.c
@@ -970,7 +970,7 @@ COMMAND_HANDLER(adapter_gpio_config_handler)
        while (i < CMD_ARGC) {
                LOG_DEBUG("Processing %s", CMD_ARGV[i]);
 
-               if (isdigit(*CMD_ARGV[i])) {
+               if (isdigit((unsigned char)*CMD_ARGV[i])) {
                        COMMAND_PARSE_NUMBER(uint, CMD_ARGV[i], 
gpio_config->gpio_num);
                        ++i;
                        continue;
diff --git a/src/pld/efinix.c b/src/pld/efinix.c
index b6e5f9e477..eff62c62bc 100644
--- a/src/pld/efinix.c
+++ b/src/pld/efinix.c
@@ -82,7 +82,8 @@ static int efinix_read_bit_file(struct raw_bit_file 
*bit_file, const char *filen
                        return ERROR_PLD_FILE_LOAD_FAILED;
                }
 
-               if (!isxdigit(buffer[0]) || !isxdigit(buffer[1])) {
+               if (!isxdigit((unsigned char)buffer[0]) ||
+                               !isxdigit((unsigned char)buffer[1])) {
                        fclose(input_file);
                        free(bit_file->data);
                        bit_file->data = NULL;
diff --git a/src/pld/gatemate.c b/src/pld/gatemate.c
index f35b39ad21..04edfbe4b7 100644
--- a/src/pld/gatemate.c
+++ b/src/pld/gatemate.c
@@ -57,7 +57,8 @@ static int gatemate_read_cfg_line(struct gatemate_bit_file 
*bit_file, const char
                } else if (line_buffer[idx] == 0) {
                        break;
                } else if (idx + 1 < nread) {
-                       if (isxdigit(line_buffer[idx]) && 
isxdigit(line_buffer[idx + 1])) {
+                       if (isxdigit((unsigned char)line_buffer[idx]) &&
+                                       isxdigit((unsigned char)line_buffer[idx 
+ 1])) {
                                uint8_t byte;
                                unhexify(&byte, line_buffer + idx, 2);
                                int retval = 
gatemate_add_byte_to_bitfile(bit_file, byte);
diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c
index 3634a2a592..10a3802ad8 100644
--- a/src/server/telnet_server.c
+++ b/src/server/telnet_server.c
@@ -601,7 +601,8 @@ static void telnet_auto_complete(struct connection 
*connection)
 
        /* user command position in the line, ignore leading spaces */
        size_t usr_cmd_pos = seq_start;
-       while ((usr_cmd_pos < t_con->line_cursor) && 
isspace(t_con->line[usr_cmd_pos]))
+       while ((usr_cmd_pos < t_con->line_cursor) &&
+                       isspace((unsigned char)t_con->line[usr_cmd_pos]))
                usr_cmd_pos++;
 
        /* check user command length */
@@ -615,9 +616,10 @@ static void telnet_auto_complete(struct connection 
*connection)
         * because info commands does not tolerate multiple spaces */
        size_t optimized_spaces = 0;
        char query[usr_cmd_len + 1];
+
        for (size_t i = 0; i < usr_cmd_len; i++) {
-               if ((i < usr_cmd_len - 1) && isspace(t_con->line[usr_cmd_pos + 
i])
-                               && isspace(t_con->line[usr_cmd_pos + i + 1])) {
+               if ((i < usr_cmd_len - 1) && isspace((unsigned 
char)t_con->line[usr_cmd_pos + i])
+                               && isspace((unsigned 
char)t_con->line[usr_cmd_pos + i + 1])) {
                        optimized_spaces++;
                        continue;
                }
diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c
index 8054a1c9b7..3dffce50e8 100644
--- a/src/target/riscv/riscv.c
+++ b/src/target/riscv/riscv.c
@@ -4380,7 +4380,7 @@ static bool parse_csr_address(const char 
*reg_address_str, unsigned int *reg_add
 {
        *reg_addr = -1;
        /* skip initial spaces */
-       while (isspace(reg_address_str[0]))
+       while (isspace((unsigned char)reg_address_str[0]))
                ++reg_address_str;
        /* try to detect if string starts with 0x or 0X */
        bool is_hex_address = strncmp(reg_address_str, "0x", 2) == 0 ||

-- 

Reply via email to