[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1109348: marked as done (unblock: chiark-utils/8.0.1)



Your message dated Fri, 18 Jul 2025 09:42:18 +0000
with message-id <E1uchbe-0069P8-1W@respighi.debian.org>
and subject line unblock chiark-utils
has caused the Debian Bug report #1109348,
regarding unblock: chiark-utils/8.0.1
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
1109348: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1109348
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: release.debian.org
Severity: normal
X-Debbugs-Cc: chiark-utils@packages.debian.org
Control: affects -1 + src:chiark-utils
User: release.debian.org@packages.debian.org
Usertags: unblock

Please unblock package chiark-utils

(Please provide enough (but not too much) information to help
the release team to judge the request efficiently. E.g. by
filling in the sections below.)

[ Reason ]

One of the programs in chiark-utils-bin.deb, xbatmon-simple,
suffered regression with kernel 6.12.35.

[ Impact ]

This program is severely dysfunctional with newer kernels.

(Even with 6.12.33 it prints a spurious warning, but this is not a
serious bug.  I fixed it on the way as part of diagnosing the serious
problem.)

[ Tests ]

I have tested the fixes manually on the affected system.
There are no autopkgtests.

[ Risks ]

It's possible that I have messed up the algorithms.  The code is
complex and not written in a very obvious style.

In that case, this one program might be broken on some other kernel
versions which report differently-weird information in
/sys/class/power_supply/*/uevent.

My ad-hoc tests of the new code are good enough that I think I can be
confident that it will work correctly with kernels with behaviour
similar to 6.12.33 and 6.12.33.

The last time this particular kernel behaviour changed was many years
ago when USB-C PD power supplies became common.

There is no risk to other functionality of the package, since that
code hasn't been touched.

[ Checklist ]
  [Y] all changes are documented in the d/changelog
  [Y] I reviewed all changes and I approve them
  [Y] attach debdiff against the package in testing

[ Other info ]
(Anything else the release team should know.)

unblock chiark-utils/8.0.1
diff --git a/cprogs/xbatmon-simple.c b/cprogs/xbatmon-simple.c
index 8fe9b06..69b07d9 100644
--- a/cprogs/xbatmon-simple.c
+++ b/cprogs/xbatmon-simple.c
@@ -123,7 +123,7 @@ typedef struct batinfo_field {
 
 #define UEVENT_ENUM_FIELDS(_)						\
   _(state,   BATTERY,  STATUS,  "Discharging","Charging","Full","Unknown" ) \
-  _(type,    BOTH,     TYPE,    "Mains",       "Battery"              )
+  _(type,    BOTH,     TYPE,    "Mains",       "Battery",  "USB" )
 
 #define CHGST_DISCHARGING 0 /* Reflects order in _(state,...) above     */
 #define CHGST_CHARGING    1 /* Also, much code assumes exactly          */
@@ -132,8 +132,9 @@ typedef struct batinfo_field {
 #define CHGST_ERROR       8 /* Except that this one is an extra bit.    */
 
 #define TYPE_MAINS        0 /* Reflects order in _(type,...) above        */
-#define TYPE_BATTERY      1 /* Also, much code assumes exactly these two  */
-#define TYPE_BOTH       100 /* Except this is a magic invalid value.      */
+#define TYPE_BATTERY      1 /* We want exactly one of MAINS & BATTERY     */
+#define TYPE_USB          2 /* These get ignored.                         */
+#define TYPE_BOTH       100 /* This is a magic invalid value.             */
 
 #define SEPARATE_QUANTITY_FIELDS(_)		\
   /* See commit ec6f5f0be800bc5f2a27046833dba04e0c67ffac for
@@ -243,10 +244,15 @@ 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(batlinevalue,&ep,10);
+    *field->valuep= strtoull(usevalue,&ep,10);
     if (*ep)
-      batfailf("value number syntax incorrect");
+      return batfailf("value number syntax incorrect");
 
   } else {
 	
@@ -255,7 +261,7 @@ static int parse_value(const fileinfo *cfile, const batinfo_field *field) {
 	 *enumsearch && strcmp(*enumsearch,batlinevalue);
 	 (*field->valuep)++, enumsearch++);
     if (!*enumsearch)
-      batfailf("unknown enum value");
+      return batfailf("unknown enum value");
 
   }
   return 0;
@@ -396,6 +402,9 @@ ALL_ACCUMULATE_FIELDS(Q_ZERO)
     r= readbattery();
     tidybattery();
 
+    if (this_type >= TYPE_USB)
+      continue;
+
     if (r) {
     bad:
       charging_mask |= (1u << CHGST_ERROR);
diff --git a/debian/changelog b/debian/changelog
index f04640e..f34aace 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+chiark-utils (8.0.1) unstable; urgency=medium
+
+  * Fix xbatmon-simple compatibility with kernel 6.12.35, which reports
+    negative POWER_SUPPLY_CHARGE_FULL resulting in alarming entirely-red
+    display.  Closes: #1109342.
+
+ -- Ian Jackson <ijackson@chiark.greenend.org.uk>  Tue, 15 Jul 2025 17:05:42 +0100
+
 chiark-utils (8.0.0) unstable; urgency=medium
 
   * Rewrite the packaging to use `debhelper` and `dh` in as standard a way

--- End Message ---
--- Begin Message ---
Unblocked chiark-utils.

--- End Message ---

Reply to: