From cd3c084957483c4192edf2e8feb4c759668a1055 Mon Sep 17 00:00:00 2001 From: "Ali H. Fardan" Date: Wed, 31 Aug 2016 06:00:14 +0300 Subject: [PATCH] slow down boy! you opened the file too early! --- slstatus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/slstatus.c b/slstatus.c index 163b44e..5246bc0 100644 --- a/slstatus.c +++ b/slstatus.c @@ -105,7 +105,7 @@ battery_perc(const char *battery) int now, full, perc; char batterynowfile[64]; char batteryfullfile[64]; - FILE *fp = fopen(batterynowfile, "r"); + FILE *fp; strlcpy(batterynowfile, BATTERY_PATH, sizeof(batterynowfile)); strlcat(batterynowfile, battery, sizeof(batterynowfile)); @@ -117,6 +117,7 @@ battery_perc(const char *battery) strlcat(batteryfullfile, "/", sizeof(batteryfullfile)); strlcat(batteryfullfile, BATTERY_FULL, sizeof(batteryfullfile)); + fp = fopen(batterynowfile, "r"); if (fp == NULL ) { fprintf(stderr, "Error opening battery file: %s: %s\n", batterynowfile,