[Privoxy-devel] filters.c: warning: 'xxx' may be used uninitialized in this function [-Wmaybe-uninitialized]
Lee
ler762 at gmail.com
Thu Jun 1 14:03:05 UTC 2017
before I go making changes to get rid of compiler warnings, is there
really a problem with variables being uninitialized in filters.c? I
can't tell :(
----------- warnings
i686-w64-mingw32-gcc -c -pipe -O2 -DWINVER=0x501 -mwindows -Wall
-Ipcre filters.c -o filters.o
filters.c: In function 'match_sockaddr':
filters.c:214:42: warning: 'address_port' may be used uninitialized in
this function [-Wmaybe-uninitialized]
if (*netmask_port && *network_port != *address_port)
^
filters.c:180:43: warning: 'address_addr' may be used uninitialized in
this function [-Wmaybe-uninitialized]
uint8_t *network_addr, *netmask_addr, *address_addr;
^
filters.c:214:8: warning: 'netmask_port' may be used uninitialized in
this function [-Wmaybe-uninitialized]
if (*netmask_port && *network_port != *address_port)
^
filters.c:209:20: warning: 'netmask_addr' may be used uninitialized in
this function [-Wmaybe-uninitialized]
netmask_addr += 12;
^
filters.c:214:25: warning: 'network_port' may be used uninitialized in
this function [-Wmaybe-uninitialized]
if (*netmask_port && *network_port != *address_port)
^
filters.c:181:17: warning: 'addr_len' may be used uninitialized in
this function [-Wmaybe-uninitialized]
unsigned int addr_len;
^
filters.c:180:13: warning: 'network_addr' may be used uninitialized in
this function [-Wmaybe-uninitialized]
uint8_t *network_addr, *netmask_addr, *address_addr;
^
------------------------ fix
Index: current/filters.c
===================================================================
RCS file: /cvsroot/ijbswa/current/filters.c,v
retrieving revision 1.204
diff -U5 -d -r1.204 filters.c
--- current/filters.c 8 Mar 2017 13:13:18 -0000 1.204
+++ current/filters.c 1 Jun 2017 13:55:45 -0000
@@ -175,13 +175,13 @@
*********************************************************************/
static int match_sockaddr(const struct sockaddr_storage *network,
const struct sockaddr_storage *netmask,
const struct sockaddr_storage *address)
{
- uint8_t *network_addr, *netmask_addr, *address_addr;
- unsigned int addr_len;
- in_port_t *network_port, *netmask_port, *address_port;
+ uint8_t *network_addr = NULL, *netmask_addr = NULL, *address_addr = NULL;
+ unsigned int addr_len = 0;
+ in_port_t *network_port = NULL, *netmask_port = NULL, *address_port = NULL;
int i;
if (network->ss_family != netmask->ss_family)
{
/* This should never happen */
Regards,
Lee
More information about the Privoxy-devel
mailing list