1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-07 17:18:11 +03:00

ctdb-common: Improve error handling

Factor out a failure label, which will get more use in subsequent
commits, and only set private_data when success is certain.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15451

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit d87041d896)
This commit is contained in:
Martin Schwenke 2023-08-15 10:43:57 +10:00 committed by Jule Anger
parent 794ce23b35
commit 550972627b

View File

@ -988,7 +988,6 @@ int ctdb_sys_open_capture_socket(const char *iface, void **private_data)
errbuf);
return -1;
}
*((pcap_t **)private_data) = pt;
pcap_packet_type = pcap_datalink(pt);
switch (pcap_packet_type) {
@ -1005,8 +1004,7 @@ int ctdb_sys_open_capture_socket(const char *iface, void **private_data)
#endif /* DLT_LINUX_SLL2 */
default:
DBG_ERR("Unknown pcap packet type %d\n", pcap_packet_type);
pcap_close(pt);
return -1;
goto fail;
}
fd = pcap_get_selectable_fd(pt);
@ -1014,7 +1012,12 @@ int ctdb_sys_open_capture_socket(const char *iface, void **private_data)
t,
fd);
*((pcap_t **)private_data) = pt;
return fd;
fail:
pcap_close(pt);
return -1;
}
int ctdb_sys_close_capture_socket(void *private_data)