Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH 2/6] lex: Mark variables with const init as const
On 1 Jan, Jörg Sommer wrote:
> Because these variables are initialized with as constant string, they should
> be marked as *const* to make the compiler running with `-Wwrite-strings`
> more happy.
Applying this patch series causes a couple of fresh warnings:
zle_thingy.c: In function 'bin_zle_refresh':
zle_thingy.c:420:15: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
420 | char *s = statusline;
|
lex.c: In function 'exalias':
lex.c:1964:20: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1964 | zshlextext = tokstrings[tok];
|
clang describes these as "initializing 'char *' with an expression of
type 'const char *' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]".
I have no objection to adding const in more places where possible. You
may find we have code that is not really modifying its parameter but
relies on being able to temporarily swap a nul in for a character as
part of parsing. I also tend to find the old issue that you can't
safely cast a char ** to const char** tends to get in the way.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author