From: Peter Wu Date: Tue, 31 Mar 2015 21:17:32 +0000 (+0200) Subject: battery: do not report sysfs ENODEV failure X-Git-Tag: collectd-5.5.0~43^2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=125f3bece6725fba00e5961882692bd671e38bcb;p=collectd.git 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. --- 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; }