Patchwork uefi: uefirtvariable: use sizeof() for finding the bit size of long integer

login
register
mail settings
Submitter Keng-Yu Lin
Date Dec. 20, 2012, 3:52 p.m.
Message ID <1356018764-26953-1-git-send-email-kengyu@canonical.com>
Download mbox | patch
Permalink /patch/207678/
State Accepted
Headers show

Comments

Keng-Yu Lin - Dec. 20, 2012, 3:52 p.m.
The size of long integer can vary on different architectures.

The patch uses sizeof() to find the bit size of the long integer rather than
a fixed value.

This also matches the definition in Linux kernel's efi.h.

Signed-off-by: Keng-Yu Lin <kengyu@canonical.com>
---
 src/uefi/uefirtvariable/uefirtvariable.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Colin King - Dec. 20, 2012, 3:55 p.m.
On 20/12/12 15:52, Keng-Yu Lin wrote:
> The size of long integer can vary on different architectures.
>
> The patch uses sizeof() to find the bit size of the long integer rather than
> a fixed value.
>
> This also matches the definition in Linux kernel's efi.h.
>
> Signed-off-by: Keng-Yu Lin <kengyu@canonical.com>
> ---
>   src/uefi/uefirtvariable/uefirtvariable.c |    4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c
> index 1599c5b..0459160 100644
> --- a/src/uefi/uefirtvariable/uefirtvariable.c
> +++ b/src/uefi/uefirtvariable/uefirtvariable.c
> @@ -40,8 +40,10 @@
>   						0xDD, 0xB7, 0x11, 0xD0, 0x6E} \
>   }
>
> +#define BITS_PER_LONG		(sizeof(long) * 8)
> +
>   #define EFI_SUCCESS		0
> -#define EFI_NOT_FOUND		(14 | (1UL << 63))
> +#define EFI_NOT_FOUND		(14 | (1UL << (BITS_PER_LONG-1)))
>
>   #define MAX_DATA_LENGTH		1024
>
>
Thanks Keng-Yu.  Nice fix.

Colin
Ivan Hu - Dec. 21, 2012, 2:49 a.m.
On 12/20/2012 11:52 PM, Keng-Yu Lin wrote:
> The size of long integer can vary on different architectures.
>
> The patch uses sizeof() to find the bit size of the long integer rather than
> a fixed value.
>
> This also matches the definition in Linux kernel's efi.h.
>
> Signed-off-by: Keng-Yu Lin <kengyu@canonical.com>
> ---
>   src/uefi/uefirtvariable/uefirtvariable.c |    4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c
> index 1599c5b..0459160 100644
> --- a/src/uefi/uefirtvariable/uefirtvariable.c
> +++ b/src/uefi/uefirtvariable/uefirtvariable.c
> @@ -40,8 +40,10 @@
>   						0xDD, 0xB7, 0x11, 0xD0, 0x6E} \
>   }
>
> +#define BITS_PER_LONG		(sizeof(long) * 8)
> +
>   #define EFI_SUCCESS		0
> -#define EFI_NOT_FOUND		(14 | (1UL << 63))
> +#define EFI_NOT_FOUND		(14 | (1UL << (BITS_PER_LONG-1)))
>
>   #define MAX_DATA_LENGTH		1024
>
>

Thanks Keng-yu, Colin for fixing the build i386 issue.
Ack by me, since you'd like to fix the build issue first with the coming 
release. These define is moved to fwts_uefi.h in previous patch 
*uefirtvariable: add the function to print out the return status messages*.
We should also modify this after the patch is applied. :)

Acked-by: Ivan Hu <ivan.hu@canonical.com>

Patch

diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c
index 1599c5b..0459160 100644
--- a/src/uefi/uefirtvariable/uefirtvariable.c
+++ b/src/uefi/uefirtvariable/uefirtvariable.c
@@ -40,8 +40,10 @@ 
 						0xDD, 0xB7, 0x11, 0xD0, 0x6E} \
 }
 
+#define BITS_PER_LONG		(sizeof(long) * 8)
+
 #define EFI_SUCCESS		0
-#define EFI_NOT_FOUND		(14 | (1UL << 63))
+#define EFI_NOT_FOUND		(14 | (1UL << (BITS_PER_LONG-1)))
 
 #define MAX_DATA_LENGTH		1024