From: Collin Funk <collin.funk1@gmail•com>
To: git@vger•kernel.org
Cc: Collin Funk <collin.funk1@gmail•com>, Junio C Hamano <gitster@pobox•com>
Subject: [PATCH] convert: constify some variables in ident_to_worktree()
Date: Mon, 9 Mar 2026 21:03:40 -0700 [thread overview]
Message-ID: <d3447c19d83c37bf2db84ae0bf75801ef7a36cea.1773115420.git.collin.funk1@gmail.com> (raw)
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
reply other threads:[~2026-03-10 4:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d3447c19d83c37bf2db84ae0bf75801ef7a36cea.1773115420.git.collin.funk1@gmail.com \
--to=collin.funk1@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox