Repository navigation
battery-status: keep UPower's rate when the sysfs read fails (#15373) - #15389
nekomario28 wants to merge 1 commit into
Conversation
|
Thanks for this. It's been read but not yet verified, because the classification step didn't finish: I read it as a hardware-caused bug fix ( What I did check, by reading only:
Waiting on: the second model's classification, then the maintainer. |
power_now being readable is not the same as reading it: a battery that only reports energy advertises the attribute and answers the read with ENODEV, and the empty result then divides to 0 W - hiding the rate UPower reported. A failed power_now read also took the branch, so the current_now x voltage_now pair below it never ran. Read the value into a variable and only let a reading that produced a value replace UPower's (omacom#15373).
c1da757 to
b16df03
Compare
[Medium impact] This PR appears safe to merge. Summary
Reviews (1) · Last reviewed commit: "battery-status: keep UPower's rate when ..." · Reviewed by Greptile |
|
Thanks, @nekomario28. I classified this again on the current head (b16df03) and read it against What was checked, by reading only. Nothing ran on a worker:
Second opinion: Codex Medium and muse-wonder (pi, thinking high) both reviewed it, and both agreed that #12755 wins and that this pull request adds nothing #12755 lacks; their independence is not guaranteed. Codex pointed out that Labelled |
Closes #15373.
/sys/class/power_supply/BAT0/power_nowcan exist, be readable, and fail the read: the ACPI battery driver advertises the attribute and a battery that only reports energy answers it with ENODEV.$(<...)is empty then — andawkcalled that0, which overwrote theenergy-rateUPower had reported correctly (21.5 W on the HP Spectre x360 in the report). Theelifnever ran either, because[[ -r ]]passed and took the branch.The value is read into a variable now and only a reading that produced a value replaces UPower's, so the
current_now × voltage_nowpair is still tried whenpower_nowfails.Testing
bash test/shell.d/battery-status-test.sh— two cases added, using a directory to stand in for the unreadablepower_now([[ -r ]]is true for it, the read is not):current_now/voltage_nowpresent the rate must come from them (10.8 W);Against the old code the file stops at
not ok - battery status falls back to current x voltage when power_now cannot be read; with that assertion disabled the second also fails (not ok - battery status keeps UPower's rate when no sysfs reading works), so both are guards that can fail rather than restatements. With the change the whole file is green, including the cases it already had (Apple Silicon's signedpower_now, the charge-hold thresholds, the shared-owner calculation).