summaryrefslogtreecommitdiff
path: root/src/systemctl/systemctl-edit.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-03-23 10:48:13 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-03-23 11:50:18 +0100
commit5980d463048f25411c55da2f6387cdc8eaeef4c8 (patch)
treee5c32417015bfd67d326d278b1cd7dac3ada39de /src/systemctl/systemctl-edit.c
parent5b391395822575533ab0fc93485fc5554d0da099 (diff)
downloadsystemd-5980d463048f25411c55da2f6387cdc8eaeef4c8.tar.gz
strv: declare iterator of FOREACH_STRING() in the loop
Same idea as 03677889f0ef42cdc534bf3b31265a054b20a354. No functional change intended. The type of the iterator is generally changed to be 'const char*' instead of 'char*'. Despite the type commonly used, modifying the string was not allowed. I adjusted the naming of some short variables for clarity and reduced the scope of some variable declarations in code that was being touched anyway.
Diffstat (limited to 'src/systemctl/systemctl-edit.c')
-rw-r--r--src/systemctl/systemctl-edit.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/systemctl/systemctl-edit.c b/src/systemctl/systemctl-edit.c
index e18a32190f..e24cfb2f45 100644
--- a/src/systemctl/systemctl-edit.c
+++ b/src/systemctl/systemctl-edit.c
@@ -318,7 +318,7 @@ static int run_editor(char **paths) {
if (r == 0) {
char **editor_args = NULL;
size_t n_editor_args = 0, i = 1, argc;
- const char **args, *editor, *p;
+ const char **args, *editor;
argc = strv_length(paths)/2 + 1;
@@ -356,9 +356,9 @@ static int run_editor(char **paths) {
if (n_editor_args > 0)
execvp(args[0], (char* const*) args);
- FOREACH_STRING(p, "editor", "nano", "vim", "vi") {
- args[0] = p;
- execvp(p, (char* const*) args);
+ FOREACH_STRING(name, "editor", "nano", "vim", "vi") {
+ args[0] = name;
+ execvp(name, (char* const*) args);
/* We do not fail if the editor doesn't exist because we want to try each one of them
* before failing. */
if (errno != ENOENT) {