From 5f59807d2dc0eb4653f2e9c0722b2f6bff751f7d Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 21 Nov 2022 10:34:28 +0100 Subject: [PATCH] repart: Rework unused partition number algorithm --- src/partition/repart.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/partition/repart.c b/src/partition/repart.c index b4ef7b8e34..20db7d7a1a 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; -- 2.25.1