efivars: minor coding style improvements

This commit is contained in:
Lennart Poettering 2017-11-23 22:05:34 +01:00
parent 6f302ce676
commit e22c567fea

View file

@ -85,10 +85,10 @@ bool is_efi_boot(void) {
} }
static int read_flag(const char *varname) { static int read_flag(const char *varname) {
int r;
_cleanup_free_ void *v = NULL; _cleanup_free_ void *v = NULL;
size_t s;
uint8_t b; uint8_t b;
size_t s;
int r;
r = efi_get_variable(EFI_VENDOR_GLOBAL, varname, NULL, &v, &s); r = efi_get_variable(EFI_VENDOR_GLOBAL, varname, NULL, &v, &s);
if (r < 0) if (r < 0)
@ -98,8 +98,7 @@ static int read_flag(const char *varname) {
return -EINVAL; return -EINVAL;
b = *(uint8_t *)v; b = *(uint8_t *)v;
r = b > 0; return b > 0;
return r;
} }
bool is_efi_secure_boot(void) { bool is_efi_secure_boot(void) {
@ -111,10 +110,10 @@ bool is_efi_secure_boot_setup_mode(void) {
} }
int efi_reboot_to_firmware_supported(void) { int efi_reboot_to_firmware_supported(void) {
int r;
size_t s;
uint64_t b;
_cleanup_free_ void *v = NULL; _cleanup_free_ void *v = NULL;
uint64_t b;
size_t s;
int r;
if (!is_efi_boot() || detect_container() > 0) if (!is_efi_boot() || detect_container() > 0)
return -EOPNOTSUPP; return -EOPNOTSUPP;
@ -122,18 +121,20 @@ int efi_reboot_to_firmware_supported(void) {
r = efi_get_variable(EFI_VENDOR_GLOBAL, "OsIndicationsSupported", NULL, &v, &s); r = efi_get_variable(EFI_VENDOR_GLOBAL, "OsIndicationsSupported", NULL, &v, &s);
if (r < 0) if (r < 0)
return r; return r;
else if (s != sizeof(uint64_t)) if (s != sizeof(uint64_t))
return -EINVAL; return -EINVAL;
b = *(uint64_t *)v; b = *(uint64_t*) v;
b &= EFI_OS_INDICATIONS_BOOT_TO_FW_UI; if (!(b & EFI_OS_INDICATIONS_BOOT_TO_FW_UI))
return b > 0 ? 0 : -EOPNOTSUPP; return -EOPNOTSUPP; /* bit unset? it's not supported then */
return 0;
} }
static int get_os_indications(uint64_t *os_indication) { static int get_os_indications(uint64_t *os_indication) {
int r;
size_t s;
_cleanup_free_ void *v = NULL; _cleanup_free_ void *v = NULL;
size_t s;
int r;
r = efi_reboot_to_firmware_supported(); r = efi_reboot_to_firmware_supported();
if (r < 0) if (r < 0)