mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-26 10:03:40 +03:00
Inline some inerator variables
This commit is contained in:
parent
e6f055cbc4
commit
c67bd42b71
@ -288,7 +288,7 @@ static int print_efi_option(uint16_t id, bool in_order) {
|
|||||||
|
|
||||||
static int status_variables(void) {
|
static int status_variables(void) {
|
||||||
_cleanup_free_ uint16_t *options = NULL, *order = NULL;
|
_cleanup_free_ uint16_t *options = NULL, *order = NULL;
|
||||||
int n_options, n_order, i;
|
int n_options, n_order;
|
||||||
|
|
||||||
n_options = efi_get_boot_options(&options);
|
n_options = efi_get_boot_options(&options);
|
||||||
if (n_options == -ENOENT)
|
if (n_options == -ENOENT)
|
||||||
@ -306,14 +306,12 @@ static int status_variables(void) {
|
|||||||
|
|
||||||
/* print entries in BootOrder first */
|
/* print entries in BootOrder first */
|
||||||
printf("Boot Loaders Listed in EFI Variables:\n");
|
printf("Boot Loaders Listed in EFI Variables:\n");
|
||||||
for (i = 0; i < n_order; i++)
|
for (int i = 0; i < n_order; i++)
|
||||||
print_efi_option(order[i], true);
|
print_efi_option(order[i], true);
|
||||||
|
|
||||||
/* print remaining entries */
|
/* print remaining entries */
|
||||||
for (i = 0; i < n_options; i++) {
|
for (int i = 0; i < n_options; i++) {
|
||||||
int j;
|
for (int j = 0; j < n_order; j++)
|
||||||
|
|
||||||
for (j = 0; j < n_order; j++)
|
|
||||||
if (options[i] == order[j])
|
if (options[i] == order[j])
|
||||||
goto next_option;
|
goto next_option;
|
||||||
|
|
||||||
@ -726,7 +724,7 @@ static int find_slot(sd_id128_t uuid, const char *path, uint16_t *id) {
|
|||||||
static int insert_into_order(uint16_t slot, bool first) {
|
static int insert_into_order(uint16_t slot, bool first) {
|
||||||
_cleanup_free_ uint16_t *order = NULL;
|
_cleanup_free_ uint16_t *order = NULL;
|
||||||
uint16_t *t;
|
uint16_t *t;
|
||||||
int n, i;
|
int n;
|
||||||
|
|
||||||
n = efi_get_boot_order(&order);
|
n = efi_get_boot_order(&order);
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
@ -738,7 +736,7 @@ static int insert_into_order(uint16_t slot, bool first) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* are we already in the boot order? */
|
/* are we already in the boot order? */
|
||||||
for (i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
if (order[i] != slot)
|
if (order[i] != slot)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -770,13 +768,13 @@ static int insert_into_order(uint16_t slot, bool first) {
|
|||||||
|
|
||||||
static int remove_from_order(uint16_t slot) {
|
static int remove_from_order(uint16_t slot) {
|
||||||
_cleanup_free_ uint16_t *order = NULL;
|
_cleanup_free_ uint16_t *order = NULL;
|
||||||
int n, i;
|
int n;
|
||||||
|
|
||||||
n = efi_get_boot_order(&order);
|
n = efi_get_boot_order(&order);
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
return n;
|
return n;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
if (order[i] != slot)
|
if (order[i] != slot)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1295,7 +1293,6 @@ static int verb_status(int argc, char *argv[], void *userdata) {
|
|||||||
_cleanup_free_ char *fw_type = NULL, *fw_info = NULL, *loader = NULL, *loader_path = NULL, *stub = NULL;
|
_cleanup_free_ char *fw_type = NULL, *fw_info = NULL, *loader = NULL, *loader_path = NULL, *stub = NULL;
|
||||||
sd_id128_t loader_part_uuid = SD_ID128_NULL;
|
sd_id128_t loader_part_uuid = SD_ID128_NULL;
|
||||||
uint64_t loader_features = 0;
|
uint64_t loader_features = 0;
|
||||||
size_t i;
|
|
||||||
int have;
|
int have;
|
||||||
|
|
||||||
read_efi_var(EFI_LOADER_VARIABLE(LoaderFirmwareType), &fw_type);
|
read_efi_var(EFI_LOADER_VARIABLE(LoaderFirmwareType), &fw_type);
|
||||||
@ -1334,7 +1331,7 @@ static int verb_status(int argc, char *argv[], void *userdata) {
|
|||||||
printf("Current Boot Loader:\n");
|
printf("Current Boot Loader:\n");
|
||||||
printf(" Product: %s%s%s\n", ansi_highlight(), strna(loader), ansi_normal());
|
printf(" Product: %s%s%s\n", ansi_highlight(), strna(loader), ansi_normal());
|
||||||
|
|
||||||
for (i = 0; i < ELEMENTSOF(flags); i++)
|
for (size_t i = 0; i < ELEMENTSOF(flags); i++)
|
||||||
print_yes_no_line(i == 0, FLAGS_SET(loader_features, flags[i].flag), flags[i].name);
|
print_yes_no_line(i == 0, FLAGS_SET(loader_features, flags[i].flag), flags[i].name);
|
||||||
|
|
||||||
sd_id128_t bootloader_esp_uuid;
|
sd_id128_t bootloader_esp_uuid;
|
||||||
@ -1432,13 +1429,11 @@ static int verb_list(int argc, char *argv[], void *userdata) {
|
|||||||
if (config.n_entries == 0)
|
if (config.n_entries == 0)
|
||||||
log_info("No boot loader entries found.");
|
log_info("No boot loader entries found.");
|
||||||
else {
|
else {
|
||||||
size_t n;
|
|
||||||
|
|
||||||
(void) pager_open(arg_pager_flags);
|
(void) pager_open(arg_pager_flags);
|
||||||
|
|
||||||
printf("Boot Loader Entries:\n");
|
printf("Boot Loader Entries:\n");
|
||||||
|
|
||||||
for (n = 0; n < config.n_entries; n++) {
|
for (size_t n = 0; n < config.n_entries; n++) {
|
||||||
r = boot_entry_show(config.entries + n, n == (size_t) config.default_entry);
|
r = boot_entry_show(config.entries + n, n == (size_t) config.default_entry);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
@ -345,9 +345,7 @@ static void id128_to_efi_guid(sd_id128_t id, void *guid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t *tilt_slashes(uint16_t *s) {
|
static uint16_t *tilt_slashes(uint16_t *s) {
|
||||||
uint16_t *p;
|
for (uint16_t *p = s; *p; p++)
|
||||||
|
|
||||||
for (p = s; *p; p++)
|
|
||||||
if (*p == '/')
|
if (*p == '/')
|
||||||
*p = '\\';
|
*p = '\\';
|
||||||
|
|
||||||
@ -465,11 +463,11 @@ int efi_set_boot_order(uint16_t *order, size_t n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int boot_id_hex(const char s[static 4]) {
|
static int boot_id_hex(const char s[static 4]) {
|
||||||
int id = 0, i;
|
int id = 0;
|
||||||
|
|
||||||
assert(s);
|
assert(s);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
if (s[i] >= '0' && s[i] <= '9')
|
if (s[i] >= '0' && s[i] <= '9')
|
||||||
id |= (s[i] - '0') << (3 - i) * 4;
|
id |= (s[i] - '0') << (3 - i) * 4;
|
||||||
else if (s[i] >= 'A' && s[i] <= 'F')
|
else if (s[i] >= 'A' && s[i] <= 'F')
|
||||||
@ -595,12 +593,9 @@ int efi_loader_get_device_part_uuid(sd_id128_t *u) {
|
|||||||
&parsed[12], &parsed[13], &parsed[14], &parsed[15]) != 16)
|
&parsed[12], &parsed[13], &parsed[14], &parsed[15]) != 16)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
if (u) {
|
if (u)
|
||||||
unsigned i;
|
for (unsigned i = 0; i < ELEMENTSOF(parsed); i++)
|
||||||
|
|
||||||
for (i = 0; i < ELEMENTSOF(parsed); i++)
|
|
||||||
u->bytes[i] = parsed[i];
|
u->bytes[i] = parsed[i];
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -608,7 +603,7 @@ int efi_loader_get_device_part_uuid(sd_id128_t *u) {
|
|||||||
int efi_loader_get_entries(char ***ret) {
|
int efi_loader_get_entries(char ***ret) {
|
||||||
_cleanup_free_ char16_t *entries = NULL;
|
_cleanup_free_ char16_t *entries = NULL;
|
||||||
_cleanup_strv_free_ char **l = NULL;
|
_cleanup_strv_free_ char **l = NULL;
|
||||||
size_t size, i, start;
|
size_t size;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(ret);
|
assert(ret);
|
||||||
@ -622,7 +617,7 @@ int efi_loader_get_entries(char ***ret) {
|
|||||||
|
|
||||||
/* The variable contains a series of individually NUL terminated UTF-16 strings. */
|
/* The variable contains a series of individually NUL terminated UTF-16 strings. */
|
||||||
|
|
||||||
for (i = 0, start = 0;; i++) {
|
for (size_t i = 0, start = 0;; i++) {
|
||||||
_cleanup_free_ char *decoded = NULL;
|
_cleanup_free_ char *decoded = NULL;
|
||||||
bool end;
|
bool end;
|
||||||
|
|
||||||
@ -795,7 +790,6 @@ bool efi_has_tpm2(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool efi_loader_entry_name_valid(const char *s) {
|
bool efi_loader_entry_name_valid(const char *s) {
|
||||||
|
|
||||||
if (!filename_is_valid(s)) /* Make sure entry names fit in filenames */
|
if (!filename_is_valid(s)) /* Make sure entry names fit in filenames */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -803,9 +797,7 @@ bool efi_loader_entry_name_valid(const char *s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *efi_tilt_backslashes(char *s) {
|
char *efi_tilt_backslashes(char *s) {
|
||||||
char *p;
|
for (char *p = s; *p; p++)
|
||||||
|
|
||||||
for (p = s; *p; p++)
|
|
||||||
if (*p == '\\')
|
if (*p == '\\')
|
||||||
*p = '/';
|
*p = '/';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user