[Privoxy-devel] 0003-fix-maybe-uninitialized-compiler-warnings

Fabian Keil fk at fabiankeil.de
Wed Aug 9 07:08:17 CEST 2023


Fabian Keil <fk at fabiankeil.de> wrote on 2023-08-04 at 09:01:52:

> Lee <ler762 at protonmail.com> wrote on 2023-08-03 at 15:39:01:
> 
> > Empty Message
> 
> I intend to review this and your other patches
> next week after the FrOSCon [0] weekend.
> 
> I briefly tried to reproduce the warnings but it looks like
> clang 15.0.7 does not support '-Wmaybe-uninitialized':
> 
> | warning: unknown warning option '-Wmaybe-uninitialized'; did you mean '-Wuninitialized'? [-Wunknown-warning-option]

I was concerned that the patch would trigger "dead store"
warnings in other compilers but at least for clang 15.0.7
this doesn't seem to be the case.

I think the warning is a false positive but of course
silencing the warnings doesn't hurt.

Please initialise the variables separately from the
declaration block and set the pointers to NULL instead
of 0.

Something like:

--- a/filters.c
+++ b/filters.c
@@ -173,6 +173,10 @@ static int match_sockaddr(const struct sockaddr_storage *network,
    in_port_t *network_port, *netmask_port, *address_port;
    int i;
 
+   network_addr = NULL;
+   netmask_addr = NULL;
+   address_addr = NULL;
+
    if (network->ss_family != netmask->ss_family)
    {
       /* This should never happen */

@@ -347,6 +351,9 @@ int acl_addr(const char *aspec, struct access_control_addr *aca)
 #ifdef HAVE_RFC2553
    /* XXX: Depend on ai_family */
    masklength = 128;
+   mask_data = NULL;
+   mask_port = NULL;
+   addr_len = 0;
 #else
    masklength = 32;
    port       =  0;

While at it, please also split the patch in two
using one for each function.

Please also mention the function name and the compiler
that emits the warnings in the commit messages.

Thanks
Fabian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.privoxy.org/pipermail/privoxy-devel/attachments/20230809/64fdbde8/attachment.bin>


More information about the Privoxy-devel mailing list