diff --git a/src/helper/log.c b/src/helper/log.c index 0976f4e0f..afba0d172 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 3f94ffec7..7bf049cd8 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 b6e5f9e47..eff62c62b 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 479f6d183..11b6ae76e 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 ea7f38fb8..83d50c2d0 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -602,7 +602,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 */ @@ -616,9 +617,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 8054a1c9b..3dffce50e 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 ||