svn commit: r364871 - head/sys/dev/asmc
Mark Johnston
markj at FreeBSD.org
Thu Aug 27 16:34:21 UTC 2020
Author: markj
Date: Thu Aug 27 16:34:20 2020
New Revision: 364871
URL: https://svnweb.freebsd.org/changeset/base/364871
Log:
asmc(4): Handle errors from asmc_key_read() properly.
asmc_key_read() returns only 0 and 1, some callers were checking
incorrectly for failure.
PR: 248939
Submitted by: Tong Zhang <ztong0001 at gmail.com>
MFC after: 1 week
Modified:
head/sys/dev/asmc/asmc.c
Modified: head/sys/dev/asmc/asmc.c
==============================================================================
--- head/sys/dev/asmc/asmc.c Thu Aug 27 14:51:44 2020 (r364870)
+++ head/sys/dev/asmc/asmc.c Thu Aug 27 16:34:20 2020 (r364871)
@@ -1073,7 +1073,7 @@ asmc_fan_count(device_t dev)
{
uint8_t buf[1];
- if (asmc_key_read(dev, ASMC_KEY_FANCOUNT, buf, sizeof buf) < 0)
+ if (asmc_key_read(dev, ASMC_KEY_FANCOUNT, buf, sizeof buf) != 0)
return (-1);
return (buf[0]);
@@ -1087,7 +1087,7 @@ asmc_fan_getvalue(device_t dev, const char *key, int f
char fankey[5];
snprintf(fankey, sizeof(fankey), key, fan);
- if (asmc_key_read(dev, fankey, buf, sizeof buf) < 0)
+ if (asmc_key_read(dev, fankey, buf, sizeof buf) != 0)
return (-1);
speed = (buf[0] << 6) | (buf[1] >> 2);
@@ -1101,7 +1101,7 @@ asmc_fan_getstring(device_t dev, const char *key, int
char* desc;
snprintf(fankey, sizeof(fankey), key, fan);
- if (asmc_key_read(dev, fankey, buf, buflen) < 0)
+ if (asmc_key_read(dev, fankey, buf, buflen) != 0)
return (NULL);
desc = buf+4;
@@ -1240,7 +1240,7 @@ asmc_temp_getvalue(device_t dev, const char *key)
/*
* Check for invalid temperatures.
*/
- if (asmc_key_read(dev, key, buf, sizeof buf) < 0)
+ if (asmc_key_read(dev, key, buf, sizeof buf) != 0)
return (-1);
return (buf[0]);
More information about the svn-src-all
mailing list