Closed Bug 829344 Opened 11 years ago Closed 11 years ago

Fix gcc -Wlogical-op warnings on Android

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set
normal

Tracking

(firefox20 wontfix, firefox21 affected)

RESOLVED FIXED
Firefox 21
Tracking Status
firefox20 --- wontfix
firefox21 --- affected

People

(Reporter: cpeterson, Assigned: cpeterson)

References

(Depends on 1 open bug)

Details

Attachments

(4 files)

      No description provided.
gcc's -Wlogical-op option now warns for logical expressions such as (c == 1 && c == 2) and (c != 1 || c != 2), which are likely to be mistakes.
Depends on: 828741
Fix gcc -Wlogical-op warning in GTK2 widget code:

widget/gtk2/nsDragService.cpp: In function 'void OnSourceGrabEventAfter(GtkWidget*, GdkEvent*, void*)':
widget/gtk2/nsDragService.cpp:239:48: warning: logical 'or' of collectively exhaustive tests is always true
Attachment #700779 - Flags: review?(karlt)
Attachment #700779 - Flags: review?(karlt) → review+
Fix gcc -Wlogical-op warnings in SIP code:

media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_core.c: In function 'getPreallocatedSipCallID':
media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_core.c:12048:5: warning: logical 'and' of mutually exclusive tests is always false
media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_core.c: In function 'ccsip_find_preallocated_sip_call_id':
media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_core.c:12177:5: warning: logical 'and' of mutually exclusive tests is always false
media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_core.c: In function 'ccsip_free_preallocated_sip_call_id':
media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_core.c:12200:5: warning: logical 'and' of mutually exclusive tests is always false
Attachment #700801 - Flags: review?(rjesup)
Attachment #700801 - Flags: review?(rjesup) → review+
Part 4: Fix gcc -Wlogical-op warnings from PRBool/bool conversion. These warnings are mostly obsolete checks for (bool == true || bool == false) that only made sense for PRBool.


layout/base/nsBidiPresUtils.cpp:1602:49: error: logical 'or' of collectively exhaustive tests is always true
layout/generic/nsCanvasFrame.cpp:150:47 [-Wlogical-op] logical 'or' of collectively exhaustive tests is always true
layout/style/nsNthIndexCache.cpp:60:53: warning: logical 'or' of collectively exhaustive tests is always true
 
netwerk/base/src/nsSimpleURI.cpp:68:43 [-Wlogical-op] logical 'and' of mutually exclusive tests is always false
netwerk/base/src/nsSimpleURI.cpp:83:45 [-Wlogical-op] logical 'and' of mutually exclusive tests is always false
netwerk/base/src/nsStandardURL.cpp:2750:43 [-Wlogical-op] logical 'and' of mutually exclusive tests is always false
netwerk/base/src/nsStandardURL.cpp:2759:55 [-Wlogical-op] logical 'and' of mutually exclusive tests is always false
netwerk/protocol/http/nsHttpChannelAuthProvider.cpp:1356:48 [-Wlogical-op] logical 'and' applied to non-boolean constant
Attachment #701179 - Flags: review?(ehsan)
Comment on attachment 701179 [details] [diff] [review]
part-4-fix-PRBool-warnings.patch

Review of attachment 701179 [details] [diff] [review]:
-----------------------------------------------------------------

::: image/src/RasterImage.cpp
@@ +2615,5 @@
>  nsresult
>  RasterImage::ShutdownDecoder(eShutdownIntent aIntent)
>  {
>    // Ensure that our intent is valid
> +  NS_ABORT_IF_FALSE((aIntent >= 0) && (aIntent < eShutdownIntent_AllCount),

Shoot!

::: layout/generic/nsCanvasFrame.cpp
@@ +146,5 @@
>                             nsIFrame*       aOldFrame)
>  {
>    NS_ASSERTION(aListID == kPrincipalList ||
>                 aListID == kAbsoluteList, "unexpected child list ID");
> +  if (aListID != kPrincipalList && aListID != kAbsoluteList) {

Ouch

::: netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
@@ +1352,5 @@
>              // flag.
>              if (nsCRT::strcmp(ident.User(), entry->User()) == 0) {
>                  uint32_t loadFlags;
>                  if (NS_SUCCEEDED(mAuthChannel->GetLoadFlags(&loadFlags)) &&
> +                    !(loadFlags & nsIChannel::LOAD_EXPLICIT_CREDENTIALS)) {

It's nice to see that the compiler warnings caught real bugs.
Attachment #701179 - Flags: review?(ehsan) → review+
(In reply to :Ehsan Akhgari from comment #6)
> It's nice to see that the compiler warnings caught real bugs.

gcc is full of surprises! :)

https://hg.mozilla.org/integration/mozilla-inbound/rev/98c2750c585d
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [leave open]
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: