n-dhcp4: work around compiler warning in n_dhcp4_socket_packet_send()

With LTO enabled, the compiler might think that "len" is not initialized.
That is even a correct assumption, if the compiler does not understand the
API of sendmsg() and that sendmsg() is supposed to set a negative errno.

Work around by initializing the variable.

    shared/n-dhcp4/src/n-dhcp4-c-connection.c: In function n_dhcp4_c_connection_send_request:
    shared/n-dhcp4/src/n-dhcp4-socket.c:368:19: error: len may be used uninitialized in this function [-Werror=maybe-uninitialized]
             } else if (len != n_buf) {
                       ^
    shared/n-dhcp4/src/n-dhcp4-socket.c:351:23: note: len was declared here
             size_t n_buf, len;
                           ^
This commit is contained in:
Thomas Haller 2021-01-11 18:14:37 +01:00
parent 040c86f15c
commit 4686e9baef
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -348,7 +348,8 @@ static int n_dhcp4_socket_packet_send(int sockfd,
.sll_halen = halen,
};
const void *buf;
size_t n_buf, len;
size_t n_buf;
size_t len = 0;
int r;
c_assert(halen <= sizeof(haddr.sll_addr));