Volume XXII, number 280Wednesday, October 7, 2026Latest message 1 hour ago

The Git List

News and archive of git@vger.kernel.org, since April 2005

patchFix compiler warning with latest gcc

3 messages between Apr 17, 2026 and Apr 17, 2026, from Marcel Holtmann, Collin Funk.

Plain Markdown or JSON for tools and agents. Diffs are folded; open one to read it.

Marcel HoltmannApr 17, 2026, 16:12 UTC on lore
        CC  src/diff.o
src/diff.c: In function ‘diff_common_add_diff_stat’:
src/diff.c:191:22: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  191 |         char *pipe = strchr(data, '|');
      |                      ^~~~~~
---
 src/diff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to src/diff.c +1 −1
diff --git a/src/diff.c b/src/diff.c
index 6c670e4b4fb4..182ea349eb9c 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -188,7 +188,7 @@ diff_common_add_diff_stat(struct view *view, const char *text, size_t offset)
 	const char *start = text + offset;
 	const char *data = start + strspn(start, " ");
 	size_t len = strlen(data);
-	char *pipe = strchr(data, '|');
+	const char *pipe = strchr(data, '|');
 
 	/* Ensure that '|' is present and the file name part contains
 	 * non-space characters. */
-- 
2.53.0
Collin FunkApr 17, 2026, 16:38 UTC in reply to Marcel Holtmann on lore

Re: [PATCH tig] Fix compiler warning with latest gcc

Marcel Holtmann <marcel@holtmann.org> writes:
Show 22 quoted lines
>         CC  src/diff.o
> src/diff.c: In function ‘diff_common_add_diff_stat’:
> src/diff.c:191:22: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
>   191 |         char *pipe = strchr(data, '|');
>       |                      ^~~~~~
> ---
>  src/diff.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/diff.c b/src/diff.c
> index 6c670e4b4fb4..182ea349eb9c 100644
> --- a/src/diff.c
> +++ b/src/diff.c
> @@ -188,7 +188,7 @@ diff_common_add_diff_stat(struct view *view, const char *text, size_t offset)
>  	const char *start = text + offset;
>  	const char *data = start + strspn(start, " ");
>  	size_t len = strlen(data);
> -	char *pipe = strchr(data, '|');
> +	const char *pipe = strchr(data, '|');
>  
>  	/* Ensure that '|' is present and the file name part contains
>  	 * non-space characters. */

Minor nit about the commit message, but this is due to a glibc-2.43 change. It isn't related to GCC versions.

Collin
Marcel HoltmannApr 17, 2026, 19:10 UTC in reply to Collin Funk on lore

Re: [PATCH tig] Fix compiler warning with latest gcc

Hi Collin,
Show 25 quoted lines
>>        CC  src/diff.o
>> src/diff.c: In function ‘diff_common_add_diff_stat’:
>> src/diff.c:191:22: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
>>  191 |         char *pipe = strchr(data, '|');
>>      |                      ^~~~~~
>> ---
>> src/diff.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/src/diff.c b/src/diff.c
>> index 6c670e4b4fb4..182ea349eb9c 100644
>> --- a/src/diff.c
>> +++ b/src/diff.c
>> @@ -188,7 +188,7 @@ diff_common_add_diff_stat(struct view *view, const char *text, size_t offset)
>> const char *start = text + offset;
>> const char *data = start + strspn(start, " ");
>> size_t len = strlen(data);
>> - char *pipe = strchr(data, '|');
>> + const char *pipe = strchr(data, '|');
>> 
>> /* Ensure that '|' is present and the file name part contains
>>  * non-space characters. */
> 
> Minor nit about the commit message, but this is due to a glibc-2.43
> change. It isn't related to GCC versions.
do you want me to fix it and send a v2 or do you just amend it after applying the patch?
Regards
Marcel

Back to recent threads