Closed
Bug 1125084
Opened 9 years ago
Closed 9 years ago
Uninitialised value use in mozilla::hal_impl::SetScreenBrightness(double)
Categories
(Core :: Hardware Abstraction Layer (HAL), defect)
Tracking
()
RESOLVED
FIXED
mozilla41
Tracking | Status | |
---|---|---|
firefox41 | --- | fixed |
People
(Reporter: jseward, Assigned: jseward)
Details
Attachments
(2 files, 1 obsolete file)
5.23 KB,
text/plain
|
Details | |
1.07 KB,
patch
|
dhylands
:
review+
|
Details | Diff | Splinter Review |
This occurs when starting up b2g on Nexus 5. I haven't tested Flame (yet). Problem is in gecko/hal/gonk/GonkHal.cpp. It appears that GetKeyLightEnabled() returns an undefined value. It looks like this: bool GetKeyLightEnabled() { LightConfiguration config; GetLight(hal::eHalLightID_Buttons, &config); return (config.color != 0x00000000); } The call to GetLight is intended to write values into |config|, but in fact GetLight returns a |bool| indicating success/failure, which this routine ignores. So it just assumes that |config| got filled in, which isn't true. There's a second call point in this file to GetLight, that also ignores the return result, in GetScreenBrightness.
Assignee | ||
Comment 1•9 years ago
|
||
Assignee | ||
Comment 2•9 years ago
|
||
Adds (ultra-trivial) handling of failure of GetLight(). mwu, what are suitable values for GetKeyLightEnabled() and GetScreenBrightness() in case of failure of GetLight() ?
Flags: needinfo?(mwu)
Comment 3•9 years ago
|
||
Comment on attachment 8610580 [details] [diff] [review] bug1125084-1.diff Review of attachment 8610580 [details] [diff] [review]: ----------------------------------------------------------------- ::: hal/gonk/GonkHal.cpp @@ +767,5 @@ > + bool ok = GetLight(eHalLightID_Buttons, &config); > + if (ok) { > + return (config.color != 0x00000000); > + } else { > + return false; This seems ok to me. @@ +807,5 @@ > + // backlight is brightness only, so using one of the RGB elements as value. > + int brightness = config.color & 0xFF; > + return brightness / 255.0; > + } else { > + return 0.5; The right thing to do here might be to crash. Alternately, we can cache the last brightness setting and return that.
Attachment #8610580 -
Flags: feedback?(dhylands)
Updated•9 years ago
|
Flags: needinfo?(mwu)
Comment 4•9 years ago
|
||
Comment on attachment 8610580 [details] [diff] [review] bug1125084-1.diff Review of attachment 8610580 [details] [diff] [review]: ----------------------------------------------------------------- Just a couple minor nits. ::: hal/gonk/GonkHal.cpp @@ +766,5 @@ > LightConfiguration config; > + bool ok = GetLight(eHalLightID_Buttons, &config); > + if (ok) { > + return (config.color != 0x00000000); > + } else { nit: lose the else, unindent the return @@ +806,5 @@ > + if (ok) { > + // backlight is brightness only, so using one of the RGB elements as value. > + int brightness = config.color & 0xFF; > + return brightness / 255.0; > + } else { nit: lose the else @@ +807,5 @@ > + // backlight is brightness only, so using one of the RGB elements as value. > + int brightness = config.color & 0xFF; > + return brightness / 255.0; > + } else { > + return 0.5; I think that if GetLight fails, then its because that light doesn't exist, so returning a cached value doesn't make sense. I think I'd just return 0 (or whatever value corresponds to off).
Attachment #8610580 -
Flags: feedback?(dhylands) → feedback+
Assignee | ||
Comment 5•9 years ago
|
||
Addresses review comments in comment 3 and comment 4.
Assignee: nobody → jseward
Attachment #8610580 -
Attachment is obsolete: true
Attachment #8612263 -
Flags: review?(dhylands)
Comment 6•9 years ago
|
||
Comment on attachment 8612263 [details] [diff] [review] bug1125084-2.diff Review of attachment 8612263 [details] [diff] [review]: ----------------------------------------------------------------- lgtm
Attachment #8612263 -
Flags: review?(dhylands) → review+
Comment 8•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/14a44154018a
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox41:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
You need to log in
before you can comment on or make changes to this bug.
Description
•