From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kmll0-0005A7-2G for mharc-grub-devel@gnu.org; Tue, 08 Dec 2020 17:46:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmlkv-000563-V7 for grub-devel@gnu.org; Tue, 08 Dec 2020 17:46:49 -0500 Received: from mail-oi1-x244.google.com ([2607:f8b0:4864:20::244]:40266) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kmlke-0000m5-EK for grub-devel@gnu.org; Tue, 08 Dec 2020 17:46:49 -0500 Received: by mail-oi1-x244.google.com with SMTP id p126so310450oif.7 for ; Tue, 08 Dec 2020 14:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TSPEMsV7gUBu6NWI9TRjJyLZgdA73FYANQ4T9oQkJ3k=; b=bdt2032nbJBQ/VBz/ioeoc+MBa+97ekMJgYxG5e+4IkUgUGWdixeu2NMzHDV8PAM9s dq/6nv9T8/iawBOUcdSGip96OVj+ui/15VpiWOROY0fmTodnAiDDGNUpKWDkqSFdsgyi XbMXRzH0mwCRnf9csDQ1ElKKPYPL1iLzW0yis5aAf4ju4C+xRWGFlzyM7Q3aJ9WqKtGK Imqjt/ccX+Wuhu0UhBrWXeonj8kkKFq/Q1xPMUOOfYt+qL0oqO7P2mx3HzVkkrV35A7m /riDVgPanHcSiPk0uGlokY/3us593vqUBRFuqTC8cZugfdSqs8400/d3JCAtvv6+Shbb KU0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TSPEMsV7gUBu6NWI9TRjJyLZgdA73FYANQ4T9oQkJ3k=; b=Pr4gJuq4WiKx/TozzWD2zVdQ4n50lJRKQTLozdAh8dRYV1mLzmYTRUXTKbcm/RD1E4 OcgI8ImOPF0c2cnG77ya8mOibcfaEBkuTJpOL1ysgBz7uK+Ndd9bTYTCd/fCu+FiF5c4 GTE0h7gXK8GB93nn0ZxRrOL041hn7WpWf5AqiGZemWKvlPo8HaukKkQCijXeH1EeYf3a /af0v7KqtGZnqWQJHsWbuzfyIKvcV0mjJ2GfVa9BY5U+YsKWLlgy/Xqk7f8zMYVQbfqX BzRi8ZQudnyNQrXnaODzebMWI/jXvE2uW1b0jn7/EdeoOvzo3+uy5ABUVEaoU3JcvhMH KkUQ== X-Gm-Message-State: AOAM5331jSIJJCWo/j4qrLkc0CRos0eFbQGSO+pnGJWUQTvntZM8Em8p JX5McJsEFQcEaXpaDmuLlO5rAkYmUWJRjA== X-Google-Smtp-Source: ABdhPJxE7kfepYUl6xVRzisjNv4YjZCYmX+kkGQChzN+281beB3cLXD2w4/mCt1m7oh/zJSB1/9EqA== X-Received: by 2002:aca:d06:: with SMTP id 6mr111347oin.13.1607467591132; Tue, 08 Dec 2020 14:46:31 -0800 (PST) Received: from crass-HP-ZBook-15-G2.attlocal.net ([136.49.211.192]) by smtp.gmail.com with ESMTPSA id v8sm45538otp.10.2020.12.08.14.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:46:30 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org Cc: Patrick Steinhardt , Daniel Kiper , Glenn Washburn , Daniel Kiper Subject: [PATCH v8 18/18] luks2: Use grub_log2ull to calculate log_sector_size and improve readability Date: Tue, 8 Dec 2020 16:45:49 -0600 Message-Id: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::244; envelope-from=development@efficientek.com; helo=mail-oi1-x244.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2020 22:46:50 -0000 Signed-off-by: Glenn Washburn Reviewed-by: Daniel Kiper --- grub-core/disk/luks2.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c index c737797b9..31b51f1d4 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 size, which is the maximum we allow. */ max_crypt_sectors = grub_disk_convert_sector(source, source->total_sectors, -- 2.27.0