git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Explicitly truncate bswap operand to uint32_t

From
Benjamin Kramer <benny.kra@googlemail.com>
Date
Oct 29, 2009, 17:43 UTC
Message-ID
<4AE9D45A.9010805@googlemail.com>

There are some places in git where a long is passed to htonl/ntohl. llvm doesn't support matching operands of different bitwidths intentionally. This patch fixes the build with llvm-gcc (and clang) on x86_64.

Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com>
---
See also:
* http://llvm.org/bugs/show_bug.cgi?id=3373
* http://lkml.org/lkml/2009/1/23/261
 compat/bswap.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/compat/bswap.h b/compat/bswap.h
index 5cc4acb..52fc7b6 100644
--- a/compat/bswap.h
+++ b/compat/bswap.h
@@ -24,7 +24,7 @@ static inline uint32_t default_swab32(uint32_t val)
 	if (__builtin_constant_p(x)) { \
 		__res = default_swab32(x); \
 	} else { \
-		__asm__("bswap %0" : "=r" (__res) : "0" (x)); \
+		__asm__("bswap %0" : "=r" (__res) : "0" ((uint32_t)(x))); \
 	} \
 	__res; })
 
-- 
1.6.5.2.102.g442a9
Message 1 of 1 in “Explicitly truncate bswap operand to uint32_t”
  1. Explicitly truncate bswap operand to uint32_tBenjamin Kramer, Oct 29, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.