summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-link.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-02-22 23:13:31 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-02-23 10:10:48 +0900
commit70f1280c83ce4cc9f11fa99f1386cdf621e70ee4 (patch)
tree327acb1e20c39d4e7daa3daaf11fe34d4efb42b5 /src/resolve/resolved-link.c
parenta90d9ee1620ce65ecf07224f2d2d16f9f5c48ca9 (diff)
downloadsystemd-70f1280c83ce4cc9f11fa99f1386cdf621e70ee4.tar.gz
tree-wide: use unlink_and_freep() moreover
Diffstat (limited to 'src/resolve/resolved-link.c')
-rw-r--r--src/resolve/resolved-link.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c
index d41f6f3e54..70e726e417 100644
--- a/src/resolve/resolved-link.c
+++ b/src/resolve/resolved-link.c
@@ -9,6 +9,7 @@
#include "env-file.h"
#include "fd-util.h"
#include "fileio.h"
+#include "fs-util.h"
#include "log-link.h"
#include "mkdir.h"
#include "netif-util.h"
@@ -1175,7 +1176,7 @@ static bool link_needs_save(Link *l) {
}
int link_save_user(Link *l) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
const char *v;
int r;
@@ -1277,14 +1278,13 @@ int link_save_user(Link *l) {
goto fail;
}
+ temp_path = mfree(temp_path);
+
return 0;
fail:
(void) unlink(l->state_file);
- if (temp_path)
- (void) unlink(temp_path);
-
return log_link_error_errno(l, r, "Failed to save link data %s: %m", l->state_file);
}