]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: trivial modernizations
authorLennart Poettering <lennart@poettering.net>
Thu, 19 Jun 2025 12:42:55 +0000 (14:42 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 26 Jun 2025 12:36:34 +0000 (14:36 +0200)
src/repart/repart.c

index 0dc9b7eb0e25a48a3da3b36b75ed6ae108dcab0e..937d4dcd89512205897079bb207cfa9a4fa8edd9 100644 (file)
@@ -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);