mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 09:58:07 +02:00
n-dhcp4/connection: avoid compiler warning in n_dhcp4_c_connection_connect() about fd_udp uninitialized
With LTO and optimizations enabled, we get a compiler warning about fd_udp
not initialized:
../src/n-dhcp4-c-connection.c: In function ‘n_dhcp4_c_connection_connect’:
../src/n-dhcp4-c-connection.c:196:13: error: ‘fd_udp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
196 | r = epoll_ctl(connection->fd_epoll,
| ^
../src/n-dhcp4-c-connection.c:185:16: note: ‘fd_udp’ was declared here
185 | int r, fd_udp;
| ^
6c6e936898
This commit is contained in:
parent
08318a0bac
commit
4e0e002092
1 changed files with 9 additions and 14 deletions
|
|
@ -182,7 +182,8 @@ int n_dhcp4_c_connection_listen(NDhcp4CConnection *connection) {
|
|||
int n_dhcp4_c_connection_connect(NDhcp4CConnection *connection,
|
||||
const struct in_addr *client,
|
||||
const struct in_addr *server) {
|
||||
int r, fd_udp;
|
||||
_c_cleanup_(c_closep) int fd_udp = -1;
|
||||
int r;
|
||||
|
||||
c_assert(connection->state == N_DHCP4_C_CONNECTION_STATE_PACKET);
|
||||
|
||||
|
|
@ -200,27 +201,21 @@ int n_dhcp4_c_connection_connect(NDhcp4CConnection *connection,
|
|||
.events = EPOLLIN,
|
||||
.data = { .u32 = N_DHCP4_CLIENT_EPOLL_IO },
|
||||
});
|
||||
if (r < 0) {
|
||||
r = -errno;
|
||||
goto exit_fd;
|
||||
}
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
r = packet_shutdown(connection->fd_packet);
|
||||
if (r < 0)
|
||||
goto exit_epoll;
|
||||
if (r < 0) {
|
||||
epoll_ctl(connection->fd_epoll, EPOLL_CTL_DEL, fd_udp, NULL);
|
||||
return r;
|
||||
}
|
||||
|
||||
connection->state = N_DHCP4_C_CONNECTION_STATE_DRAINING;
|
||||
connection->fd_udp = fd_udp;
|
||||
fd_udp = -1;
|
||||
connection->client_ip = client->s_addr;
|
||||
connection->server_ip = server->s_addr;
|
||||
fd_udp = -1;
|
||||
return 0;
|
||||
|
||||
exit_epoll:
|
||||
epoll_ctl(connection->fd_epoll, EPOLL_CTL_DEL, fd_udp, NULL);
|
||||
exit_fd:
|
||||
close(fd_udp);
|
||||
return r;
|
||||
}
|
||||
|
||||
void n_dhcp4_c_connection_close(NDhcp4CConnection *connection) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue