]> git.proxmox.com Git - grub2.git/commitdiff
luks2: Use grub_log2ull() to calculate log_sector_size and improve readability
authorGlenn Washburn <development@efficientek.com>
Tue, 15 Dec 2020 23:31:11 +0000 (17:31 -0600)
committerDaniel Kiper <daniel.kiper@oracle.com>
Fri, 18 Dec 2020 22:15:05 +0000 (23:15 +0100)
Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/disk/luks2.c

index 894f155e6e746bfc88abb53b10344914aa6c920d..7460d7b583ed3edcdca2903322218e448b749aaa 100644 (file)
@@ -642,8 +642,7 @@ luks2_recover_key (grub_disk_t source,
 
       /* Set up disk according to keyslot's segment. */
       crypt->offset_sectors = grub_divmod64 (segment.offset, segment.sector_size, NULL);
-      crypt->log_sector_size = sizeof (unsigned int) * 8
-               - __builtin_clz ((unsigned int) segment.sector_size) - 1;
+      crypt->log_sector_size = grub_log2ull (segment.sector_size);
       /* Set to the source disk/partition size, which is the maximum we allow. */
       max_crypt_sectors = grub_disk_native_sectors (source);
       max_crypt_sectors = grub_convert_sector (max_crypt_sectors, GRUB_DISK_SECTOR_BITS,