From 8ddf4a054533691cebfc8b3244313cbcb3c68944 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 18 Jun 2015 09:16:18 +0200 Subject: [PATCH] battery plugin: Fix file descriptor leak. --- src/battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); -- 2.11.0