From: Zbigniew Jędrzejewski-Szmek Date: Wed, 11 May 2022 08:53:25 +0000 (+0200) Subject: bootctl: inline iterator variable X-Git-Tag: v252-rc1~857^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=da60e5b5c7c5f6e41dcdf07baa6f072af0efd6fb;p=thirdparty%2Fsystemd.git bootctl: inline iterator variable --- diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 814e0681583..a27a0d45e47 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -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; }