diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-11-22 17:13:36 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-12-15 17:51:45 +0100 |
commit | 2865507008a407dcf0d8116349978ea185457647 (patch) | |
tree | 703cfe8d3666a4186f1df4f1f18ea46b04a14f69 /src/systemctl/systemctl-edit.c | |
parent | systemctl: simplify trim_edit_markers() (diff) | |
download | systemd-2865507008a407dcf0d8116349978ea185457647.tar.xz systemd-2865507008a407dcf0d8116349978ea185457647.zip |
systemctl: minor modernizations/simplifications
Diffstat (limited to 'src/systemctl/systemctl-edit.c')
-rw-r--r-- | src/systemctl/systemctl-edit.c | 13 |
1 files 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.", |