Re: Minor cleanup after adding more warnings to CFLAGS

"Kevin J. McCarthy" <[email protected]>
Newsgroups gmane.mail.mutt.devel
Message-ID <acoG8RI8WODqByTF@qinghai>
On Sun, Mar 29, 2026 at 05:36:52PM +0200, Rene Kita wrote:
>What is the general opinion here regarding such compiler flags and how
>to handle such situations?

I'm going through these (besides imap_next_word() which I already 
commented about), but as you said, some of these aren't easy fixes.  I 
think we can note them in TODO but shouldn't strive too hard to fix them 
all now.

In some cases it's hard to know if the solution wouldn't be worse than
the cast is right now.

>mutt_socket.c: In function ‘mutt_conn_find’:
>mutt_socket.c:311:22: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
>  311 |   mutt_account_tourl((ACCOUNT*) account, &url, 0);

The ACCOUNT stuff is a mess that has been on my todo list for a while. 
The fact that they don't have a begin/end lifecycle is just a part of 
the problem.  Would definitely advise ignore this for now at least.

>mutt_zstrm.c: In function ‘mutt_zstrm_write’:
>mutt_zstrm.c:190:27: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
>  190 |   zctx->write.z.next_in = (Bytef*) buf;

Yeah, this is tough because we're inbetween the api and the CONNECTION
function pointer signatures.  Advise to let it be.

>pgppubring.c: In function ‘main’:
>pgppubring.c:159:34: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
>  159 |   pgpring_find_candidates(kring, (const char**) argv + optind, argc - optind);

I think this can be fixed by changing the types of main argv back to 
char *argv[], and the two functions: pgpring_string_matches_hint and 
pgpring_find_candidates to const char * const hints[].  Does that work
for you?

>date.c: In function ‘mutt_mktime’:
>date.c:88:20: warning: comparison is always false due to limited range of data type [-Wtype-limits]
>   88 |   if ((time_t)year > TM_YEAR_MAX)

I think this warning should be ignored.  It's a safety check, that maybe 
won't be true on all platorms.

>sendlib.c:73:15: warning: redundant redeclaration of ‘environ’ [-Wredundant-decls]
>   73 | extern char **environ;
>      |               ^~~~~~~
>In file included from mutt.h:25,
>                 from sendlib.c:26:
>/usr/include/unistd.h:566:15: note: previous declaration of ‘environ’ with type ‘char **’
>  566 | extern char **environ;

Hmm... I added the extern declaration myself four years ago.  I presumed 
I needed to but perhaps it's okay.  What happens if you comment it out? 
For me it builds fine.

>sendlib.c: In function ‘convert_file_from_to’:
>sendlib.c:864:50: warning: to be safe all intermediate pointers in cast from ‘char **’ to ‘const char **’ must be ‘const’ qualified [-Wcast-qual]
>  864 |       ret = convert_file_to(file, fcode, ncodes, (const char **)tcode,
>      |                                                  ^
>sendlib.c:879:52: warning: to be safe all intermediate pointers in cast from ‘char **’ to ‘const char **’ must be ‘const’ qualified [-Wcast-qual]
>  879 |     ret = convert_file_to(file, fromcodes, ncodes, (const char **)tcode,

Does changing the type and parameter case to (const char * const *) not 
work?

-- 
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEiXWpszqjeRA4XFMIre92hIAxa9oFAmnKBvEACgkQre92hIAx
a9qlqw/+M57CdzL9mCxbn03Fzkij7GVQxTg/I/ZEZo7dTBgYDhF1cj8S+2ZyW5Th
oYGWi3BYEEMYy5Lw6hlrXwYyLZvOdS3KogfRzdgojBquHo8CnqNfU5zhr0ZPksUM
SIRs274YRspD/rTcnnf5wNVrniptwqWdElcu2kRKsNs0v6Byigo1h4z4Y+YsTcBT
63gTBE0Zz/lqVenlTOZfIryx5Waf6kfrPvlvArA9rxIFlehK2EWTz4iUi8jgGEn8
wo64tj1/mJTOluOlu1uXfcjuVPMrq/+PVfM8SSu20nyCTy83tX44BLUBCjY+V97/
jLHVtQjzBGdii15FYr3IVxGoYyBK/3fylcIhzeR4zoxEm5z6hCfYBP5AeVWNz/mp
bEsSBmrHswcxm6WNhY48rxhMsh9ufViFHREznbh9sLbKQGR9m7dT6TS+iNguuSa5
yOv0YkwlVO79jejWJx0Uir1BQZFbELpEXWSqBbJ18MirpxfuFtJ/tl5vsJOuZaCq
+lI+/tajtNDeuktrXRSsStt03hJoMAImNclo9YpVm8PF+0gmw2H5W/EdjulMenik
7PUM+4vCMvmYqysYnYu+Xg5aIQfrYFOg89XMQRpLHkxqhVkavhN5mIM5p560Dv1t
NMVloZRo0/z+Dz5OEhJnSJT9/fwxsRjJfYub3eMxZX951QZPXgM=
=Tpjf
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.