From 56ba0250abbe9a4949e3d6bfe5cb484dd5cc545d Mon Sep 17 00:00:00 2001 From: Phil Date: Mon, 1 Sep 2008 23:46:48 +0000 Subject: [PATCH] fix error reporting for battery_* variables * reproduce with a config displaying stuff for BAT0 and BAT1 while only BAT0 is installed: the call to get_battery_stuff() for the existent BAT0 will reset the static variable rep and the errors for BAT1 will be reported over and over again * this fix is not perfect: if both batteries are missing, only the first errors will be reported; but better than flooding the terminal git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1243 7f574dfc-610e-0410-a909-a81674777703 --- src/linux.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/linux.c b/src/linux.c index 80d69740..7276fc07 100644 --- a/src/linux.c +++ b/src/linux.c @@ -1582,7 +1582,7 @@ void set_return_value(char *buffer, unsigned int n, int item, int idx); void get_battery_stuff(char *buffer, unsigned int n, const char *bat, int item) { - static int idx, rep = 0, rep2 = 0; + static int idx, rep = 0, rep1 = 0, rep2 = 0; char acpi_path[128]; char sysfs_path[128]; @@ -1608,11 +1608,10 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat, int item) if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) { sysfs_bat_fp[idx] = open_file(sysfs_path, &rep); - rep = 0; } if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) { - acpi_bat_fp[idx] = open_file(acpi_path, &rep); + acpi_bat_fp[idx] = open_file(acpi_path, &rep1); } if (sysfs_bat_fp[idx] != NULL) {