Add missing cast in compile-time byteswaps
PATCH 1/1 Add missing cast in compile-time byteswaps
Without them 0x80LL is 32-bit byte-swapped to 0xffffffff80000000 instead of correct 0x80000000
Signed-off-by Vladimir Serbinenko <[email protected]>
--- include/grub/types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/grub/types.h +2 -2
@@ -196,8 +196,8 @@ static inline grub_uint16_t grub_swap_bytes16(grub_uint16_t _x)return (grub_uint16_t) ((_x <<8 ) | (_x >>8 )); } -#define grub_swap_bytes16_compile_time (x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8)) -#define grub_swap_bytes32_compile_time (x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000UL) >> 24)) +#define grub_swap_bytes16_compile_time (x) ((grub_uint16_t)((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))) +#define grub_swap_bytes32_compile_time (x) ((grub_uint32_t)((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000UL) >> 24)))#define grub_swap_bytes64_compile_time (x) \ ({ \ grub_uint64_t _x = (x); \
Signature · 7 lines
2.39.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 4 lines · Vladimir Serbinenko
Without them
0x80LLis 32-bit byte-swapped to0xffffffff80000000instead of correct0x80000000Signed-off-by Vladimir Serbinenko <[email protected]>
Reviewed-by Daniel Kiper <[email protected]>
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 3 lines · Daniel Kiper
Quoted 2 lines · Vladimir Serbinenko
Without them
0x80LLis 32-bit byte-swapped to0xffffffff80000000instead of correct0x80000000
I think it should be added "on 64-bit target"... Right?
Quoted 3 lines
Quoted 1 line
Signed-off-by Vladimir Serbinenko <[email protected]>Reviewed-by Daniel Kiper <[email protected]>
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel