n-dhcp4: use c_errno() in packet_sendto_udp() to avoid compiler warning

With LTO enabled, the compiler might think that "len" in n_dhcp4_socket_packet_send()
might be uninitialized. That is even a correct assumption, as the compiler does not
understand the API of sendmsg() and that sendmsg() is supposed to set a positive errno.

Work around by using c_errno() in packet_sendto_udp().

    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-19 14:50:58 +01:00
parent d649a1f9cc
commit 5bdc36b392
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -223,7 +223,7 @@ int packet_sendto_udp(int sockfd,
pktlen = sendmsg(sockfd, &msg, 0);
if (pktlen < 0)
return -errno;
return -c_errno();
/*
* Kernel never truncates. Worst case, we get -EMSGSIZE. Kernel *might*