Date: Thu, 27 Aug 2020 16:34:20 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r364871 - head/sys/dev/asmc Message-ID: <202008271634.07RGYKu8033319@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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@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]);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008271634.07RGYKu8033319>