]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootspec: normalize function names/parameter lists 22843/head
authorLennart Poettering <lennart@poettering.net>
Thu, 24 Mar 2022 16:15:50 +0000 (17:15 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 28 Mar 2022 14:02:15 +0000 (16:02 +0200)
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
src/login/logind-dbus.c
src/shared/bootspec.c
src/shared/bootspec.h
src/systemctl/systemctl-start-special.c
src/test/test-bootspec.c

index 2766c8452f4831d779a2f86b37a5cf3993758de5..759b3ca86a1b699f24fbbd8d6c93352b353e2d08 100644 (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)
index 04a72bd9b31744f07fc4c29948b22969fe4be2fd..1212a1ac537c4840c622ddd25424fd1f94ae1558 100644 (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)
index fd08e22bf9bb35763b159967c5ade50949c45c01..7016f3840e138defd3a2423553779ab38dbdb78a 100644 (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) {
index 02ccd90aee73808f1d5a1999d2eda8f639485ce0..99bc5f69a4916886547c867e94c4469d3de5792e 100644 (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);
 
index 6b41f4f298fc37be19956af59cc6349b30ff34eb..7a6cef3c5e45e7e85ef0d8a2e8d44012efa81ede 100644 (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,
index f52b53c5f8ad6320f755daf5742fde6cda58c852..46acd60e0d69ff95efe6e67200450b42b650603a 100644 (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);