1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-09 13:57:42 +03:00

bootctl: inline iterator variable

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-05-11 10:53:25 +02:00
parent 789431f9f4
commit da60e5b5c7

View File

@ -923,30 +923,29 @@ static bool same_entry(uint16_t id, sd_id128_t uuid, const char *path) {
static int find_slot(sd_id128_t uuid, const char *path, uint16_t *id) {
_cleanup_free_ uint16_t *options = NULL;
int n, i;
n = efi_get_boot_options(&options);
int n = efi_get_boot_options(&options);
if (n < 0)
return n;
/* find already existing systemd-boot entry */
for (i = 0; i < n; i++)
for (int i = 0; i < n; i++)
if (same_entry(options[i], uuid, path)) {
*id = options[i];
return 1;
}
/* find free slot in the sorted BootXXXX variable list */
for (i = 0; i < n; i++)
for (int i = 0; i < n; i++)
if (i != options[i]) {
*id = i;
return 0;
}
/* use the next one */
if (i == 0xffff)
if (n == 0xffff)
return -ENOSPC;
*id = i;
*id = n;
return 0;
}