From 6e6a1f59e83a56bf5b3c9c4d4fbe0dff497896db Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Fri, 1 Jan 2010 14:49:35 -0800 Subject: [PATCH] Fix hddtemp with disabled drives. Some drives are unable to return their temperature when in standby mode. If there is more than one drive installed then other drives may not be able to get parsed. This patch will skip over the unparsable output for the current drive and let others get parsed. Signed-off-by: Brenden Matthews --- src/hddtemp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hddtemp.c b/src/hddtemp.c index e5a47598..93b79a07 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -173,6 +173,7 @@ static int read_hdd_val(const char *line, char **dev, short *val, char *unit, } line_s = *saveptr; +again: /* read the device */ *dev = ++p; if (!(p = strchr(p, line_s[0]))) @@ -188,8 +189,13 @@ static int read_hdd_val(const char *line, char **dev, short *val, char *unit, *(p++) = '\0'; *unit = *(p++); *val = strtol(cval, &endptr, 10); - if (*endptr) - goto out_fail; + if (*endptr) { + if (!(p = strchr(p, line_s[0]))) + goto out_fail; + + p++; + goto again; + } /* preset p for next call */ p++;