diff options
author | Mike Yuan <me@yhndnzj.com> | 2023-03-11 22:52:39 +0800 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2023-03-13 00:40:15 +0800 |
commit | 8992667fefe2f06fcf83181ffac8a71d0b5f03eb (patch) | |
tree | b72e9de816829a24ffa93de88c74fc875558e1b0 /src | |
parent | 7d28e496e827ef5f118251b61a8548c05bb1f837 (diff) | |
download | systemd-8992667fefe2f06fcf83181ffac8a71d0b5f03eb.tar.gz |
edit-util: minor cleanups
Reuse unlink_and_free() and avoid unnecessary
call to rmdir()
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/edit-util.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/shared/edit-util.c b/src/shared/edit-util.c index ba1f4128a0..734c06601b 100644 --- a/src/shared/edit-util.c +++ b/src/shared/edit-util.c @@ -24,10 +24,7 @@ void edit_file_context_done(EditFileContext *context) { assert(context); FOREACH_ARRAY(i, context->files, context->n_files) { - if (i->temp) { - (void) unlink(i->temp); - free(i->temp); - } + unlink_and_free(i->temp); if (context->remove_parent) { _cleanup_free_ char *parent = NULL; @@ -35,9 +32,8 @@ void edit_file_context_done(EditFileContext *context) { r = path_extract_directory(i->path, &parent); if (r < 0) log_debug_errno(r, "Failed to extract directory from '%s', ignoring: %m", i->path); - - /* No need to check if the dir is empty, rmdir does nothing if it is not the case. */ - (void) rmdir(parent); + else /* No need to check if the dir is empty, rmdir does nothing if it is not the case. */ + (void) rmdir(parent); } free(i->path); |