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

Re: [PATCH] global: constify some pointers that are not written to

From
Jeff King <peff@peff.net>
Date
Feb 5, 2026, 07:41 UTC
Message-ID
<20260205074139.GA1019015@coredump.intra.peff.net>
In-Reply-To
<342b01acd42f1fcaa3abefa38dc589e12ccb1134.1770261829.git.collin.funk1@gmail.com>
On Wed, Feb 04, 2026 at 07:24:19PM -0800, Collin Funk wrote:
> This patch fixes the more obvious ones by making them const when we do
> not write to the returned pointer.

Thanks, this looks like a good start. All of the changes look correct to me (and can be confirmed with the compiler). I also cross-checked them against my own earlier hacky pass. The only difference was in this hunk:

Show 10 quoted lines
> diff --git a/gpg-interface.c b/gpg-interface.c
> index 47222bf31b..87fb6605fb 100644
> --- a/gpg-interface.c
> +++ b/gpg-interface.c
> @@ -398,7 +398,7 @@ static void parse_ssh_output(struct signature_check *sigc)
>  {
>  	const char *line, *principal, *search;
>  	char *to_free;
> -	char *key = NULL;
> +	const char *key;

You've dropped the NULL initialization here. That's OK to do, as the NULL is never used (we assign "key" immediately before the first time we look at it). But it probably makes sense for this patch to change only one thing. So either leave the dead initialization, or remove it as a separate patch.

-Peff
Previous: Collin FunkNext: Junio C Hamano
Message 2 of 8 in “global: constify some pointers that are not written to”
  1. global: constify some pointers that are not written toCollin Funk, Feb 5, 2026
  2. Jeff KingFeb 5, 2026
  3. Junio C HamanoFeb 5, 2026
  4. Collin FunkFeb 5, 2026
  5. 1/2 global: constify some pointers that are not written toCollin Funk, Feb 6, 2026
  6. 2/2 gpg-interface: remove an unnecessary NULL initializationCollin Funk, Feb 6, 2026
  7. Junio C HamanoFeb 6, 2026
  8. Ben KnobleFeb 6, 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.