X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fbattery.c;h=0350a9eb1dae3b84bffdf84b6ebf2b33a27e48ed;hb=ff9e11ade5cfabf32c63fb19fc76cbbc4186bc5b;hp=f106da09bd4e2114cc82c2fb84de806a2db21960;hpb=af5eb0ca07aac94bf4ebf5429e9d5c2c1fb7d4e9;p=collectd.git diff --git a/src/battery.c b/src/battery.c index f106da09..0350a9eb 100644 --- a/src/battery.c +++ b/src/battery.c @@ -143,7 +143,7 @@ static void submit_capacity (char const *plugin_instance, /* {{{ */ } /* }}} void submit_capacity */ #if HAVE_IOKIT_PS_IOPOWERSOURCES_H || HAVE_IOKIT_IOKITLIB_H -static double dict_get_double (CFDictionaryRef dict, char *key_string) /* {{{ */ +static double dict_get_double (CFDictionaryRef dict, const char *key_string) /* {{{ */ { double val_double; long long val_int; @@ -341,7 +341,7 @@ static void get_via_generic_iokit (double *ret_capacity_full, /* {{{ */ *ret_voltage = temp_double / 1000.0; } } - + CFRelease (bat_root_dict); } @@ -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; } @@ -553,7 +556,7 @@ static int read_acpi_full_capacity (char const *dir, /* {{{ */ ssnprintf (filename, sizeof (filename), "%s/%s/info", dir, power_supply); fh = fopen (filename, "r"); - if ((fh = fopen (filename, "r")) == NULL) + if (fh == NULL) return (errno); /* last full capacity: 40090 mWh */ @@ -612,7 +615,7 @@ static int read_acpi_callback (char const *dir, /* {{{ */ ssnprintf (filename, sizeof (filename), "%s/%s/state", dir, power_supply); fh = fopen (filename, "r"); - if ((fh = fopen (filename, "r")) == NULL) + if (fh == NULL) { if ((errno == EAGAIN) || (errno == EINTR) || (errno == ENOENT)) return (0);