mailing list of musl libc
 help / color / mirror / code / Atom feed
* [Patch] reduced warnings reported by clang
@ 2018-01-09 16:48 Patrick Cheng
  2018-01-09 17:01 ` Markus Wichmann
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick Cheng @ 2018-01-09 16:48 UTC (permalink / raw)
  To: musl

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

Hello,

Not sure if it's the version of clang that I was using, or the warning
level/toggle on the project that I was compiling, but Musl headers were
causing a number of warnings.

Added extra parenthesis, so it's more explicit the precedence of | vs &

Added 'const' to the typecasting. Clang didn't like const casting.



diff --git a/include/endian.h b/include/endian.h
index 1bd4445..a7a9b6a 100644
--- a/include/endian.h
+++ b/include/endian.h
@@ -24,17 +24,17 @@

 static __inline uint16_t __bswap16(uint16_t __x)
 {
- return __x<<8 | __x>>8;
+ return (__x<<8) | (__x>>8);
 }

 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
diff --git a/include/sched.h b/include/sched.h
index 05d40b1..4d1a599 100644
--- a/include/sched.h
+++ b/include/sched.h
@@ -95,8 +95,8 @@ static __inline void __CPU_##func##_S(size_t __size,
cpu_set_t *__dest, \
 { \
  size_t __i; \
  for (__i=0; __i<__size/sizeof(long); __i++) \
- ((unsigned long *)__dest)[__i] = ((unsigned long *)__src1)[__i] \
- op ((unsigned long *)__src2)[__i] ; \
+ ((unsigned long *)__dest)[__i] = ((const unsigned long *)__src1)[__i] \
+ op ((const unsigned long *)__src2)[__i] ; \
 }

 __CPU_op_func_S(AND, &)

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

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

end of thread, other threads:[~2018-01-09 17:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-09 16:48 [Patch] reduced warnings reported by clang Patrick Cheng
2018-01-09 17:01 ` Markus Wichmann
2018-01-09 17:07   ` Rich Felker
2018-01-09 17:49     ` Patrick Cheng

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).