Fix -Wunused-but-set-variable build warnings in widget/gonk/ProcessOrientation.cpp

RESOLVED FIXED in Firefox 40

Status

()

RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

(Blocks: 1 bug)

Trunk
mozilla40
x86_64
Linux
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(firefox40 fixed)

Details

Attachments

(1 attachment)

(Assignee)

Description

4 years ago
Build warning, when compiling an opt b2g build for a device:
{
widget/gonk/ProcessOrientation.cpp: In member function 'int mozilla::ProcessOrientation::OnSensorChanged(const mozilla::hal::SensorData&, int)':
widget/gonk/ProcessOrientation.cpp:210:8: warning: variable 'isAccelerating' set but not used [-Wunused-but-set-variable]
   bool isAccelerating = false;
        ^
widget/gonk/ProcessOrientation.cpp:211:8: warning: variable 'isFlat' set but not used [-Wunused-but-set-variable]
   bool isFlat = false;
        ^
widget/gonk/ProcessOrientation.cpp:212:8: warning: variable 'isSwinging' set but not used [-Wunused-but-set-variable]
   bool isSwinging = false;
        ^
}

These bools are only used in a LOGD statement, which is currently #ifdeffed to be a no-op, like so:
> 30 #if 0
> 31 #define LOGD(args...)  __android_log_print(ANDROID_LOG_DEBUG, "ProcessOrientation" , ## args)
> 32 #else
> 33 #define LOGD(args...)
> 34 #endif
> 35

The best way to hack around the build warning is probably just "mozilla::unused", I think. (DebugOnly<> won't work, because these variables aren't even used in debug builds, unless you tweak that "#if 0" check.)
(Assignee)

Comment 1

4 years ago
Created attachment 8594877 [details] [diff] [review]
fix v1
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #8594877 - Flags: review?(mwu)
(Assignee)

Comment 2

4 years ago
You can't quite see it in the patch-context, but I'm adding these "unused <<" statements right after this LOGD statement which actually references these variables:
http://mxr.mozilla.org/mozilla-central/source/widget/gonk/ProcessOrientation.cpp?rev=ae78bb875714&mark=303-303,311-312#303

Updated

4 years ago
Attachment #8594877 - Flags: review?(mwu) → review+
https://hg.mozilla.org/mozilla-central/rev/6ef45d22c467
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
status-firefox40: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
You need to log in before you can comment on or make changes to this bug.