mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
systemctl: let's make use of FOREACH_STRING() where we can
This commit is contained in:
parent
1d22e9068c
commit
1cfa9a4cbb
@ -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__)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user