This is an automated email from Gerrit.

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

-- gerrit

commit 53e6d624f4a4d7a0364c1df7b3b1cb7ff494b2e6
Author: Christoph Seitz <[email protected]>
Date:   Tue May 5 13:41:17 2026 +0000

    Fix const correctnes for strchr and strrchr
    
    Recent compiler and libc updates have generic signature
    for certain libc functions. The return type these functions
    is the same as the argument type. This causes compilation
    errors. The patch fixes the types and usage of the return
    values to be const correct.
    
    Change-Id: I20a769cdc82675938f64fb47cd77ff84c0980d51
    Signed-off-by: Christoph Seitz <[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..1685d11a54 100644
--- a/src/jtag/drivers/vdebug.c
+++ b/src/jtag/drivers/vdebug.c
@@ -1215,12 +1215,14 @@ static int vdebug_dap_run(struct adiv5_dap *dap)
 
 COMMAND_HANDLER(vdebug_set_server)
 {
-       if ((CMD_ARGC != 1) || !strchr(CMD_ARGV[0], ':'))
+       if (CMD_ARGC != 1)
                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);
+       const char *pchar = strchr(CMD_ARGV[0], ':');
+       if (!pchar)
+               return ERROR_COMMAND_SYNTAX_ERROR;
+       size_t len = MIN(pchar - CMD_ARGV[0], sizeof(vdc.server_name) - 1);
+       memcpy(vdc.server_name, CMD_ARGV[0], len);
+       vdc.server_name[len] = '\0';
        int port = atoi(++pchar);
        if (port < 0 || port > UINT16_MAX) {
                LOG_ERROR("invalid port number %d specified", port);
diff --git a/src/rtos/ecos.c b/src/rtos/ecos.c
index 41159bf094..84fb05800a 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;

-- 

Reply via email to