From 2865507008a407dcf0d8116349978ea185457647 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 22 Nov 2022 17:13:36 +0100 Subject: [PATCH] systemctl: minor modernizations/simplifications --- src/systemctl/systemctl-edit.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/systemctl/systemctl-edit.c b/src/systemctl/systemctl-edit.c index 8a424c9f68..7d919b28e2 100644 --- a/src/systemctl/systemctl-edit.c +++ b/src/systemctl/systemctl-edit.c @@ -110,7 +110,12 @@ int verb_cat(int argc, char *argv[], void *userdata) { return rc; } -static int create_edit_temp_file(const char *new_path, const char *original_path, char ** const original_unit_paths, char **ret_tmp_fn) { +static int create_edit_temp_file( + const char *new_path, + const char *original_path, + char ** const original_unit_paths, + char **ret_tmp_fn) { + _cleanup_free_ char *t = NULL; int r; @@ -154,8 +159,7 @@ static int create_edit_temp_file(const char *new_path, const char *original_path if (!f) return log_error_errno(errno, "Failed to open \"%s\": %m", t); - r = fchmod(fileno(f), 0644); - if (r < 0) + if (fchmod(fileno(f), 0644) < 0) return log_error_errno(errno, "Failed to change mode of \"%s\": %m", t); r = read_full_file(new_path, &new_contents, NULL); @@ -200,7 +204,6 @@ static int create_edit_temp_file(const char *new_path, const char *original_path } *ret_tmp_fn = TAKE_PTR(t); - return 0; } @@ -222,9 +225,7 @@ static int get_file_to_edit( run = path_join(paths->runtime_config, name); if (!run) return log_oom(); - } - if (arg_runtime) { if (access(path, F_OK) >= 0) return log_error_errno(SYNTHETIC_ERRNO(EEXIST), "Refusing to create \"%s\" because it would be overridden by \"%s\" anyway.", -- 2.25.1