summaryrefslogtreecommitdiffstats
path: root/src/partition
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2022-11-21 10:34:28 +0100
committerDaan De Meyer <daan.j.demeyer@gmail.com>2022-11-21 10:34:28 +0100
commit5f59807d2dc0eb4653f2e9c0722b2f6bff751f7d (patch)
tree11f901178aba8f1fa2aac593a0dc4927b8d7b31f /src/partition
parentrepart: Use IN_SET() in one more place (diff)
downloadsystemd-5f59807d2dc0eb4653f2e9c0722b2f6bff751f7d.tar.xz
systemd-5f59807d2dc0eb4653f2e9c0722b2f6bff751f7d.zip
repart: Rework unused partition number algorithm
Diffstat (limited to 'src/partition')
-rw-r--r--src/partition/repart.c17
1 files 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;