1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-11 05:17:44 +03:00

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.
This commit is contained in:
Lennart Poettering 2022-03-24 17:15:50 +01:00
parent 3f8e42c038
commit af9ae75026
6 changed files with 21 additions and 21 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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) {

View File

@ -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);

View File

@ -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,

View File

@ -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);