From: Junio C Hamano <gitster@pobox.com>
To: "Ahelenia Ziemiańska" <nabijaczleweli@nabijaczleweli.xyz>
Cc: git@vger.kernel.org, "Jean-Noël Avila" <jn.avila@free.fr>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Elijah Newren" <newren@gmail.com>,
"Glen Choo" <glencbz@gmail.com>, "Taylor Blau" <me@ttaylorr.com>
Subject: Re: [PATCH] Make remaining usage strings and string tables const
Date: Mon, 21 Apr 2025 13:30:36 -0700 [thread overview]
Message-ID: <xmqqv7qx5kb7.fsf@gitster.g> (raw)
In-Reply-To: <daj53eijkqzsjy5cvuxchea4qm3pbiu673ehetihfffyvwzhgs@tarta.nabijaczleweli.xyz> ("Ahelenia Ziemiańska"'s message of "Mon, 21 Apr 2025 10:56:13 +0200")
Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> writes:
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
> ---
I've looked at these changes (I wouldn't claim with fine toothed
comb, though) and they looked correct. Most of the changes are to
ensure not just the strings are not writable through the pointers in
the arrays but the arrays themselves cannot be modified to hold
pionters that point elsewhere.
Functions like parse_revision_opt() declare their parameter for the
usage string array as
const char *const usagestr[]
but that merely promises to the caller that the function would not
touch the strings or the pointers in the incoming array, so the
callers declaring the array they pass, like blame_opt_usage[] here,
> -static const char *blame_opt_usage[] = {
> +static const char *const blame_opt_usage[] = {
> blame_usage,
> "",
> N_("<rev-opts> are documented in git-rev-list(1)"),
> NULL
> };
much looser to allow swapping the pointers in the array is *not* a
problem per-se, but as long as the compiler would not barf after
this patch, we know these callers that use these arrays are not
doing such mutations to these arrays themselves, so it is good.
Thanks.
next prev parent reply other threads:[~2025-04-21 20:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-21 8:56 [PATCH] Make remaining usage strings and string tables const Ahelenia Ziemiańska
2025-04-21 20:30 ` Junio C Hamano [this message]
2025-04-21 20:53 ` Ahelenia Ziemiańska
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=xmqqv7qx5kb7.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=glencbz@gmail.com \
--cc=jn.avila@free.fr \
--cc=me@ttaylorr.com \
--cc=nabijaczleweli@nabijaczleweli.xyz \
--cc=newren@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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