chiark / gitweb /
systemctl: let's make use of FOREACH_STRING() where we can
authorLennart Poettering <lennart@poettering.net>
Wed, 18 Feb 2015 17:27:32 +0000 (18:27 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 18 Feb 2015 17:56:27 +0000 (18:56 +0100)
src/shared/log.h
src/systemctl/systemctl.c

index 2889e1e77fcd65cfd31526001db2c2f80e22f536..b323b2f7d42bc8b011afae24073b8d3f9709e9ac 100644 (file)
@@ -156,12 +156,12 @@ void log_assert_failed_return(
                 const char *func);
 
 /* Logging with level */
-#define log_full_errno(level, error, ...)                                         \
-        ({                                                                        \
-                int _l = (level), _e = (error);                                   \
-                (log_get_max_level() >= LOG_PRI(_l))                              \
-                ? log_internal(_l, _e, __FILE__, __LINE__, __func__, __VA_ARGS__) \
-                : -abs(_e); \
+#define log_full_errno(level, error, ...)                               \
+        ({                                                              \
+                int _level = (level), _e = (error);                     \
+                (log_get_max_level() >= LOG_PRI(_level))                \
+                        ? log_internal(_level, _e, __FILE__, __LINE__, __func__, __VA_ARGS__) \
+                        : -abs(_e);                                     \
         })
 
 #define log_full(level, ...) log_full_errno(level, 0, __VA_ARGS__)
index 21cb898b9af66042085edbe4ce4160c8f27b8dd6..773b4ccd87f19e139023adf2a00bbfe2086c7bf8 100644 (file)
@@ -5771,7 +5771,6 @@ static int get_file_to_edit(const char *name, const char *user_home, const char
         return 0;
 }
 
-
 static int unit_file_create_dropin(const char *unit_name, const char *user_home, const char *user_runtime, char **ret_new_path, char **ret_tmp_path) {
         char *tmp_new_path, *ending;
         char *tmp_tmp_path;
@@ -5798,12 +5797,14 @@ static int unit_file_create_dropin(const char *unit_name, const char *user_home,
         return 0;
 }
 
-static int unit_file_create_copy(const char *unit_name,
-                                 const char *fragment_path,
-                                 const char *user_home,
-                                 const char *user_runtime,
-                                 char **ret_new_path,
-                                 char **ret_tmp_path) {
+static int unit_file_create_copy(
+                const char *unit_name,
+                const char *fragment_path,
+                const char *user_home,
+                const char *user_runtime,
+                char **ret_new_path,
+                char **ret_tmp_path) {
+
         char *tmp_new_path;
         char *tmp_tmp_path;
         int r;
@@ -5859,9 +5860,8 @@ static int run_editor(char **paths) {
 
         if (pid == 0) {
                 const char **args;
-                char **backup_editors = STRV_MAKE("nano", "vim", "vi");
                 char *editor;
-                char **tmp_path, **original_path, **p;
+                char **tmp_path, **original_path, *p;
                 unsigned i = 1;
                 size_t argc;
 
@@ -5890,9 +5890,9 @@ static int run_editor(char **paths) {
                         execvp(editor, (char* const*) args);
                 }
 
-                STRV_FOREACH(p, backup_editors) {
-                        args[0] = *p;
-                        execvp(*p, (char* const*) args);
+                FOREACH_STRING(p, "nano", "vim", "vi") {
+                        args[0] = p;
+                        execvp(p, (char* const*) args);
                         /* We do not fail if the editor doesn't exist
                          * because we want to try each one of them before
                          * failing.
@@ -5903,7 +5903,7 @@ static int run_editor(char **paths) {
                         }
                 }
 
-                log_error("Cannot edit unit(s), no editor available. Please set either $SYSTEMD_EDITOR or $EDITOR or $VISUAL.");
+                log_error("Cannot edit unit(s), no editor available. Please set either $SYSTEMD_EDITOR, $EDITOR or $VISUAL.");
                 _exit(EXIT_FAILURE);
         }