This is an automated email from Gerrit. "Aurore Poirier <[email protected]>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9719
-- gerrit commit dd17354a250626967fe422d056cf23d5a3c9c314 Author: Aurore Poirier <[email protected]> Date: Wed May 20 10:25:18 2026 +0200 building: Fixed strchr uses with const char* Both gcc 16.1.1 and clang 22.1.5 were raising an error when compiling (respectively `-Wdiscarded-qualifiers` and `-Wincompatible-pointer-types-discards-qualifiers`) because of the way strchr used to work, even with `-std=gun99`. This commit fixes this compilation error and should allow compiling OpenOCD with more recent compilers, and possibly in C23. Change-Id: I6080adac87132f642a7c15d93f1492b21c3eef73 Signed-off-by: Aurore Poirier <[email protected]> diff --git a/src/helper/log.c b/src/helper/log.c index ce21a907d3..8263cfc601 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -104,7 +104,7 @@ static void log_puts(enum log_levels level, const char *function, const char *string) { - char *f; + const char *f; if (!log_output) { /* log_init() not called yet; print on stderr */ diff --git a/src/helper/options.c b/src/helper/options.c index 28e2221717..9eb26a4762 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -151,7 +151,7 @@ static char *find_relative_path(const char *from, const char *to) while (from[0] != '\0') { if (from[0] != '/') i++; - char *next = strchr(from, '/'); + const char *next = strchr(from, '/'); if (!next) break; from = next + 1; diff --git a/src/jtag/drivers/vdebug.c b/src/jtag/drivers/vdebug.c index 29bfa8360d..1ed1406f3b 100644 --- a/src/jtag/drivers/vdebug.c +++ b/src/jtag/drivers/vdebug.c @@ -1218,10 +1218,10 @@ COMMAND_HANDLER(vdebug_set_server) if ((CMD_ARGC != 1) || !strchr(CMD_ARGV[0], ':')) return ERROR_COMMAND_SYNTAX_ERROR; - char *pchar = strchr(CMD_ARGV[0], ':'); - *pchar = '\0'; - strncpy(vdc.server_name, CMD_ARGV[0], sizeof(vdc.server_name) - 1); - int port = atoi(++pchar); + const char *pchar = strchr(CMD_ARGV[0], ':'); + strncpy(vdc.server_name, CMD_ARGV[0], pchar - CMD_ARGV[0] + 1); + vdc.server_name[pchar - CMD_ARGV[0]] = '\0'; + int port = atoi(pchar + 1); if (port < 0 || port > UINT16_MAX) { LOG_ERROR("invalid port number %d specified", port); return ERROR_COMMAND_SYNTAX_ERROR; diff --git a/src/rtos/ecos.c b/src/rtos/ecos.c index 120b50685e..cadfa4442d 100644 --- a/src/rtos/ecos.c +++ b/src/rtos/ecos.c @@ -510,7 +510,7 @@ static bool ecos_escape_string(const char *raw, char *out, size_t limit) continue; } - char *fidx = strchr(tokens, *raw); + const char *fidx = strchr(tokens, *raw); if (!fidx) { /* Should never happen assuming xmlchars * vector and tokens string match. */ diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index 83d50c2d0b..52115a529d 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -68,7 +68,7 @@ static int telnet_outputline(struct connection *connection, const char *line) /* process lines in buffer */ while (*line) { - char *line_end = strchr(line, '\n'); + const char *line_end = strchr(line, '\n'); if (line_end) len = line_end-line; --
