Fix hddtemp with disabled drives.
authorBen Kibbey <benkibbey@users.sourceforge.net>
Fri, 1 Jan 2010 22:49:35 +0000 (14:49 -0800)
committerBrenden Matthews <brenden@diddyinc.com>
Fri, 1 Jan 2010 22:55:39 +0000 (14:55 -0800)
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 <brenden@diddyinc.com>

src/hddtemp.c

index 315664e..b3de87d 100644 (file)
@@ -171,6 +171,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])))
@@ -186,8 +187,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++;