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.
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;
}