From b364c4de6289003e5f431f865a0ded73f44f6f29 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 14 Oct 2022 11:12:19 +0200 Subject: [PATCH] install: include full type name in special UnitFilePresetMode values Typically the _MAX and _INVALID special enum values use the full type as prefix, even if the actual values of the enum might not. Let's follow this rule here too. --- src/shared/install.c | 6 +++--- src/shared/install.h | 4 ++-- src/systemctl/systemctl.c | 2 +- src/test/test-tables.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/shared/install.c b/src/shared/install.c index 43aa865b0ea..53b5aefbe6c 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -3471,7 +3471,7 @@ int unit_file_preset( assert(scope >= 0); assert(scope < _LOOKUP_SCOPE_MAX); - assert(mode < _UNIT_FILE_PRESET_MAX); + assert(mode < _UNIT_FILE_PRESET_MODE_MAX); r = lookup_paths_init(&lp, scope, 0, root_dir); if (r < 0) @@ -3510,7 +3510,7 @@ int unit_file_preset_all( assert(scope >= 0); assert(scope < _LOOKUP_SCOPE_MAX); - assert(mode < _UNIT_FILE_PRESET_MAX); + assert(mode < _UNIT_FILE_PRESET_MODE_MAX); r = lookup_paths_init(&lp, scope, 0, root_dir); if (r < 0) @@ -3674,7 +3674,7 @@ static const char* const install_change_type_table[_INSTALL_CHANGE_TYPE_MAX] = { DEFINE_STRING_TABLE_LOOKUP(install_change_type, InstallChangeType); -static const char* const unit_file_preset_mode_table[_UNIT_FILE_PRESET_MAX] = { +static const char* const unit_file_preset_mode_table[_UNIT_FILE_PRESET_MODE_MAX] = { [UNIT_FILE_PRESET_FULL] = "full", [UNIT_FILE_PRESET_ENABLE_ONLY] = "enable-only", [UNIT_FILE_PRESET_DISABLE_ONLY] = "disable-only", diff --git a/src/shared/install.h b/src/shared/install.h index 302b52733a4..d13b143e4eb 100644 --- a/src/shared/install.h +++ b/src/shared/install.h @@ -22,8 +22,8 @@ enum UnitFilePresetMode { UNIT_FILE_PRESET_FULL, UNIT_FILE_PRESET_ENABLE_ONLY, UNIT_FILE_PRESET_DISABLE_ONLY, - _UNIT_FILE_PRESET_MAX, - _UNIT_FILE_PRESET_INVALID = -EINVAL, + _UNIT_FILE_PRESET_MODE_MAX, + _UNIT_FILE_PRESET_MODE_INVALID = -EINVAL, }; enum InstallChangeType { diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 430f59d4963..5858c3f6d34 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -838,7 +838,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) { case ARG_PRESET_MODE: if (streq(optarg, "help")) { - DUMP_STRING_TABLE(unit_file_preset_mode, UnitFilePresetMode, _UNIT_FILE_PRESET_MAX); + DUMP_STRING_TABLE(unit_file_preset_mode, UnitFilePresetMode, _UNIT_FILE_PRESET_MODE_MAX); return 0; } diff --git a/src/test/test-tables.c b/src/test/test-tables.c index 36965b334b5..30ca1871cb9 100644 --- a/src/test/test-tables.c +++ b/src/test/test-tables.c @@ -117,7 +117,7 @@ int main(int argc, char **argv) { test_table(unit_active_state, UNIT_ACTIVE_STATE); test_table(unit_dependency, UNIT_DEPENDENCY); test_table(install_change_type, INSTALL_CHANGE_TYPE); - test_table(unit_file_preset_mode, UNIT_FILE_PRESET); + test_table(unit_file_preset_mode, UNIT_FILE_PRESET_MODE); test_table(unit_file_state, UNIT_FILE_STATE); test_table(unit_load_state, UNIT_LOAD_STATE); test_table(unit_type, UNIT_TYPE); -- 2.47.3