chiark
/
gitweb
/
~ian
/
chiark-utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ae8424f
)
Work around weird kernel behaviour with negative currents
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Tue, 15 Jul 2025 15:39:07 +0000
(16:39 +0100)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Tue, 15 Jul 2025 15:42:35 +0000
(16:42 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
cprogs/xbatmon-simple.c
patch
|
blob
|
history
diff --git
a/cprogs/xbatmon-simple.c
b/cprogs/xbatmon-simple.c
index 8dc679321930c683acbeacc51e98d763073cc734..69b07d910c3c62f3b35534652791e1ef212b3451 100644
(file)
--- a/
cprogs/xbatmon-simple.c
+++ b/
cprogs/xbatmon-simple.c
@@
-244,8
+244,13
@@
static int parse_value(const fileinfo *cfile, const batinfo_field *field) {
if (!field->enumarray[0]) {
+ // Some kernels present a negative number for POWER_SUPPLY_CURRENT_NOW
+ // #1109342, #1109344
+ const char *usevalue = batlinevalue;
+ if (*usevalue == '-') usevalue++;
+
char *ep;
- *field->valuep= strtoull(
batlin
evalue,&ep,10);
+ *field->valuep= strtoull(
us
evalue,&ep,10);
if (*ep)
return batfailf("value number syntax incorrect");