Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Dec 2016 00:01:28 -0800
From:      Mark Millard <markmi@dsl-only.net>
To:        Justin Hibbits <jhibbits@FreeBSD.org>
Cc:        Nathan Whitehorn <nwhitehorn@freebsd.org>, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>
Subject:   Re: sys/powerpc/powerpc/trap.c has messed up masking operation?: use of || for bit field masling
Message-ID:  <6335DBE9-4942-45B2-8DD7-0EDF781CA0F4@dsl-only.net>
In-Reply-To: <96CACD85-DED4-46C6-BBE3-53B4DEFF89DD@FreeBSD.org>
References:  <0661C9A5-5D4C-4F00-9B0C-F80688BED8A4@dsl-only.net> <96CACD85-DED4-46C6-BBE3-53B4DEFF89DD@FreeBSD.org>

index | next in thread | previous in thread | raw e-mail

On 2016-Dec-15, at 8:42 PM, Justin Hibbits <jhibbits at FreeBSD.org> wrote:

> Hi Mark,
> 
> On Dec 13, 2016, at 10:41 PM, Mark Millard wrote:
> 
>> clang 3.9.0 is complaining about:
>> 
>> --- trap.o ---
>> /usr/src/sys/powerpc/powerpc/trap.c:283:42: warning: use of logical '||' with constant operand [-Wconstant-logical-operand]
>>                       frame->cpu.booke.dbcr0 &= ~(DBCR0_IDM || DBCR0_IC);
>>                                                             ^  ~~~~~~~~
>> /usr/src/sys/powerpc/powerpc/trap.c:283:42: note: use '|' for a bitwise operation
>>                       frame->cpu.booke.dbcr0 &= ~(DBCR0_IDM || DBCR0_IC);
>>                                                             ^~
>>                                                             |
>> Looking around:
>> 
>> 
>> # grep DBCR0_ /usr/src/sys/powerpc/include/spr.h
>> . . .
>> #define   DBCR0_IDM               0x40000000 /* Internal Debug Mode */
>> . . .
>> #define   DBCR0_IC                0x08000000 /* Instruction Completion debug event */
>> . . .
>> 
>> || use seems unlikely to be correct for the context.
>> 
> 
> Good find.  Fixed in r310146, to be merged to stable/11 in a couple weeks.

Thanks.

>> 
>> There is also this that I happened to notice sys/powerpc/powerpc/intr_machdep.c :
>> 
>> --- intr_machdep.o ---
>> /usr/src/sys/powerpc/powerpc/intr_machdep.c:454:15: warning: comparison of constant -1 with expression of type 'enum intr_trigger' is always false [-Wtautological-constant-out-of-range-compare]
>>               if (i->trig == -1)
>>                   ~~~~~~~ ^  ~~
>> /usr/src/sys/powerpc/powerpc/intr_machdep.c:500:16: warning: comparison of constant -1 with expression of type 'enum intr_trigger' is always false [-Wtautological-constant-out-of-range-compare]
>>                       if (i->trig == -1)
>>                           ~~~~~~~ ^  ~~
> 
> This may or may not be a problem, depending on optimization settings.  Can you file a bug for this so it doesn't get lost?

Bugzilla 215333 has the submittal.

>> 
>> There are other comparisons around with a constant
>> result at compile time. But they tend to be in less
>> central areas like zfs. Similarly for some other
>> types of compiler reports.
>> 
>> ===
>> Mark Millard
>> markmi at dsl-only.net
>> 
> 
> 
> Thanks for the clang and external toolchain testing.  Lots of good finds.

Glad to help.

> - Justin

===
Mark Millard
markmi at dsl-only.net



help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6335DBE9-4942-45B2-8DD7-0EDF781CA0F4>