From 125f3bece6725fba00e5961882692bd671e38bcb Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Tue, 31 Mar 2015 23:17:32 +0200 Subject: [PATCH] battery: do not report sysfs ENODEV failure Linux reports ENODEV if the reported battery values are equal to ACPI_BATTERY_VALUE_UNKNOWN. This can be observed for an unpatched Clevo B7130 laptop while reading the "Battery Present Charge" attribute. Since this is a non-fatal, non-recoverable event, do not report such errors. Also change the error message to report the filename triggering this error to ease hunting down the error. --- src/battery.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/battery.c b/src/battery.c index f106da09..9b060dd9 100644 --- a/src/battery.c +++ b/src/battery.c @@ -416,10 +416,13 @@ static int sysfs_file_to_buffer(char const *dir, /* {{{ */ if (fgets (buffer, buffer_size, fp) == NULL) { - char errbuf[1024]; status = errno; - WARNING ("battery plugin: fgets failed: %s", - sstrerror (status, errbuf, sizeof (errbuf))); + if (status != ENODEV) + { + char errbuf[1024]; + WARNING ("battery plugin: fgets (%s) failed: %s", filename, + sstrerror (status, errbuf, sizeof (errbuf))); + } fclose (fp); return status; } -- 2.30.2