summaryrefslogtreecommitdiff
path: root/cmd/efi.c
diff options
context:
space:
mode:
authorEugeniu Rosca <roscaeugeniu@gmail.com>2018-07-14 22:53:30 +0200
committerAlexander Graf <agraf@suse.de>2018-08-21 00:03:01 +0200
commit9b89183b97f3d906a8df1050707d48a74e35caed (patch)
tree7d2600485d3cfd939ce6f7ebe7efa783228737e4 /cmd/efi.c
parent9d12daff6c3c12a6c30c01a1937305c2e63fae8b (diff)
downloadu-boot-9b89183b97f3d906a8df1050707d48a74e35caed.tar.gz
efi: Fix truncation of constant value
Starting with commit 867a6ac86dd8 ("efi: Add start-up library code"), sparse constantly complains about truncated constant value in efi.h: include/efi.h:176:35: warning: cast truncates bits from constant value (8000000000000000 becomes 0) This can get quite noisy, preventing real issues to be noticed: $ make defconfig *** Default configuration is based on 'sandbox_defconfig' $ make C=2 -j12 2>&1 | grep truncates | wc -l 441 After the patch is applied: $ make C=2 -j12 2>&1 | grep truncates | wc -l 0 $ sparse --version v0.5.2 Following the suggestion of Heinrich Schuchardt, instead of only fixing the root-cause, I replaced the whole enum of _SHIFT values by ULL defines. This matches both the UEFI 2.7 spec and the Linux kernel implementation. Some ELF size comparison before and after the patch (gcc 7.3.0): efi-x86_payload64_defconfig: text data bss dec hex filename 407174 29432 278676 715282 aea12 u-boot.old 407152 29464 278676 715292 aea1c u-boot.new -22 +32 0 +10 efi-x86_payload32_defconfig: text data bss dec hex filename 447075 30308 280076 757459 b8ed3 u-boot.old 447053 30340 280076 757469 b8edd u-boot.new -22 +32 0 +10 Fixes: 867a6ac86dd8 ("efi: Add start-up library code") Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'cmd/efi.c')
-rw-r--r--cmd/efi.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/cmd/efi.c b/cmd/efi.c
index 6c1eb88424..92a565f713 100644
--- a/cmd/efi.c
+++ b/cmd/efi.c
@@ -28,18 +28,18 @@ static const char *const type_name[] = {
};
static struct attr_info {
- int shift;
+ u64 val;
const char *name;
} mem_attr[] = {
- { EFI_MEMORY_UC_SHIFT, "uncached" },
- { EFI_MEMORY_WC_SHIFT, "write-coalescing" },
- { EFI_MEMORY_WT_SHIFT, "write-through" },
- { EFI_MEMORY_WB_SHIFT, "write-back" },
- { EFI_MEMORY_UCE_SHIFT, "uncached & exported" },
- { EFI_MEMORY_WP_SHIFT, "write-protect" },
- { EFI_MEMORY_RP_SHIFT, "read-protect" },
- { EFI_MEMORY_XP_SHIFT, "execute-protect" },
- { EFI_MEMORY_RUNTIME_SHIFT, "needs runtime mapping" }
+ { EFI_MEMORY_UC, "uncached" },
+ { EFI_MEMORY_WC, "write-coalescing" },
+ { EFI_MEMORY_WT, "write-through" },
+ { EFI_MEMORY_WB, "write-back" },
+ { EFI_MEMORY_UCE, "uncached & exported" },
+ { EFI_MEMORY_WP, "write-protect" },
+ { EFI_MEMORY_RP, "read-protect" },
+ { EFI_MEMORY_XP, "execute-protect" },
+ { EFI_MEMORY_RUNTIME, "needs runtime mapping" }
};
/* Maximum different attribute values we can track */
@@ -173,7 +173,7 @@ static void efi_print_mem_table(struct efi_entry_memmap *map,
printf("%c%llx: ", attr & EFI_MEMORY_RUNTIME ? 'r' : ' ',
attr & ~EFI_MEMORY_RUNTIME);
for (j = 0, first = true; j < ARRAY_SIZE(mem_attr); j++) {
- if (attr & (1ULL << mem_attr[j].shift)) {
+ if (attr & mem_attr[j].val) {
if (first)
first = false;
else