From: Glenn Washburn Date: Tue, 15 Dec 2020 23:31:11 +0000 (-0600) Subject: luks2: Use grub_log2ull() to calculate log_sector_size and improve readability X-Git-Tag: grub-2.06-rc1~144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec46685ed4ea7bf0dd81c8254c2d9e0e8514976c;p=thirdparty%2Fgrub.git luks2: Use grub_log2ull() to calculate log_sector_size and improve readability Signed-off-by: Glenn Washburn Reviewed-by: Daniel Kiper --- diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c index 894f155e6..7460d7b58 100644 --- a/grub-core/disk/luks2.c +++ b/grub-core/disk/luks2.c @@ -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,