From af9ae7502614741601565ba94569570363d9ac39 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 24 Mar 2022 17:15:50 +0100 Subject: [PATCH] bootspec: normalize function names/parameter lists This normalizes naming of functions operating on BootConfig objects. Let's always call them boot_config_xyz(), like our usual way to name stuff. moreover, move the BootConfig parameter to the beginning, as it's not a return value (which we typically move to the end of the parameter list), but simply an object, that even happens to be initialized already. With these changes the functions are more like our usual way to call things, and less surprises are good. --- src/boot/bootctl.c | 6 +++--- src/login/logind-dbus.c | 8 ++++---- src/shared/bootspec.c | 18 +++++++++--------- src/shared/bootspec.h | 6 +++--- src/systemctl/systemctl-start-special.c | 2 +- src/test/test-bootspec.c | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 2766c8452f4..759b3ca86a1 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -709,7 +709,7 @@ static int status_entries( SD_ID128_FORMAT_VAL(dollar_boot_partition_uuid)); printf("\n\n"); - r = boot_entries_load_config(esp_path, xbootldr_path, &config); + r = boot_config_load(&config, esp_path, xbootldr_path); if (r < 0) return r; @@ -1816,7 +1816,7 @@ static int verb_list(int argc, char *argv[], void *userdata) { /* If XBOOTLDR and ESP actually refer to the same block device, suppress XBOOTLDR, since it would find the same entries twice */ bool same = arg_esp_path && arg_xbootldr_path && devid_set_and_equal(esp_devid, xbootldr_devid); - r = boot_entries_load_config(arg_esp_path, same ? NULL : arg_xbootldr_path, &config); + r = boot_config_load(&config, arg_esp_path, same ? NULL : arg_xbootldr_path); if (r < 0) return r; @@ -1826,7 +1826,7 @@ static int verb_list(int argc, char *argv[], void *userdata) { else if (r < 0) log_warning_errno(r, "Failed to determine entries reported by boot loader, ignoring: %m"); else - (void) boot_entries_augment_from_loader(&config, efi_entries, /* only_auto= */ false); + (void) boot_config_augment_from_loader(&config, efi_entries, /* only_auto= */ false); r = boot_config_select_special_entries(&config); if (r < 0) diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 04a72bd9b31..1212a1ac537 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -3008,13 +3008,13 @@ static int boot_loader_entry_exists(Manager *m, const char *id) { assert(m); assert(id); - r = boot_entries_load_config_auto(NULL, NULL, &config); + r = boot_config_load_auto(&config, NULL, NULL); if (r < 0 && r != -ENOKEY) /* don't complain if no GPT is found, hence skip ENOKEY */ return r; r = manager_read_efi_boot_loader_entries(m); if (r >= 0) - (void) boot_entries_augment_from_loader(&config, m->efi_boot_loader_entries, /* auto_only= */ true); + (void) boot_config_augment_from_loader(&config, m->efi_boot_loader_entries, /* auto_only= */ true); return !!boot_config_find_entry(&config, id); } @@ -3166,13 +3166,13 @@ static int property_get_boot_loader_entries( assert(reply); assert(m); - r = boot_entries_load_config_auto(NULL, NULL, &config); + r = boot_config_load_auto(&config, NULL, NULL); if (r < 0 && r != -ENOKEY) /* don't complain if there's no GPT found */ return r; r = manager_read_efi_boot_loader_entries(m); if (r >= 0) - (void) boot_entries_augment_from_loader(&config, m->efi_boot_loader_entries, /* auto_only= */ true); + (void) boot_config_augment_from_loader(&config, m->efi_boot_loader_entries, /* auto_only= */ true); r = sd_bus_message_open_container(reply, 'a', "s"); if (r < 0) diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index fd08e22bf9b..7016f3840e1 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -834,10 +834,10 @@ int boot_config_select_special_entries(BootConfig *config) { return 0; } -int boot_entries_load_config( +int boot_config_load( + BootConfig *config, const char *esp_path, - const char *xbootldr_path, - BootConfig *config) { + const char *xbootldr_path) { const char *p; int r; @@ -882,10 +882,10 @@ int boot_entries_load_config( return 0; } -int boot_entries_load_config_auto( +int boot_config_load_auto( + BootConfig *config, const char *override_esp_path, - const char *override_xbootldr_path, - BootConfig *config) { + const char *override_xbootldr_path) { _cleanup_free_ char *esp_where = NULL, *xbootldr_where = NULL; dev_t esp_devid = 0, xbootldr_devid = 0; @@ -902,7 +902,7 @@ int boot_entries_load_config_auto( if (!override_esp_path && !override_xbootldr_path) { if (access("/run/boot-loader-entries/", F_OK) >= 0) - return boot_entries_load_config("/run/boot-loader-entries/", NULL, config); + return boot_config_load(config, "/run/boot-loader-entries/", NULL); if (errno != ENOENT) return log_error_errno(errno, @@ -921,10 +921,10 @@ int boot_entries_load_config_auto( if (esp_where && xbootldr_where && devid_set_and_equal(esp_devid, xbootldr_devid)) xbootldr_where = mfree(xbootldr_where); - return boot_entries_load_config(esp_where, xbootldr_where, config); + return boot_config_load(config, esp_where, xbootldr_where); } -int boot_entries_augment_from_loader( +int boot_config_augment_from_loader( BootConfig *config, char **found_by_loader, bool only_auto) { diff --git a/src/shared/bootspec.h b/src/shared/bootspec.h index 02ccd90aee7..99bc5f69a49 100644 --- a/src/shared/bootspec.h +++ b/src/shared/bootspec.h @@ -83,9 +83,9 @@ static inline BootEntry* boot_config_default_entry(BootConfig *config) { void boot_config_free(BootConfig *config); -int boot_entries_load_config(const char *esp_path, const char *xbootldr_path, BootConfig *config); -int boot_entries_load_config_auto(const char *override_esp_path, const char *override_xbootldr_path, BootConfig *config); -int boot_entries_augment_from_loader(BootConfig *config, char **list, bool only_auto); +int boot_config_load(BootConfig *config, const char *esp_path, const char *xbootldr_path); +int boot_config_load_auto(BootConfig *config, const char *override_esp_path, const char *override_xbootldr_path); +int boot_config_augment_from_loader(BootConfig *config, char **list, bool only_auto); int boot_config_select_special_entries(BootConfig *config); diff --git a/src/systemctl/systemctl-start-special.c b/src/systemctl/systemctl-start-special.c index 6b41f4f298f..7a6cef3c5e4 100644 --- a/src/systemctl/systemctl-start-special.c +++ b/src/systemctl/systemctl-start-special.c @@ -32,7 +32,7 @@ static int load_kexec_kernel(void) { if (access(KEXEC, X_OK) < 0) return log_error_errno(errno, KEXEC" is not available: %m"); - r = boot_entries_load_config_auto(NULL, NULL, &config); + r = boot_config_load_auto(&config, NULL, NULL); if (r == -ENOKEY) /* The call doesn't log about ENOKEY, let's do so here. */ return log_error_errno(r, diff --git a/src/test/test-bootspec.c b/src/test/test-bootspec.c index f52b53c5f8a..46acd60e0d6 100644 --- a/src/test/test-bootspec.c +++ b/src/test/test-bootspec.c @@ -74,7 +74,7 @@ TEST_RET(bootspec_sort) { assert_se(write_string_file(j, entries[i].contents, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_MKDIR_0755) >= 0); } - assert_se(boot_entries_load_config(d, NULL, &config) >= 0); + assert_se(boot_config_load(&config, d, NULL) >= 0); assert_se(config.n_entries == 6); -- 2.47.3