mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-11 00:30:23 +01:00
probe: unconditionally pass ownership of message in n_dhcp4_client_probe_dispatch_io()
It is error prone when a function consumes an input only in certain cases (and telling the caller via the return code). At least in these cases, the message is never used afterwards, and we can always pass it on.
This commit is contained in:
parent
499b0785d8
commit
ce5c8db175
1 changed files with 11 additions and 13 deletions
|
|
@ -800,7 +800,8 @@ static int n_dhcp4_client_probe_transition_lifetime(NDhcp4ClientProbe *probe) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int n_dhcp4_client_probe_transition_offer(NDhcp4ClientProbe *probe, NDhcp4Incoming *message) {
|
||||
static int n_dhcp4_client_probe_transition_offer(NDhcp4ClientProbe *probe, NDhcp4Incoming *message_take) {
|
||||
_c_cleanup_(n_dhcp4_incoming_freep) NDhcp4Incoming *message = message_take;
|
||||
_c_cleanup_(n_dhcp4_client_lease_unrefp) NDhcp4ClientLease *lease = NULL;
|
||||
NDhcp4CEventNode *node;
|
||||
int r;
|
||||
|
|
@ -818,7 +819,7 @@ static int n_dhcp4_client_probe_transition_offer(NDhcp4ClientProbe *probe, NDhcp
|
|||
if (r)
|
||||
return r;
|
||||
|
||||
/* message consumed, do not fail */
|
||||
message = NULL; /* consumed */
|
||||
|
||||
n_dhcp4_client_lease_link(lease, probe);
|
||||
|
||||
|
|
@ -836,15 +837,15 @@ static int n_dhcp4_client_probe_transition_offer(NDhcp4ClientProbe *probe, NDhcp
|
|||
case N_DHCP4_CLIENT_PROBE_STATE_REBINDING:
|
||||
case N_DHCP4_CLIENT_PROBE_STATE_EXPIRED:
|
||||
default:
|
||||
/* ignore, but consume message. */
|
||||
n_dhcp4_incoming_free(message);
|
||||
/* ignore */
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int n_dhcp4_client_probe_transition_ack(NDhcp4ClientProbe *probe, NDhcp4Incoming *message) {
|
||||
static int n_dhcp4_client_probe_transition_ack(NDhcp4ClientProbe *probe, NDhcp4Incoming *message_take) {
|
||||
_c_cleanup_(n_dhcp4_incoming_freep) NDhcp4Incoming *message = message_take;
|
||||
_c_cleanup_(n_dhcp4_client_lease_unrefp) NDhcp4ClientLease *lease = NULL;
|
||||
NDhcp4CEventNode *node;
|
||||
int r;
|
||||
|
|
@ -863,7 +864,7 @@ static int n_dhcp4_client_probe_transition_ack(NDhcp4ClientProbe *probe, NDhcp4I
|
|||
if (r)
|
||||
return r;
|
||||
|
||||
/* message consumed, do not fail */
|
||||
message = NULL; /* consumed */
|
||||
|
||||
n_dhcp4_client_lease_link(lease, probe);
|
||||
|
||||
|
|
@ -886,7 +887,7 @@ static int n_dhcp4_client_probe_transition_ack(NDhcp4ClientProbe *probe, NDhcp4I
|
|||
if (r)
|
||||
return r;
|
||||
|
||||
/* message consumed, do not fail */
|
||||
message = NULL; /* consumed */
|
||||
|
||||
n_dhcp4_client_lease_link(lease, probe);
|
||||
|
||||
|
|
@ -904,8 +905,7 @@ static int n_dhcp4_client_probe_transition_ack(NDhcp4ClientProbe *probe, NDhcp4I
|
|||
case N_DHCP4_CLIENT_PROBE_STATE_GRANTED:
|
||||
case N_DHCP4_CLIENT_PROBE_STATE_EXPIRED:
|
||||
default:
|
||||
/* ignore, but consume message. */
|
||||
n_dhcp4_incoming_free(message);
|
||||
/* ignore */
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1169,17 +1169,15 @@ int n_dhcp4_client_probe_dispatch_io(NDhcp4ClientProbe *probe, uint32_t events)
|
|||
switch (type) {
|
||||
case N_DHCP4_MESSAGE_OFFER:
|
||||
r = n_dhcp4_client_probe_transition_offer(probe, message);
|
||||
message = NULL; /* consumed */
|
||||
if (r)
|
||||
return r;
|
||||
else
|
||||
message = NULL; /* consumed */
|
||||
break;
|
||||
case N_DHCP4_MESSAGE_ACK:
|
||||
r = n_dhcp4_client_probe_transition_ack(probe, message);
|
||||
message = NULL; /* consumed */
|
||||
if (r)
|
||||
return r;
|
||||
else
|
||||
message = NULL; /* consumed */
|
||||
break;
|
||||
case N_DHCP4_MESSAGE_NAK:
|
||||
r = n_dhcp4_client_probe_transition_nak(probe);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue