public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Collin Funk <collin.funk1@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] bloom: remove a misleading const qualifier
Date: Mon, 09 Mar 2026 07:59:57 -0700	[thread overview]
Message-ID: <xmqq7brl6ob6.fsf@gitster.g> (raw)
In-Reply-To: <ab59807b36213a51245965fa46c1770de10bcd2c.1773024911.git.collin.funk1@gmail.com> (Collin Funk's message of "Sun, 8 Mar 2026 19:55:11 -0700")

Collin Funk <collin.funk1@gmail.com> writes:

> When building with glibc-2.43 there is the following warning:
>
>     bloom.c: In function ‘get_or_compute_bloom_filter’:
>     bloom.c:515:52: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
>       515 |                                 char *last_slash = strrchr(path, '/');
>           |                                                    ^~~~~~~
>
> In this case, we always write through "path" through the "last_slash"
> pointer. Therefore, the const qualifier on "path" is misleading and we
> can just remove it.

Right.  Thanks.


> Signed-off-by: Collin Funk <collin.funk1@gmail.com>
> ---
>  bloom.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/bloom.c b/bloom.c
> index 77a6fddf72..a805ac0c29 100644
> --- a/bloom.c
> +++ b/bloom.c
> @@ -501,7 +501,7 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,
>  		struct hashmap_iter iter;
>  
>  		for (i = 0; i < diff_queued_diff.nr; i++) {
> -			const char *path = diff_queued_diff.queue[i]->two->path;
> +			char *path = diff_queued_diff.queue[i]->two->path;
>  
>  			/*
>  			 * Add each leading directory of the changed file, i.e. for
> @@ -523,7 +523,7 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,
>  					free(e);
>  
>  				if (!last_slash)
> -					last_slash = (char*)path;
> +					last_slash = path;
>  				*last_slash = '\0';
>  
>  			} while (*path);

      reply	other threads:[~2026-03-09 14:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09  2:55 [PATCH] bloom: remove a misleading const qualifier Collin Funk
2026-03-09 14:59 ` Junio C Hamano [this message]

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=xmqq7brl6ob6.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=collin.funk1@gmail.com \
    --cc=git@vger.kernel.org \
    /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