mailing list of musl libc
 help / color / mirror / code / Atom feed
* clarify bswap a bit more for gcc
@ 2019-03-24 11:26 vilimp
  2019-03-24 14:31 ` Pascal Cuoq
  0 siblings, 1 reply; 2+ messages in thread
From: vilimp @ 2019-03-24 11:26 UTC (permalink / raw)
  To: musl; +Cc: vilimp

[-- Attachment #1: Type: text/plain, Size: 364 bytes --]

Hi,
i recently found musl and i started to play with it, i.e. comparing result
of compilation against glibc. 

i know nearly nothing about programing, but is it possible to upstream this
patch, please? It gets rid of gcc's warnings.

> If you are not subscribed and want to be Cc’d on replies, please
> mention that in your post.

Yes, please.

Best regards,
PV

[-- Attachment #2: bswap.patch --]
[-- Type: application/octet-stream, Size: 1147 bytes --]

diff --git a/byteswap.h_orig b/byteswap.h
index 00b9df3..928be2b 100644
--- a/byteswap.h_orig
+++ b/byteswap.h
@@ -11,12 +11,12 @@ static __inline uint16_t __bswap_16(uint16_t __x)
 
 static __inline uint32_t __bswap_32(uint32_t __x)
 {
-	return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
+	return __x>>24 | (__x>>8&0xff00) | (__x<<8&0xff0000) | __x<<24;
 }
 
 static __inline uint64_t __bswap_64(uint64_t __x)
 {
-	return __bswap_32(__x)+0ULL<<32 | __bswap_32(__x>>32);
+	return (__bswap_32(__x)+0ULL)<<32 | __bswap_32(__x>>32);
 }
 
 #define bswap_16(x) __bswap_16(x)
diff --git a/endian.h_orig b/endian.h
index 1bd4445..88c3347 100644
--- a/endian.h_orig
+++ b/endian.h
@@ -29,12 +29,12 @@ static __inline uint16_t __bswap16(uint16_t __x)
 
 static __inline uint32_t __bswap32(uint32_t __x)
 {
-	return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
+	return __x>>24 | (__x>>8&0xff00) | (__x<<8&0xff0000) | __x<<24;
 }
 
 static __inline uint64_t __bswap64(uint64_t __x)
 {
-	return __bswap32(__x)+0ULL<<32 | __bswap32(__x>>32);
+	return (__bswap32(__x)+0ULL)<<32 | __bswap32(__x>>32);
 }
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: clarify bswap a bit more for gcc
  2019-03-24 11:26 clarify bswap a bit more for gcc vilimp
@ 2019-03-24 14:31 ` Pascal Cuoq
  0 siblings, 0 replies; 2+ messages in thread
From: Pascal Cuoq @ 2019-03-24 14:31 UTC (permalink / raw)
  To: musl; +Cc: vilimp

[-- Attachment #1: Type: text/plain, Size: 1132 bytes --]


On 24 Mar 2019, at 12:26, vilimp@volny.cz<mailto:vilimp@volny.cz> wrote:

i know nearly nothing about programing, but is it possible to upstream this
patch, please? It gets rid of gcc's warnings.

If you search around for discussion about this GCC warning, you will find a lot of opinions such as

“That's the one warning that I like to disable. I hate having to write superfluous parentheses around conjunctions. I mean, come on. It's just as lame as requiring them around multiplications would be.” https://news.ycombinator.com/item?id=15405045

“Fortunately I live by my own rule, to avoid unnecessary parentheses” http://wordaligned.org/articles/fixing-compiler-warnings-the-hard-way

There is no reason to think that people in the position of making this change have not already compiled musl with GCC, seen the warning and decided it wasn't useful. Do “git grep parentheses” in musl and you'll find:

configure:tryflag CFLAGS_AUTO -Wno-parentheses

Whatever you did to compile musl, if I were you I would just try to find how to do it in in a way that does not activate this warning.

Pascal


[-- Attachment #2: Type: text/html, Size: 2164 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-24 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-24 11:26 clarify bswap a bit more for gcc vilimp
2019-03-24 14:31 ` Pascal Cuoq

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).