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

* Re: [Patch] reduced warnings reported by clang
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Wichmann @ 2018-01-09 17:01 UTC (permalink / raw)
  To: musl

On Tue, Jan 09, 2018 at 04:48:02PM +0000, Patrick Cheng wrote:
> 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.
> 

Didn't we have this topic already? If clang reports warnings from system
headers, it is broken. Either because it is not told those headers are
from the system (did you use -I instead of -isystem?) or because clang
is broken fundamentally. The latter appears to be unlikely, but I've
seen horses puke before.

Ciao,
Markus


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

* Re: [Patch] reduced warnings reported by clang
  2018-01-09 17:01 ` Markus Wichmann
@ 2018-01-09 17:07   ` Rich Felker
  2018-01-09 17:49     ` Patrick Cheng
  0 siblings, 1 reply; 4+ messages in thread
From: Rich Felker @ 2018-01-09 17:07 UTC (permalink / raw)
  To: musl

On Tue, Jan 09, 2018 at 06:01:49PM +0100, Markus Wichmann wrote:
> On Tue, Jan 09, 2018 at 04:48:02PM +0000, Patrick Cheng wrote:
> > 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.
> > 
> 
> Didn't we have this topic already? If clang reports warnings from system
> headers, it is broken. Either because it is not told those headers are
> from the system (did you use -I instead of -isystem?) or because clang
> is broken fundamentally. The latter appears to be unlikely, but I've
> seen horses puke before.

Yes, musl policy is not to let compiler warning whims dictate the way
code or headers are written, on the assumption that musl itself is
built with the warning options it's intended to be used with, and that
compilers do not generate warnings for system headers.

As you noted, usually when this topic comes up it means the user has
not installed musl correctly and is trying to manually -I it rather
than using a musl-targeting toolchain or the provided wrapper scripts.
So it tends to be a helpful warning that something else is wrong in
the user's setup.

Rich


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

* Re: [Patch] reduced warnings reported by clang
  2018-01-09 17:07   ` Rich Felker
@ 2018-01-09 17:49     ` Patrick Cheng
  0 siblings, 0 replies; 4+ messages in thread
From: Patrick Cheng @ 2018-01-09 17:49 UTC (permalink / raw)
  To: musl

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

Thank you for the pointers. That helps.

Found out it was my fault.
When building musl, I set the --prefix=/usr

So in the project, althought I did pass a --sysroot, I also ended up
passing -I.../usr (where musl lives).

Once I sorted those out, the warnings disappears.

Thanks again.



On Tue, Jan 9, 2018 at 9:08 AM Rich Felker <dalias@libc.org> wrote:

> On Tue, Jan 09, 2018 at 06:01:49PM +0100, Markus Wichmann wrote:
> > On Tue, Jan 09, 2018 at 04:48:02PM +0000, Patrick Cheng wrote:
> > > 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.
> > >
> >
> > Didn't we have this topic already? If clang reports warnings from system
> > headers, it is broken. Either because it is not told those headers are
> > from the system (did you use -I instead of -isystem?) or because clang
> > is broken fundamentally. The latter appears to be unlikely, but I've
> > seen horses puke before.
>
> Yes, musl policy is not to let compiler warning whims dictate the way
> code or headers are written, on the assumption that musl itself is
> built with the warning options it's intended to be used with, and that
> compilers do not generate warnings for system headers.
>
> As you noted, usually when this topic comes up it means the user has
> not installed musl correctly and is trying to manually -I it rather
> than using a musl-targeting toolchain or the provided wrapper scripts.
> So it tends to be a helpful warning that something else is wrong in
> the user's setup.
>
> Rich
>

[-- Attachment #2: Type: text/html, Size: 2397 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).