efivars: Remove STRINGIFY() helper macros
The names of these conflict with macros from efi.h that we'll move to efi-fundamental.h in a later commit. Let's avoid the conflict by getting rid of these helpers. Arguably this also improves readability by clearly indicating we're passing arbitrary strings and not constants to the macros when we invoke them.
This commit is contained in:
@@ -1382,19 +1382,19 @@ static int boot_load_efi_entry_pointers(BootConfig *config, bool skip_efivars) {
|
||||
|
||||
/* Loads the three "pointers" to boot loader entries from their EFI variables */
|
||||
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE(LoaderEntryOneShot), &config->entry_oneshot);
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE_STR("LoaderEntryOneShot"), &config->entry_oneshot);
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
if (r < 0 && !IN_SET(r, -ENOENT, -ENODATA))
|
||||
log_warning_errno(r, "Failed to read EFI variable \"LoaderEntryOneShot\", ignoring: %m");
|
||||
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE(LoaderEntryDefault), &config->entry_default);
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE_STR("LoaderEntryDefault"), &config->entry_default);
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
if (r < 0 && !IN_SET(r, -ENOENT, -ENODATA))
|
||||
log_warning_errno(r, "Failed to read EFI variable \"LoaderEntryDefault\", ignoring: %m");
|
||||
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE(LoaderEntrySelected), &config->entry_selected);
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE_STR("LoaderEntrySelected"), &config->entry_selected);
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
if (r < 0 && !IN_SET(r, -ENOENT, -ENODATA))
|
||||
@@ -1560,7 +1560,7 @@ int boot_config_augment_from_loader(
|
||||
break;
|
||||
}
|
||||
|
||||
p = strdup(EFIVAR_PATH(EFI_LOADER_VARIABLE(LoaderEntries)));
|
||||
p = strdup(EFIVAR_PATH(EFI_LOADER_VARIABLE_STR("LoaderEntries")));
|
||||
if (!p)
|
||||
return log_oom();
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ int efi_reboot_to_firmware_supported(void) {
|
||||
if (!is_efi_boot())
|
||||
goto not_supported;
|
||||
|
||||
r = efi_get_variable(EFI_GLOBAL_VARIABLE(OsIndicationsSupported), NULL, &v, &s);
|
||||
r = efi_get_variable(EFI_GLOBAL_VARIABLE_STR("OsIndicationsSupported"), NULL, &v, &s);
|
||||
if (r == -ENOENT)
|
||||
goto not_supported; /* variable doesn't exist? it's not supported then */
|
||||
if (r < 0)
|
||||
@@ -115,7 +115,7 @@ static int get_os_indications(uint64_t *ret) {
|
||||
return r;
|
||||
|
||||
/* stat() the EFI variable, to see if the mtime changed. If it did we need to cache again. */
|
||||
if (stat(EFIVAR_PATH(EFI_GLOBAL_VARIABLE(OsIndications)), &new_stat) < 0) {
|
||||
if (stat(EFIVAR_PATH(EFI_GLOBAL_VARIABLE_STR("OsIndications")), &new_stat) < 0) {
|
||||
if (errno != ENOENT)
|
||||
return -errno;
|
||||
|
||||
@@ -129,7 +129,7 @@ static int get_os_indications(uint64_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = efi_get_variable(EFI_GLOBAL_VARIABLE(OsIndications), NULL, &v, &s);
|
||||
r = efi_get_variable(EFI_GLOBAL_VARIABLE_STR("OsIndications"), NULL, &v, &s);
|
||||
if (r == -ENOENT) {
|
||||
/* Some firmware implementations that do support OsIndications and report that with
|
||||
* OsIndicationsSupported will remove the OsIndications variable when it is unset. Let's
|
||||
@@ -172,7 +172,7 @@ int efi_set_reboot_to_firmware(bool value) {
|
||||
|
||||
/* Avoid writing to efi vars store if we can due to firmware bugs. */
|
||||
if (b != b_new)
|
||||
return efi_set_variable(EFI_GLOBAL_VARIABLE(OsIndications), &b_new, sizeof(uint64_t));
|
||||
return efi_set_variable(EFI_GLOBAL_VARIABLE_STR("OsIndications"), &b_new, sizeof(uint64_t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -399,7 +399,7 @@ int efi_get_boot_order(uint16_t **ret_order) {
|
||||
if (!is_efi_boot())
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
r = efi_get_variable(EFI_GLOBAL_VARIABLE(BootOrder), NULL, &buf, &l);
|
||||
r = efi_get_variable(EFI_GLOBAL_VARIABLE_STR("BootOrder"), NULL, &buf, &l);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -419,7 +419,7 @@ int efi_set_boot_order(const uint16_t *order, size_t n) {
|
||||
if (!is_efi_boot())
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return efi_set_variable(EFI_GLOBAL_VARIABLE(BootOrder), order, n * sizeof(uint16_t));
|
||||
return efi_set_variable(EFI_GLOBAL_VARIABLE_STR("BootOrder"), order, n * sizeof(uint16_t));
|
||||
}
|
||||
|
||||
static int boot_id_hex(const char s[static 4]) {
|
||||
|
||||
+14
-14
@@ -43,11 +43,11 @@ int efi_loader_get_boot_usec(usec_t *ret_firmware, usec_t *ret_loader) {
|
||||
if (!is_efi_boot())
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
r = read_usec(EFI_LOADER_VARIABLE(LoaderTimeInitUSec), &x);
|
||||
r = read_usec(EFI_LOADER_VARIABLE_STR("LoaderTimeInitUSec"), &x);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to read LoaderTimeInitUSec: %m");
|
||||
|
||||
r = read_usec(EFI_LOADER_VARIABLE(LoaderTimeExecUSec), &y);
|
||||
r = read_usec(EFI_LOADER_VARIABLE_STR("LoaderTimeExecUSec"), &y);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to read LoaderTimeExecUSec: %m");
|
||||
|
||||
@@ -69,11 +69,11 @@ static int get_device_part_uuid(const char *variable, sd_id128_t *ret) {
|
||||
}
|
||||
|
||||
int efi_loader_get_device_part_uuid(sd_id128_t *ret) {
|
||||
return get_device_part_uuid(EFI_LOADER_VARIABLE(LoaderDevicePartUUID), ret);
|
||||
return get_device_part_uuid(EFI_LOADER_VARIABLE_STR("LoaderDevicePartUUID"), ret);
|
||||
}
|
||||
|
||||
int efi_stub_get_device_part_uuid(sd_id128_t *ret) {
|
||||
return get_device_part_uuid(EFI_LOADER_VARIABLE(StubDevicePartUUID), ret);
|
||||
return get_device_part_uuid(EFI_LOADER_VARIABLE_STR("StubDevicePartUUID"), ret);
|
||||
}
|
||||
|
||||
int efi_loader_get_entries(char ***ret) {
|
||||
@@ -87,7 +87,7 @@ int efi_loader_get_entries(char ***ret) {
|
||||
if (!is_efi_boot())
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
r = efi_get_variable(EFI_LOADER_VARIABLE(LoaderEntries), NULL, (void**) &entries, &size);
|
||||
r = efi_get_variable(EFI_LOADER_VARIABLE_STR("LoaderEntries"), NULL, (void**) &entries, &size);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -148,12 +148,12 @@ int efi_loader_get_features(uint64_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = efi_get_variable(EFI_LOADER_VARIABLE(LoaderFeatures), NULL, &v, &s);
|
||||
r = efi_get_variable(EFI_LOADER_VARIABLE_STR("LoaderFeatures"), NULL, &v, &s);
|
||||
if (r == -ENOENT) {
|
||||
_cleanup_free_ char *info = NULL;
|
||||
|
||||
/* The new (v240+) LoaderFeatures variable is not supported, let's see if it's systemd-boot at all */
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE(LoaderInfo), &info);
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE_STR("LoaderInfo"), &info);
|
||||
if (r < 0) {
|
||||
if (r != -ENOENT)
|
||||
return r;
|
||||
@@ -199,12 +199,12 @@ int efi_stub_get_features(uint64_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = efi_get_variable(EFI_LOADER_VARIABLE(StubFeatures), NULL, &v, &s);
|
||||
r = efi_get_variable(EFI_LOADER_VARIABLE_STR("StubFeatures"), NULL, &v, &s);
|
||||
if (r == -ENOENT) {
|
||||
_cleanup_free_ char *info = NULL;
|
||||
|
||||
/* The new (v252+) StubFeatures variable is not supported, let's see if it's systemd-stub at all */
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE(StubInfo), &info);
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE_STR("StubInfo"), &info);
|
||||
if (r < 0) {
|
||||
if (r != -ENOENT)
|
||||
return r;
|
||||
@@ -261,7 +261,7 @@ int efi_measured_uki(int log_level) {
|
||||
if (!efi_has_tpm2())
|
||||
return (cached = 0);
|
||||
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE(StubPcrKernelImage), &pcr_string);
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE_STR("StubPcrKernelImage"), &pcr_string);
|
||||
if (r == -ENOENT)
|
||||
return (cached = 0);
|
||||
if (r < 0)
|
||||
@@ -291,7 +291,7 @@ int efi_loader_get_config_timeout_one_shot(usec_t *ret) {
|
||||
assert(ret);
|
||||
|
||||
/* stat() the EFI variable, to see if the mtime changed. If it did, we need to cache again. */
|
||||
if (stat(EFIVAR_PATH(EFI_LOADER_VARIABLE(LoaderConfigTimeoutOneShot)), &new_stat) < 0)
|
||||
if (stat(EFIVAR_PATH(EFI_LOADER_VARIABLE_STR("LoaderConfigTimeoutOneShot")), &new_stat) < 0)
|
||||
return -errno;
|
||||
|
||||
if (stat_inode_unmodified(&new_stat, &cache_stat)) {
|
||||
@@ -299,7 +299,7 @@ int efi_loader_get_config_timeout_one_shot(usec_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE(LoaderConfigTimeoutOneShot), &v);
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE_STR("LoaderConfigTimeoutOneShot"), &v);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -323,13 +323,13 @@ int efi_loader_update_entry_one_shot_cache(char **cache, struct stat *cache_stat
|
||||
assert(cache_stat);
|
||||
|
||||
/* stat() the EFI variable, to see if the mtime changed. If it did we need to cache again. */
|
||||
if (stat(EFIVAR_PATH(EFI_LOADER_VARIABLE(LoaderEntryOneShot)), &new_stat) < 0)
|
||||
if (stat(EFIVAR_PATH(EFI_LOADER_VARIABLE_STR("LoaderEntryOneShot")), &new_stat) < 0)
|
||||
return -errno;
|
||||
|
||||
if (stat_inode_unmodified(&new_stat, cache_stat))
|
||||
return 0;
|
||||
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE(LoaderEntryOneShot), &v);
|
||||
r = efi_get_variable_string(EFI_LOADER_VARIABLE_STR("LoaderEntryOneShot"), &v);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -527,7 +527,7 @@ int clear_efi_hibernate_location_and_warn(void) {
|
||||
if (!is_efi_boot())
|
||||
return 0;
|
||||
|
||||
r = efi_set_variable(EFI_SYSTEMD_VARIABLE(HibernateLocation), NULL, 0);
|
||||
r = efi_set_variable(EFI_SYSTEMD_VARIABLE_STR("HibernateLocation"), NULL, 0);
|
||||
if (r == -ENOENT)
|
||||
return 0;
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user