From: Daan De Meyer Date: Mon, 21 Nov 2022 09:34:28 +0000 (+0100) Subject: repart: Rework unused partition number algorithm X-Git-Tag: v253-rc1~485^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f59807d2dc0eb4653f2e9c0722b2f6bff751f7d;p=thirdparty%2Fsystemd.git repart: Rework unused partition number algorithm --- diff --git a/src/partition/repart.c b/src/partition/repart.c index b4ef7b8e34b..20db7d7a1a7 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -1056,16 +1056,13 @@ static uint64_t find_first_unused_partno(Context *context) { assert(context); - for (bool changed = true; changed;) { - changed = false; - - LIST_FOREACH(partitions, p, context->partitions) { - if (p->partno != UINT64_MAX && p->partno == partno) { - partno++; - changed = true; - break; - } - } + for (partno = 0;; partno++) { + bool found = false; + LIST_FOREACH(partitions, p, context->partitions) + if (p->partno != UINT64_MAX && p->partno == partno) + found = true; + if (!found) + break; } return partno;