X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fhddtemp.c;h=b1ba81ec8b76d7d392b7600c574983eeeb5e6ab5;hb=2d2a163728283108eb78c11d7b02bf5c54d88ea4;hp=12e6f24970a874a4c678f938d391aa80ef215991;hpb=f1b69e26a29bf8a5c3f91980dc4f15327d9e1b2a;p=monky diff --git a/src/hddtemp.c b/src/hddtemp.c index 12e6f24..b1ba81e 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -130,7 +130,7 @@ static char *fetch_hddtemp_output(void) close(sockfd); } if (!rp) { - NORM_ERR("could not connect to mpd host"); + NORM_ERR("could not connect to hddtemp host"); goto GET_OUT; } @@ -172,6 +172,8 @@ static int read_hdd_val(const char *line, char **dev, short *val, char *unit, line_s = *saveptr; again: + if(!*p) + goto out_fail; /* read the device */ *dev = ++p; if (!(p = strchr(p, line_s[0]))) @@ -204,29 +206,30 @@ out_fail: return 1; } -void update_hddtemp(void) { +int update_hddtemp(void) { char *data, *dev, unit, *saveptr; short val; static double last_hddtemp_update = 0.0; /* limit tcp connection overhead */ if (current_update_time - last_hddtemp_update < 5) - return; + return 0; last_hddtemp_update = current_update_time; free_hddtemp_info(); if (!(data = fetch_hddtemp_output())) - return; + return 0; if (read_hdd_val(data, &dev, &val, &unit, &saveptr)) { free(data); - return; + return 0; } do { add_hddtemp_info(dev, val, unit); } while (!read_hdd_val(NULL, &dev, &val, &unit, &saveptr)); free(data); + return 0; } void free_hddtemp(void)