Re: Minor cleanup after adding more warnings to CFLAGS

"Kevin J. McCarthy" <[email protected]>
Newsgroups gmane.mail.mutt.devel
Message-ID <acnY4RwPeffcqfT6@qinghai>
On Sun, Mar 29, 2026 at 05:36:52PM +0200, Rene Kita wrote:
>Below is the shortened build log with the remaining errors after my 9
>patches were applied. Adding more const to avoid these errors leads to
>more errors somewhere else in the call chain. There are other errors
>which come from -Wtype-limits and -Wredundant-decls.

I'll take a closer look at these later today when I have more time.

>Most prominent example is imap_next_word which is called in a lot of
>functions taking const char * as an parameter. We do cast away the const
>there. imap_next_word does not modify the string, but will return the
>string in the end. This means if we let imap_next_word take a const
>char * we also need to return a const char *. But this does not work
>everywhere it is used.
>
>What is the general opinion here regarding such compiler flags and how
>to handle such situations?

The imap_next_word() is traversing a mutable stream of characters. 
Several places modify that stream as they "parse" the IMAP results.  So 
changing imap_next_word() argument/return type would just make thing 
even more complicated.

The problem are the various helper functions, like imap_cmd_trailer(), 
cmd_status(), cmd_parse_myrights(), cmd_parse_search(), 
cmd_parse_enabled().  Yes, they aren't modifying the char* and are 
trying to be helpful by noting that.  But it gets complicated when they
intertwine with imap_next_word().

I have to confess I'm not proficient with the sharp edges of const 
usage.  If we want to remove the warnings (and I'd love to hear others' 
opinions about this), then I would vote for removing the const from 
those helper functions.

-- 
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-----

iQIzBAEBCgAdFiEEiXWpszqjeRA4XFMIre92hIAxa9oFAmnJ2OEACgkQre92hIAx
a9qNPhAA5V5gInQeZlcjmTPMBfFsqoAFs5BYvUpY4Iiu7Q6wYZnU7dgG9m7QX41Y
wM9wa1AKmsVqd6XPS9cVG9Ta+fmC0tqVo8TPA0/kQpTcZzWOS/kfjiOibRkrQo5V
uUIPSAOczzBmIJhzWmIghLuY2fN3GMX6b+zi+ZVILjPqvgy3yR25oGZ7ao9+d0N4
eHpxpw8/K2SXmCEzB+7ko8l1CBtpEGa+FtywlyX4vJVrjotmffk94TQ6jp0QrEOv
myLb3Uo3BSLiwlGIloKLHWCZh6ZNB/KDcdZc7+NJnRoKLC8soSgomxaFlFAh4KZB
nn6xW/ULjSvDeYTwMNcTk0wnOX0no+qCJZqh0iqZbCE7NMJijXs2QJJQ4mLhLjUB
AVXsZfbK1hdnJyxTPG4+YEett47opZ7KPFUN8/GV1jIU8lWziNjGsUTb32xIHh8v
ylT8lbptmp+t94Wr/yYVWhZG25z4bNRjTplGUFIRovlhM9a9Zz+oiWZ44VySywns
gBgmRCXSrocCoaFuEIyFE/uYSog7gMIDjCDGxLLYp46u/8DxPmTLrUYaJNW2ffNI
oG9wDIouf8x0t/d1hFmxJHC+aaFi0ZaNdcbKvuwhRvDTxhbqtsMzJHdREcH6z4r0
bG9p5p+i3hDT2AxDVzfCWiC+LJLS/kwFCg/+hdUPk6B6IqMoCXI=
=I89r
-----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.