From: Florian Forster Date: Thu, 18 Jun 2015 07:16:18 +0000 (+0200) Subject: battery plugin: Fix file descriptor leak. X-Git-Tag: collectd-5.5.1~104 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8ddf4a054533691cebfc8b3244313cbcb3c68944;p=collectd.git battery plugin: Fix file descriptor leak. --- diff --git a/src/battery.c b/src/battery.c index 9b060dd9..c4c050d7 100644 --- a/src/battery.c +++ b/src/battery.c @@ -556,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 */ @@ -615,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);