fix error reporting for battery_* variables
authorPhil <n0-1@users.sourceforge.net>
Mon, 1 Sep 2008 23:46:48 +0000 (23:46 +0000)
committerPhil <n0-1@users.sourceforge.net>
Mon, 1 Sep 2008 23:46:48 +0000 (23:46 +0000)
* 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

index 80d6974..7276fc0 100644 (file)
@@ -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) {