From 7adbda7348f8cec071b7ba647329160a29a45df0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 30 Jun 2021 15:58:44 +0200 Subject: [PATCH] n-dhcp4: avoid maybe-uninitialized warning in n_dhcp4_c_connection_dispatch_io() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On RHEL-8.5, s390x with gcc-8.5.0-2.el8, we get a compiler warning: $ CFLAGS='-O2 -Werror=maybe-uninitialized' meson build ... cc -Isrc/libndhcp4-private.a.p -Isrc -I../src -Isubprojects/c-list/src -I../subprojects/c-list/src -Isubprojects/c-siphash/src -I../subprojects/c-siphash/src -Isubprojects/c-stdaux/src -I../subprojects/c-stdaux/src -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c11 -g -D_GNU_SOURCE -O2 -Werror=maybe-uninitialized -fPIC -fvisibility=hidden -fno-common -MD -MQ src/libndhcp4-private.a.p/n-dhcp4-c-connection.c.o -MF src/libndhcp4-private.a.p/n-dhcp4-c-connection.c.o.d -o src/libndhcp4-private.a.p/n-dhcp4-c-connection.c.o -c ../src/n-dhcp4-c-connection.c ../src/n-dhcp4-c-connection.c: In function ‘n_dhcp4_c_connection_dispatch_io’: ../src/n-dhcp4-c-connection.c:1151:17: error: ‘type’ may be used uninitialized in this function [-Werror=maybe-uninitialized] uint8_t type; ^~~~ https://github.com/nettools/n-dhcp4/pull/24 (cherry picked from commit 3a4822c52c8893e56b1506d771a1441497c8209a) --- src/n-dhcp4/src/n-dhcp4-c-connection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/n-dhcp4/src/n-dhcp4-c-connection.c b/src/n-dhcp4/src/n-dhcp4-c-connection.c index 3123525390..4aba97393d 100644 --- a/src/n-dhcp4/src/n-dhcp4-c-connection.c +++ b/src/n-dhcp4/src/n-dhcp4-c-connection.c @@ -1148,7 +1148,7 @@ int n_dhcp4_c_connection_dispatch_io(NDhcp4CConnection *connection, _c_cleanup_(n_dhcp4_incoming_freep) NDhcp4Incoming *message = NULL; char serv_addr[INET_ADDRSTRLEN]; char client_addr[INET_ADDRSTRLEN]; - uint8_t type; + uint8_t type = 0; int r; switch (connection->state) {