{"thread":{"id":"65172","subject":"[PATCH] bloom: remove a misleading const qualifier","startedAt":"2026-03-09T02:55:25Z","lastAt":"2026-03-09T14:59:59Z","messageCount":2,"participants":["Collin Funk","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"538249","messageId":"ab59807b36213a51245965fa46c1770de10bcd2c.1773024911.git.collin.funk1@gmail.com","threadId":"65172","inReplyTo":null,"subject":"[PATCH] bloom: remove a misleading const qualifier","fromName":"Collin Funk","fromEmail":"collin.funk1@gmail.com","sentAt":"2026-03-09T02:55:11Z","receivedAt":"2026-03-09T02:55:25Z","isPatch":true,"sender":{"key":"collin.funk1@gmail.com","avatar":"https://avatars.githubusercontent.com/u/65689063?v=4"},"body":"When building with glibc-2.43 there is the following warning:\n\n    bloom.c: In function ‘get_or_compute_bloom_filter’:\n    bloom.c:515:52: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]\n      515 |                                 char *last_slash = strrchr(path, '/');\n          |                                                    ^~~~~~~\n\nIn this case, we always write through \"path\" through the \"last_slash\"\npointer. Therefore, the const qualifier on \"path\" is misleading and we\ncan just remove it.\n\nSigned-off-by: Collin Funk <collin.funk1@gmail.com>\n---\n bloom.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/bloom.c b/bloom.c\nindex 77a6fddf72..a805ac0c29 100644\n--- a/bloom.c\n+++ b/bloom.c\n@@ -501,7 +501,7 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,\n \t\tstruct hashmap_iter iter;\n \n \t\tfor (i = 0; i < diff_queued_diff.nr; i++) {\n-\t\t\tconst char *path = diff_queued_diff.queue[i]->two->path;\n+\t\t\tchar *path = diff_queued_diff.queue[i]->two->path;\n \n \t\t\t/*\n \t\t\t * Add each leading directory of the changed file, i.e. for\n@@ -523,7 +523,7 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,\n \t\t\t\t\tfree(e);\n \n \t\t\t\tif (!last_slash)\n-\t\t\t\t\tlast_slash = (char*)path;\n+\t\t\t\t\tlast_slash = path;\n \t\t\t\t*last_slash = '\\0';\n \n \t\t\t} while (*path);\n-- \n2.53.0\n\n"},{"id":"538282","messageId":"xmqq7brl6ob6.fsf@gitster.g","threadId":"65172","inReplyTo":"ab59807b36213a51245965fa46c1770de10bcd2c.1773024911.git.collin.funk1@gmail.com","subject":"Re: [PATCH] bloom: remove a misleading const qualifier","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-09T14:59:57Z","receivedAt":"2026-03-09T14:59:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Collin Funk <collin.funk1@gmail.com> writes:\n\n> When building with glibc-2.43 there is the following warning:\n>\n>     bloom.c: In function ‘get_or_compute_bloom_filter’:\n>     bloom.c:515:52: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]\n>       515 |                                 char *last_slash = strrchr(path, '/');\n>           |                                                    ^~~~~~~\n>\n> In this case, we always write through \"path\" through the \"last_slash\"\n> pointer. Therefore, the const qualifier on \"path\" is misleading and we\n> can just remove it.\n\nRight.  Thanks.\n\n\n> Signed-off-by: Collin Funk <collin.funk1@gmail.com>\n> ---\n>  bloom.c | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/bloom.c b/bloom.c\n> index 77a6fddf72..a805ac0c29 100644\n> --- a/bloom.c\n> +++ b/bloom.c\n> @@ -501,7 +501,7 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,\n>  \t\tstruct hashmap_iter iter;\n>  \n>  \t\tfor (i = 0; i < diff_queued_diff.nr; i++) {\n> -\t\t\tconst char *path = diff_queued_diff.queue[i]->two->path;\n> +\t\t\tchar *path = diff_queued_diff.queue[i]->two->path;\n>  \n>  \t\t\t/*\n>  \t\t\t * Add each leading directory of the changed file, i.e. for\n> @@ -523,7 +523,7 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,\n>  \t\t\t\t\tfree(e);\n>  \n>  \t\t\t\tif (!last_slash)\n> -\t\t\t\t\tlast_slash = (char*)path;\n> +\t\t\t\t\tlast_slash = path;\n>  \t\t\t\t*last_slash = '\\0';\n>  \n>  \t\t\t} while (*path);\n"}]}