1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-12 09:17:44 +03:00

network: do not remove LLDP state file on failure

This commit is contained in:
Yu Watanabe 2021-03-03 16:42:18 +09:00
parent 5288861bf6
commit 66d2330265

View File

@ -135,7 +135,7 @@ int link_update_lldp(Link *link) {
}
int link_lldp_save(Link *link) {
_cleanup_free_ char *temp_path = NULL;
_cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
sd_lldp_neighbor **l = NULL;
int n = 0, r, i;
@ -150,10 +150,10 @@ int link_lldp_save(Link *link) {
r = sd_lldp_get_neighbors(link->lldp, &l);
if (r < 0)
goto finish;
return r;
if (r == 0) {
(void) unlink(link->lldp_file);
goto finish;
return 0;
}
n = r;
@ -187,13 +187,8 @@ int link_lldp_save(Link *link) {
goto finish;
finish:
if (r < 0) {
(void) unlink(link->lldp_file);
if (temp_path)
(void) unlink(temp_path);
if (r < 0)
log_link_error_errno(link, r, "Failed to save LLDP data to %s: %m", link->lldp_file);
}
if (l) {
for (i = 0; i < n; i++)