git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] convert: constify some variables in ident_to_worktree()

From
Collin Funk <collin.funk1@gmail.com>
Date
Mar 10, 2026, 04:03 UTC
Message-ID
<d3447c19d83c37bf2db84ae0bf75801ef7a36cea.1773115420.git.collin.funk1@gmail.com>
When building with glibc-2.43 there is the following warnings:
    convert.c: In function ‘ident_to_worktree’:
    convert.c:1189:24: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     1189 |                 dollar = memchr(src, '$', len);
          |                        ^
    convert.c:1212:32: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     1212 |                         dollar = memchr(src + 3, '$', len - 3);
          |                                ^
    convert.c:1223:29: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     1223 |                         spc = memchr(src + 4, ' ', dollar - src - 4);
          |                             ^

The "dollar" and "space" pointers are used to iterate over the const string "src". Since they are never written to we can make them const too.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
---
 convert.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/convert.c b/convert.c
index a34ec6ecdc..eae36c8a59 100644
--- a/convert.c
+++ b/convert.c
@@ -1168,7 +1168,8 @@ static int ident_to_worktree(const char *src, size_t len,
 			     struct strbuf *buf, int ident)
 {
 	struct object_id oid;
-	char *to_free = NULL, *dollar, *spc;
+	char *to_free = NULL;
+	const char *dollar, *spc;
 	int cnt;
 
 	if (!ident)
-- 
2.53.0
Message 1 of 1 in “convert: constify some variables in ident_to_worktree()”
  1. convert: constify some variables in ident_to_worktree()Collin Funk, Mar 10, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.