mailing list of musl libc
 help / color / mirror / code / Atom feed
* Fix warnings when build with clang
@ 2016-06-25  0:18 Zhao, Weiming
  2016-06-25  9:37 ` Szabolcs Nagy
  0 siblings, 1 reply; 7+ messages in thread
From: Zhao, Weiming @ 2016-06-25  0:18 UTC (permalink / raw)
  To: musl

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

Clang gives warnings about the missing parentheses for bitwise ops.

It's not functional but just code readability.

musl-m3/include/endian.h:32:25: warning: '&' within '|' 
[-Wbitwise-op-parentheses]
         return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
                        ~ ~~~~~~^~~~~~~


musl-m3/include/endian.h:37:23: warning: operator '<<' has lower 
precedence than '+'; '+' will be evaluated first [-Wshift-op-parentheses]
         return __bswap32(__x)+0ULL<<32 | __bswap32(__x>>32);
                ~~~~~~~~~~~~~~^~~~~~~


Thanks,
Weiming

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation


[-- Attachment #2: musl.patch --]
[-- Type: text/plain, Size: 589 bytes --]

diff --git a/include/endian.h b/include/endian.h
index 1bd4445..88c3347 100644
--- a/include/endian.h
+++ b/include/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] 7+ messages in thread

* Re: Fix warnings when build with clang
  2016-06-25  0:18 Fix warnings when build with clang Zhao, Weiming
@ 2016-06-25  9:37 ` Szabolcs Nagy
  2016-06-27 17:01   ` weimingz
  0 siblings, 1 reply; 7+ messages in thread
From: Szabolcs Nagy @ 2016-06-25  9:37 UTC (permalink / raw)
  To: musl

* Zhao, Weiming <weimingz@codeaurora.org> [2016-06-24 17:18:23 -0700]:
> Clang gives warnings about the missing parentheses for bitwise ops.
> 
> It's not functional but just code readability.
> 
> musl-m3/include/endian.h:32:25: warning: '&' within '|'
> [-Wbitwise-op-parentheses]
>         return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
>                        ~ ~~~~~~^~~~~~~

if clang warns about system headers that's a clang bug.


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

* Re: Fix warnings when build with clang
  2016-06-25  9:37 ` Szabolcs Nagy
@ 2016-06-27 17:01   ` weimingz
  2016-06-27 17:21     ` Rich Felker
  0 siblings, 1 reply; 7+ messages in thread
From: weimingz @ 2016-06-27 17:01 UTC (permalink / raw)
  To: musl; +Cc: Szabolcs Nagy

On 2016-06-25 02:37, Szabolcs Nagy wrote:
> * Zhao, Weiming <weimingz@codeaurora.org> [2016-06-24 17:18:23 -0700]:
>> Clang gives warnings about the missing parentheses for bitwise ops.
>> 
>> It's not functional but just code readability.
>> 
>> musl-m3/include/endian.h:32:25: warning: '&' within '|'
>> [-Wbitwise-op-parentheses]
>>         return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
>>                        ~ ~~~~~~^~~~~~~
> 
> if clang warns about system headers that's a clang bug.

The endian.h is a musl file.


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

* Re: Fix warnings when build with clang
  2016-06-27 17:01   ` weimingz
@ 2016-06-27 17:21     ` Rich Felker
  2016-06-27 17:30       ` Zhao, Weiming
  2016-06-27 17:41       ` Luca Barbato
  0 siblings, 2 replies; 7+ messages in thread
From: Rich Felker @ 2016-06-27 17:21 UTC (permalink / raw)
  To: musl

On Mon, Jun 27, 2016 at 10:01:52AM -0700, weimingz@codeaurora.org wrote:
> On 2016-06-25 02:37, Szabolcs Nagy wrote:
> >* Zhao, Weiming <weimingz@codeaurora.org> [2016-06-24 17:18:23 -0700]:
> >>Clang gives warnings about the missing parentheses for bitwise ops.
> >>
> >>It's not functional but just code readability.
> >>
> >>musl-m3/include/endian.h:32:25: warning: '&' within '|'
> >>[-Wbitwise-op-parentheses]
> >>        return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
> >>                       ~ ~~~~~~^~~~~~~
> >
> >if clang warns about system headers that's a clang bug.
> 
> The endian.h is a musl file.

Right, which is why it's a system header.

Rich


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

* Re: Fix warnings when build with clang
  2016-06-27 17:21     ` Rich Felker
@ 2016-06-27 17:30       ` Zhao, Weiming
  2016-06-27 17:41       ` Luca Barbato
  1 sibling, 0 replies; 7+ messages in thread
From: Zhao, Weiming @ 2016-06-27 17:30 UTC (permalink / raw)
  To: musl

I don't think it's a compiler bug. Neither a functionality issue in MUSL.

Its a warning about code readability / sanity and we can fix it in 2 
seconds, which can make build process looks more clean.

Weiming


On 6/27/2016 10:21 AM, Rich Felker wrote:
> On Mon, Jun 27, 2016 at 10:01:52AM -0700, weimingz@codeaurora.org wrote:
>> On 2016-06-25 02:37, Szabolcs Nagy wrote:
>>> * Zhao, Weiming <weimingz@codeaurora.org> [2016-06-24 17:18:23 -0700]:
>>>> Clang gives warnings about the missing parentheses for bitwise ops.
>>>>
>>>> It's not functional but just code readability.
>>>>
>>>> musl-m3/include/endian.h:32:25: warning: '&' within '|'
>>>> [-Wbitwise-op-parentheses]
>>>>         return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
>>>>                        ~ ~~~~~~^~~~~~~
>>> if clang warns about system headers that's a clang bug.
>> The endian.h is a musl file.
> Right, which is why it's a system header.
>
> Rich

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation



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

* Re: Fix warnings when build with clang
  2016-06-27 17:21     ` Rich Felker
  2016-06-27 17:30       ` Zhao, Weiming
@ 2016-06-27 17:41       ` Luca Barbato
  2016-06-27 17:55         ` Rich Felker
  1 sibling, 1 reply; 7+ messages in thread
From: Luca Barbato @ 2016-06-27 17:41 UTC (permalink / raw)
  To: musl

On 27/06/16 19:21, Rich Felker wrote:
> On Mon, Jun 27, 2016 at 10:01:52AM -0700, weimingz@codeaurora.org wrote:
>> On 2016-06-25 02:37, Szabolcs Nagy wrote:
>>> * Zhao, Weiming <weimingz@codeaurora.org> [2016-06-24 17:18:23 -0700]:
>>>> Clang gives warnings about the missing parentheses for bitwise ops.
>>>>
>>>> It's not functional but just code readability.
>>>>
>>>> musl-m3/include/endian.h:32:25: warning: '&' within '|'
>>>> [-Wbitwise-op-parentheses]
>>>>        return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
>>>>                       ~ ~~~~~~^~~~~~~
>>>
>>> if clang warns about system headers that's a clang bug.
>>
>> The endian.h is a musl file.
> 
> Right, which is why it's a system header.

I'm not sure there is a simple way to know what's a system header and
what is not, beside keeping a list.

And even in that case I'm not so sure the compiler should hide warnings
(no matter how fringe this actual warning is).

lu





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

* Re: Fix warnings when build with clang
  2016-06-27 17:41       ` Luca Barbato
@ 2016-06-27 17:55         ` Rich Felker
  0 siblings, 0 replies; 7+ messages in thread
From: Rich Felker @ 2016-06-27 17:55 UTC (permalink / raw)
  To: musl

On Mon, Jun 27, 2016 at 07:41:49PM +0200, Luca Barbato wrote:
> On 27/06/16 19:21, Rich Felker wrote:
> > On Mon, Jun 27, 2016 at 10:01:52AM -0700, weimingz@codeaurora.org wrote:
> >> On 2016-06-25 02:37, Szabolcs Nagy wrote:
> >>> * Zhao, Weiming <weimingz@codeaurora.org> [2016-06-24 17:18:23 -0700]:
> >>>> Clang gives warnings about the missing parentheses for bitwise ops.
> >>>>
> >>>> It's not functional but just code readability.
> >>>>
> >>>> musl-m3/include/endian.h:32:25: warning: '&' within '|'
> >>>> [-Wbitwise-op-parentheses]
> >>>>        return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
> >>>>                       ~ ~~~~~~^~~~~~~
> >>>
> >>> if clang warns about system headers that's a clang bug.
> >>
> >> The endian.h is a musl file.
> > 
> > Right, which is why it's a system header.
> 
> I'm not sure there is a simple way to know what's a system header and
> what is not, beside keeping a list.

If your compiler is automatically searching the right system header
paths for the target, it's a non-issue. If not (if you have some
hacked-together setup) then you should use -isystem rather than -I for
the system header path.

> And even in that case I'm not so sure the compiler should hide warnings
> (no matter how fringe this actual warning is).

The intent of style warning options (which this one is) is to warn
about issues in the code being compiled, where it does not meet the
policy set for the project being compiled. It's not to warn that libc
does not meet your project's arbitrary style policies. This one
happens to be turned on by -Wall I think, but there are lots of other
style-policy warning options the user could turn on which musl's
headers are cerainly not going to try to comply with, so the proper
solution is for the compiler not to apply the style policy to them.

Rich


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

end of thread, other threads:[~2016-06-27 17:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-25  0:18 Fix warnings when build with clang Zhao, Weiming
2016-06-25  9:37 ` Szabolcs Nagy
2016-06-27 17:01   ` weimingz
2016-06-27 17:21     ` Rich Felker
2016-06-27 17:30       ` Zhao, Weiming
2016-06-27 17:41       ` Luca Barbato
2016-06-27 17:55         ` Rich Felker

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