diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2011-10-25 00:05:46 +0000 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2011-10-25 00:05:46 +0000 |
commit | d1b1cbc75715eb4f40a444d3a1d2741b3617b1f0 (patch) | |
tree | d7ba15bd1300fff66757d0178ed91b156312bf7c /BatteryMeter.c | |
parent | 75080ce79d2fb8ae895659326dacf688c8cb7ce9 (diff) |
cleanups and fixes, thanks to cppcheck and gcc -Wextra
Diffstat (limited to 'BatteryMeter.c')
-rw-r--r-- | BatteryMeter.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/BatteryMeter.c b/BatteryMeter.c index 1690a969..f7323aa9 100644 --- a/BatteryMeter.c +++ b/BatteryMeter.c @@ -45,7 +45,7 @@ static unsigned long int parseUevent(FILE * file, const char *key) { } static unsigned long int parseBatInfo(const char *fileName, const unsigned short int lineNum, const unsigned short int wordNum) { - const DIR *batteryDir; + DIR* batteryDir; const struct dirent *dirEntries; const char batteryPath[] = PROCDIR "/acpi/battery/"; @@ -89,6 +89,7 @@ static unsigned long int parseBatInfo(const char *fileName, const unsigned short snprintf((char *) infoPath, sizeof infoPath, "%s%s/%s", batteryPath, newEntry->content, fileName); if ((file = fopen(infoPath, "r")) == NULL) { + closedir(batteryDir); return 0; } @@ -107,7 +108,7 @@ static unsigned long int parseBatInfo(const char *fileName, const unsigned short free(myList); free(newEntry); - closedir((DIR *) batteryDir); + closedir(batteryDir); return total; } @@ -274,6 +275,7 @@ static double getSysBatData() { } else { //reset file pointer if (fseek(file, 0, SEEK_SET) < 0) { + closedir(power_supplyDir); fclose(file); return 0; } @@ -285,6 +287,7 @@ static double getSysBatData() { } else { //reset file pointer if (fseek(file, 0, SEEK_SET) < 0) { + closedir(power_supplyDir); fclose(file); return 0; } |