Bugfix: use localtime_r so that later calls in print_battery_info don’t overwrite the time

This commit is contained in:
Michael Stapelberg 2011-04-22 01:06:53 +02:00
parent 4fa8a4e0ab
commit 28934ef858

View File

@ -321,11 +321,14 @@ int main(int argc, char *argv[]) {
int interval = cfg_getint(cfg_general, "interval"); int interval = cfg_getint(cfg_general, "interval");
struct tm tm;
while (1) { while (1) {
time_t current_time = time(NULL); time_t current_time = time(NULL);
struct tm *current_tm = NULL; struct tm *current_tm = NULL;
if (current_time != (time_t) -1) if (current_time != (time_t) -1) {
current_tm = localtime(&current_time); localtime_r(&current_time, &tm);
current_tm = &tm;
}
for (j = 0; j < cfg_size(cfg, "order"); j++) { for (j = 0; j < cfg_size(cfg, "order"); j++) {
if (j > 0) if (j > 0)
print_seperator(); print_seperator();