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)
/* 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;
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)
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;
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;
_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);
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;
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;
}
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 = '\\';
}
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')
&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;
}
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);
/* 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;
#endif
bool efi_loader_entry_name_valid(const char *s) {
-
if (!filename_is_valid(s)) /* Make sure entry names fit in filenames */
return false;
}
char *efi_tilt_backslashes(char *s) {
- char *p;
-
- for (p = s; *p; p++)
+ for (char *p = s; *p; p++)
if (*p == '\\')
*p = '/';