From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1klEmp-0000Zu-5M for mharc-grub-devel@gnu.org; Fri, 04 Dec 2020 12:22:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1klEhm-0008NK-8E for grub-devel@gnu.org; Fri, 04 Dec 2020 12:17:33 -0500 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]:46876) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1klEfO-0008GL-M4 for grub-devel@gnu.org; Fri, 04 Dec 2020 12:16:47 -0500 Received: by mail-qt1-x843.google.com with SMTP id h19so2194045qtq.13 for ; Fri, 04 Dec 2020 09:13:46 -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=iwwZMVk2Vi2otYaYX1S0mPSD1xWAAceBWCZKs9gKd5Q=; b=NXF1iuesr/J9gSbpQSMtZ8onLOy9W55WvFxpT4SkGJDnAX4ovBd60LnK124S5FoiTj 1O3/Y4ptbSN+yjIVsYZMleBspzoDC8swOJjDrXsUBYtf/vg/zgHosSdkJIy1pBdlBiGH BhOkVLkCsbIEgdWgBKLmNRLyuhroUBePyD0Xvl/ENi6msoB0qV4n36twfIZkUX8qmem8 DdNNjAzovp6aQhatoUemW+u6eXn4qOHr/Ih1fq9xrZywv96THkfYIoSiblJSLzTUx1wi 1e0N43F56aObFponIgc/HXtq6QWvO5Mrdzd0i3Oq8EXMvpfDe7C2B7LcRCsrJzrB2NO9 mKew== 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=iwwZMVk2Vi2otYaYX1S0mPSD1xWAAceBWCZKs9gKd5Q=; b=a9NKheANrTpn8RsdfMCmbi79Q536+ZZNerIGzYGVgDxvynJzXUqWXvorXhDCtSdxGK UGR0vpseGy8blC5/wbVBF5kaNIbjpYUYB5qYFRKkjs7S3phEYX9M+hrZ3Mhc2GmIeMYE 1PFaE6Rc213l40AcVmTX2FYGJByo+b1PecPI1mtvQ1AbOFXlDC6d+8O7DNf9j2/QXv2e KqecZ754t/ytxhIVbDoyMLLc42LIa2ofRNX+/+oloWx3uNHpt9wVsZYtWLQq5GkJRxTi DQmZ9Z9MCrxXw9UXsgmuX/fiZyWsZyYVL4ZyreAgX1IqX50pqLfRDXXuTmc2b9/uxfCq zk1g== X-Gm-Message-State: AOAM53317OIJvYexuUhCGWy28crpX8cQWi+K10YtHg/1je0c4trxGMrY XRynsmtqyXnimKaxPOrntFepe76tVEdqlQ== X-Google-Smtp-Source: ABdhPJwriwAwKmAwCoo9/E2N+wnFhJWVaDCvwK5hSkLmDioiE2Yo/jSjJXByPqgICgBtF+oVXXBWCw== X-Received: by 2002:a02:caac:: with SMTP id e12mr7448948jap.45.1607100273521; Fri, 04 Dec 2020 08:44:33 -0800 (PST) Received: from localhost.localdomain ([136.49.211.192]) by smtp.gmail.com with ESMTPSA id w3sm1754909iol.9.2020.12.04.08.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 08:44:33 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org Cc: Patrick Steinhardt , Daniel Kiper , Glenn Washburn , Daniel Kiper Subject: [PATCH v7 17/17] luks2: Use grub_log2ull to calculate log_sector_size and improve readability Date: Fri, 4 Dec 2020 10:43:46 -0600 Message-Id: <8b97e688757dd244a6f199bb0cf258ac196375a0.1607098915.git.development@efficientek.com> 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::843; envelope-from=development@efficientek.com; helo=mail-qt1-x843.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: Fri, 04 Dec 2020 17:18:00 -0000 X-List-Received-Date: Fri, 04 Dec 2020 17:18:00 -0000 Reviewed-by: Daniel Kiper Signed-off-by: Glenn Washburn --- 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 2335ded77..4fa5a0dbc 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