From 3982577119e678cc57a4bb1cfee7849d4c8391de Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 19 Jun 2025 14:42:55 +0200 Subject: [PATCH] repart: trivial modernizations --- src/repart/repart.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/repart/repart.c b/src/repart/repart.c index 0dc9b7eb0e..937d4dcd89 100644 --- a/src/repart/repart.c +++ b/src/repart/repart.c @@ -3239,7 +3239,6 @@ static int context_load_partition_table(Context *context) { bool from_scratch = false; sd_id128_t disk_uuid; size_t n_partitions; - unsigned long secsz; uint64_t grainsz, fs_secsz = DEFAULT_FILESYSTEM_SECTOR_SIZE; int r; @@ -3340,7 +3339,7 @@ static int context_load_partition_table(Context *context) { * it for all our needs. Note that the values we use ourselves always are in bytes though, thus mean * the same thing universally. Also note that regardless what kind of sector size is in use we'll * place partitions at multiples of 4K. */ - secsz = fdisk_get_sector_size(c); + unsigned long secsz = fdisk_get_sector_size(c); /* Insist on a power of two, and that it's a multiple of 512, i.e. the traditional sector size. */ if (secsz < 512 || !ISPOWEROF2(secsz)) @@ -3348,7 +3347,7 @@ static int context_load_partition_table(Context *context) { /* Use at least 4K, and ensure it's a multiple of the sector size, regardless if that is smaller or * larger */ - grainsz = secsz < 4096 ? 4096 : secsz; + grainsz = MAX(secsz, 4096U); log_debug("Sector size of device is %lu bytes. Using default filesystem sector size of %" PRIu64 " and grain size of %" PRIu64 ".", secsz, fs_secsz, grainsz);