Mailing List Archive

Re: [exim-announce] Exim 4.95-RC2 released
Hi,

While compiling 4.95-RC2 I'm still seeing the following warnings emitted :-

cc filter.c
filter.c: In function 'interpret_commands':
filter.c:2018:23: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
2018 | else headers_charset = s; /*XXX loses track of const */
| ^
filter.c:2042:12: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
2042 | fmsg = expargs[0]; /*XXX loses track of const */
| ^
filter.c:2129:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
2129 | if (i != mailarg_index_text) for (p = s; *p != 0; p++)
| ^
filter.c:2179:24: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
2179 | commands->args[i].u = s; /*XXX loses track of const */
| ^
cc filtertest.c


I'm compiling using gcc on Alpine Linux :-

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/9.3.0/lto-wrapper
Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-9.3.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 9.3.0' --enable-checking=release
--disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-default-ssp --enable-cloog-backend --enable-languages=c,c++,d,objc,fortran,ada --disable-libssp --disable-libmpx --disable-libmudflap
--disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-system-zlib --with-linker-hash-style=gnu
Thread model: posix
gcc version 9.3.0 (Alpine 9.3.0)

I modified the relevant lines in filter.c to cast the RHS :-

2018c2018
< else headers_charset = (uschar *) s; /*XXX loses track of const */
---
> else headers_charset = s; /*XXX loses track of const */
2042c2042
< fmsg = (uschar *) (expargs[0]); /*XXX loses track of const */
---
> fmsg = expargs[0]; /*XXX loses track of const */
2129c2129
< if (i != mailarg_index_text) for (p = (uschar *) s; *p != 0; p++)
---
> if (i != mailarg_index_text) for (p = s; *p != 0; p++)
2179c2179
< commands->args[i].u = (uschar *) s; /*XXX loses track of const */
---
> commands->args[i].u = s; /*XXX loses track of const */

(I left the comments :-) )

and the source compiles clean without warnings.

Whether this breaks big stuff is unknown - my simple tests ran ok.

Regards,



D
lists/exim/users/2021-09-08.tx exim-users
+----------------------------------------------------------------------------+
| Dave Restall, Computer Anorak, Geek, Cyclist, Radio Amateur G4FCU, Bodger |
| Mob +44 (0) 7973 831245 Skype: dave.restall Radio: G4FCU |
| email : dave@restall.net - Anti-SocialMediaist - Web : Not Ready Yet :-( |
+- QOTD ---------------------------------------------------------------------+
| "You who hate the Jews so, why did you adopt their religion?" |
| -- Friedrich Nietzsche, addressing anti-semitic |
| Christians |
+----------------------------------------------------------------------------+


--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: [exim-announce] Exim 4.95-RC2 released [ In reply to ]
On 08/09/2021 09:01, David Restall via Exim-users wrote:
> While compiling 4.95-RC2 I'm still seeing the following warnings emitted :-
>
> cc filter.c
> filter.c: In function 'interpret_commands':
> filter.c:2018:23: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
> 2018 | else headers_charset = s; /*XXX loses track of const */

These are expected and can be ignored.

> and the source compiles clean without warnings.

Unfortunately, you've only hidden the problem.
--
Cheers,
Jeremy

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: [exim-announce] Exim 4.95-RC2 released [ In reply to ]
Hi,

> On 08/09/2021 09:01, David Restall via Exim-users wrote:
> > While compiling 4.95-RC2 I'm still seeing the following warnings emitted :-
> >
> > cc filter.c
> > filter.c: In function 'interpret_commands':
> > filter.c:2018:23: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
> > 2018 | else headers_charset = s; /*XXX loses track of const */
>
> These are expected and can be ignored.
>
> > and the source compiles clean without warnings.
>
> Unfortunately, you've only hidden the problem.

Granted (I did allude to this in the email) but what actually is the
problem that it is masking ? I didn't dig all the way through the code
and have no idea what the variables do (s ? absolutely stupid name that
_REALLY_ helps debugging for instance) & why does it need to be const :-)
) If the comments are correct and losing track of const is known about
then surely it can't be a big problem so why not just cast the result to
resolve the warning or remove the constness ? If it's a big issue, then
innocuous comments are not helpful and the problem should be resolved.
Whichever way you look at it, it's sloppy code and that should not be
dismissed with a glib response.

Regards,



D
lists/exim/users/2021-09-08.2.tx exim-users
+----------------------------------------------------------------------------+
| Dave Restall, Computer Anorak, Geek, Cyclist, Radio Amateur G4FCU, Bodger |
| Mob +44 (0) 7973 831245 Skype: dave.restall Radio: G4FCU |
| email : dave@restall.net - Anti-SocialMediaist - Web : Not Ready Yet :-( |
+- QOTD ---------------------------------------------------------------------+
| New York now leads the world's great cities in the number of people |
| around whom you shouldn't make a sudden move. |
| -- David Letterman |
+----------------------------------------------------------------------------+


> --
> Cheers,
> Jeremy
>
> --
> ## List details at https://lists.exim.org/mailman/listinfo/exim-users
> ## Exim details at http://www.exim.org/
> ## Please use the Wiki with this list - http://wiki.exim.org/
>

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: [exim-announce] Exim 4.95-RC2 released [ In reply to ]
On 08/09/2021 10:14, David Restall via Exim-users wrote:
> Granted (I did allude to this in the email) but what actually is the
> problem that it is masking ?

The problem arises from a program of constification of the Exim source.
That is, using the 'C' const qualifer to mark up variables that we think
should not be modified, so that the compiler can a) static-check that
assertion, and b) possibly generate more efficient code.

It's a long and difficult job, and still in progress. The filter modules
are particularly difficult because they were written in a different style,
and one I personally find rather abstruse. So the current boundary of
the constification effort has reached those commented points.

> I didn't dig all the way through the code
> and have no idea what the variables do (s ? absolutely stupid name that
> _REALLY_ helps debugging for instance) & why does it need to be const :-)

"s" is the project-standard name for a string pointer. It generally has
a short lifetime.

> ) If the comments are correct and losing track of const is known about
> then surely it can't be a big problem

Wrong.

> so why not just cast the result to
> resolve the warning or remove the constness ?

Because the wish is to introduce, where appropriate, const-ness.

> If it's a big issue, then
> innocuous comments are not helpful and the problem should be resolved.
> Whichever way you look at it, it's sloppy code and that should not be
> dismissed with a glib response.

Feel free to donate your time and expertise to the effort.
--
Cheers,
Jeremy

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/