1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-24 21:34:08 +03:00

Inline some inerator variables

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-06-11 12:23:46 +02:00
parent e6f055cbc4
commit c67bd42b71
2 changed files with 18 additions and 31 deletions

View File

@ -288,7 +288,7 @@ static int print_efi_option(uint16_t id, bool in_order) {
static int status_variables(void) {
_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);
if (n_options == -ENOENT)
@ -306,14 +306,12 @@ static int status_variables(void) {
/* print entries in BootOrder first */
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 remaining entries */
for (i = 0; i < n_options; i++) {
int j;
for (j = 0; j < n_order; j++)
for (int i = 0; i < n_options; i++) {
for (int j = 0; j < n_order; j++)
if (options[i] == order[j])
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) {
_cleanup_free_ uint16_t *order = NULL;
uint16_t *t;
int n, i;
int n;
n = efi_get_boot_order(&order);
if (n <= 0)
@ -738,7 +736,7 @@ static int insert_into_order(uint16_t slot, bool first) {
return 0;
/* are we already in the boot order? */
for (i = 0; i < n; i++) {
for (int i = 0; i < n; i++) {
if (order[i] != slot)
continue;
@ -770,13 +768,13 @@ static int insert_into_order(uint16_t slot, bool first) {
static int remove_from_order(uint16_t slot) {
_cleanup_free_ uint16_t *order = NULL;
int n, i;
int n;
n = efi_get_boot_order(&order);
if (n <= 0)
return n;
for (i = 0; i < n; i++) {
for (int i = 0; i < n; i++) {
if (order[i] != slot)
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;
sd_id128_t loader_part_uuid = SD_ID128_NULL;
uint64_t loader_features = 0;
size_t i;
int have;
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(" 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);
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)
log_info("No boot loader entries found.");
else {
size_t n;
(void) pager_open(arg_pager_flags);
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);
if (r < 0)
return r;

View File

@ -345,9 +345,7 @@ static void id128_to_efi_guid(sd_id128_t id, void *guid) {
}
static uint16_t *tilt_slashes(uint16_t *s) {
uint16_t *p;
for (p = s; *p; p++)
for (uint16_t *p = s; *p; p++)
if (*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]) {
int id = 0, i;
int id = 0;
assert(s);
for (i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
if (s[i] >= '0' && s[i] <= '9')
id |= (s[i] - '0') << (3 - i) * 4;
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)
return -EIO;
if (u) {
unsigned i;
for (i = 0; i < ELEMENTSOF(parsed); i++)
if (u)
for (unsigned i = 0; i < ELEMENTSOF(parsed); i++)
u->bytes[i] = parsed[i];
}
return 0;
}
@ -608,7 +603,7 @@ int efi_loader_get_device_part_uuid(sd_id128_t *u) {
int efi_loader_get_entries(char ***ret) {
_cleanup_free_ char16_t *entries = NULL;
_cleanup_strv_free_ char **l = NULL;
size_t size, i, start;
size_t size;
int r;
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. */
for (i = 0, start = 0;; i++) {
for (size_t i = 0, start = 0;; i++) {
_cleanup_free_ char *decoded = NULL;
bool end;
@ -795,7 +790,6 @@ bool efi_has_tpm2(void) {
#endif
bool efi_loader_entry_name_valid(const char *s) {
if (!filename_is_valid(s)) /* Make sure entry names fit in filenames */
return false;
@ -803,9 +797,7 @@ bool efi_loader_entry_name_valid(const char *s) {
}
char *efi_tilt_backslashes(char *s) {
char *p;
for (p = s; *p; p++)
for (char *p = s; *p; p++)
if (*p == '\\')
*p = '/';