All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Serbinenko <phcoder@gmail.com>
To: grub-devel@gnu.org
Cc: Vladimir Serbinenko <phcoder@gmail.com>
Subject: [PATCH] Add missing cast in compile-time byteswaps
Date: Thu, 16 May 2024 22:22:58 +0300	[thread overview]
Message-ID: <20240516192258.4245-1-phcoder@gmail.com> (raw)

Without them 0x80LL is 32-bit byte-swapped to 0xffffffff80000000 instead
of correct 0x80000000

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
 include/grub/types.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/grub/types.h b/include/grub/types.h
index 064066e2e..45079bf65 100644
--- a/include/grub/types.h
+++ b/include/grub/types.h
@@ -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); \
-- 
2.39.2


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

             reply	other threads:[~2024-05-16 19:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16 19:22 Vladimir Serbinenko [this message]
2024-06-03 16:33 ` [PATCH] Add missing cast in compile-time byteswaps Daniel Kiper
2024-06-03 16:43   ` Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240516192258.4245-1-phcoder@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.