git: 88e0df0b33e2 - main - asmc: compare integer results to zero explicitly

From: Abdelkader Boudih <seuros_at_FreeBSD.org>
Date: Mon, 09 Nov 2026 18:37:00 UTC
The branch main has been updated by seuros:

URL: https://cgit.FreeBSD.org/src/commit/?id=88e0df0b33e29fe593f1fc07a3847d8764f1ef1b

commit 88e0df0b33e29fe593f1fc07a3847d8764f1ef1b
Author:     Abdelkader Boudih <seuros@FreeBSD.org>
AuthorDate: 2026-11-09 18:36:05 +0000
Commit:     Abdelkader Boudih <seuros@FreeBSD.org>
CommitDate: 2026-11-09 18:36:05 +0000

    asmc: compare integer results to zero explicitly
    
    No functional change.
    
    MFC After: 1 Week
    Approved-by: ngie (co-mentor)
    
    Reviewed by:    ngie, adrian
    Differential Revision:  https://reviews.freebsd.org/D61303
---
 sys/dev/asmc/asmc.c        |  7 ++++---
 sys/dev/asmc/asmc_debug.c  |  8 ++++----
 sys/dev/asmc/asmc_pio.c    | 29 +++++++++++++++--------------
 sys/dev/asmc/asmc_sysctl.c |  4 ++--
 sys/dev/asmc/asmcmmio.c    |  2 +-
 5 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c
index cff1b3bf3311..3f43ff6d45d2 100644
--- a/sys/dev/asmc/asmc.c
+++ b/sys/dev/asmc/asmc.c
@@ -151,7 +151,8 @@ asmc_probe(device_t dev)
 	if (rv > 0)
 		return (rv);
 	product = kern_getenv("smbios.system.product");
-	device_set_descf(dev, "Apple %s", product ? product : "SMC");
+	device_set_descf(dev, "Apple %s",
+	    product != NULL ? product : "SMC");
 	freeenv(product);
 	return (rv);
 }
@@ -316,7 +317,7 @@ asmc_attach(device_t dev)
 
 	ret = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_MISC | INTR_MPSAFE,
 	    asmc_sms_intrfast, NULL, dev, &sc->sc_cookie);
-	if (ret) {
+	if (ret != 0) {
 		device_printf(dev, "unable to setup SMS IRQ\n");
 		goto err;
 	}
@@ -735,7 +736,7 @@ asmc_scan_sensor_range(device_t dev, unsigned int start,
 	char *sensor_key;
 
 	for (unsigned int i = start; i < end; i++) {
-		if (asmc_key_dump_by_index(dev, i, key, type, &len))
+		if (asmc_key_dump_by_index(dev, i, key, type, &len) != 0)
 			continue;
 		if (len != 2 || (prefix != '\0' && key[0] != prefix))
 			continue;
diff --git a/sys/dev/asmc/asmc_debug.c b/sys/dev/asmc/asmc_debug.c
index 29d7983d1a8e..311f2476fe9d 100644
--- a/sys/dev/asmc/asmc_debug.c
+++ b/sys/dev/asmc/asmc_debug.c
@@ -40,13 +40,13 @@ asmc_key_dump(device_t dev, int number)
 	int error;
 
 	error = asmc_key_dump_by_index(dev, number, key, type, &len);
-	if (error)
+	if (error != 0)
 		return (error);
 
 	len = MIN(len, sizeof(v));
 	memset(v, 0, sizeof(v));
 	error = asmc_key_read(dev, key, v, len);
-	if (error)
+	if (error != 0)
 		return (error);
 
 	sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
@@ -94,7 +94,7 @@ asmc_raw_key_sysctl(SYSCTL_HANDLER_ARGS)
 
 	strlcpy(newkey, sc->sc_rawkey, sizeof(newkey));
 	error = sysctl_handle_string(oidp, newkey, sizeof(newkey), req);
-	if (error || req->newptr == NULL)
+	if (error != 0 || req->newptr == NULL)
 		return (error);
 
 	if (strlen(newkey) != ASMC_KEYLEN)
@@ -137,7 +137,7 @@ asmc_raw_value_sysctl(SYSCTL_HANDLER_ARGS)
 	hexbuf[i * 2] = '\0';
 
 	error = sysctl_handle_string(oidp, hexbuf, sizeof(hexbuf), req);
-	if (error || req->newptr == NULL)
+	if (error != 0 || req->newptr == NULL)
 		return (error);
 
 	/* Reject writes until a key is selected via raw.key. */
diff --git a/sys/dev/asmc/asmc_pio.c b/sys/dev/asmc/asmc_pio.c
index d39dd55bd103..d349b20da45b 100644
--- a/sys/dev/asmc/asmc_pio.c
+++ b/sys/dev/asmc/asmc_pio.c
@@ -105,7 +105,7 @@ asmc_pio_send(device_t dev, const uint8_t *buf, int len, uint8_t status)
 
 	for (int i = 0; i < len; i++) {
 		ASMC_DATAPORT_WRITE(sc, buf[i]);
-		if (asmc_wait(dev, status))
+		if (asmc_wait(dev, status) != 0)
 			return (1);
 	}
 
@@ -119,7 +119,7 @@ asmc_pio_recv(device_t dev, uint8_t *buf, int len, uint8_t status)
 	struct asmc_softc *sc = device_get_softc(dev);
 
 	for (int i = 0; i < len; i++) {
-		if (asmc_wait(dev, status))
+		if (asmc_wait(dev, status) != 0)
 			return (1);
 		buf[i] = ASMC_DATAPORT_READ(sc);
 	}
@@ -139,10 +139,11 @@ asmc_pio_getbyindex_locked(device_t dev, int index, uint8_t *key)
 	index_buf[2] = (index >> 8) & 0xff;
 	index_buf[3] = index & 0xff;
 
-	if (asmc_command(dev, ASMC_CMDGETBYINDEX))
+	if (asmc_command(dev, ASMC_CMDGETBYINDEX) != 0)
 		return (1);
 
-	if (asmc_pio_send(dev, index_buf, ASMC_KEYLEN, ASMC_STATUS_AWAIT_DATA))
+	if (asmc_pio_send(dev, index_buf, ASMC_KEYLEN,
+	    ASMC_STATUS_AWAIT_DATA) != 0)
 		return (1);
 
 	ASMC_DATAPORT_WRITE(sc, ASMC_KEYLEN);
@@ -156,10 +157,10 @@ asmc_pio_getinfo_locked(device_t dev, const uint8_t *key, uint8_t *info)
 {
 	struct asmc_softc *sc = device_get_softc(dev);
 
-	if (asmc_command(dev, ASMC_CMDGETINFO))
+	if (asmc_command(dev, ASMC_CMDGETINFO) != 0)
 		return (1);
 
-	if (asmc_pio_send(dev, key, ASMC_KEYLEN, ASMC_STATUS_AWAIT_DATA))
+	if (asmc_pio_send(dev, key, ASMC_KEYLEN, ASMC_STATUS_AWAIT_DATA) != 0)
 		return (1);
 
 	ASMC_DATAPORT_WRITE(sc, ASMC_KEYINFO_RESPLEN);
@@ -189,21 +190,21 @@ asmc_pio_key_read(device_t dev, const char *key, uint8_t *buf, uint8_t len)
 	mtx_lock_spin(&sc->sc_mtx);
 
 begin:
-	if (asmc_command(dev, ASMC_CMDREAD))
+	if (asmc_command(dev, ASMC_CMDREAD) != 0)
 		goto out;
 
 	if (asmc_pio_send(dev, (const uint8_t *)key, ASMC_KEYLEN,
-	    ASMC_STATUS_AWAIT_DATA))
+	    ASMC_STATUS_AWAIT_DATA) != 0)
 		goto out;
 
 	ASMC_DATAPORT_WRITE(sc, len);
 
-	if (asmc_pio_recv(dev, buf, len, ASMC_STATUS_DATA_READY))
+	if (asmc_pio_recv(dev, buf, len, ASMC_STATUS_DATA_READY) != 0)
 		goto out;
 
 	error = 0;
 out:
-	if (error) {
+	if (error != 0) {
 		if (++try < 10)
 			goto begin;
 		device_printf(dev, "%s for key %s failed %d times, giving up\n",
@@ -289,12 +290,12 @@ asmc_pio_key_write(device_t dev, const char *key, uint8_t *buf, uint8_t len)
 
 begin:
 	ASMC_DPRINTF(("cmd port: cmd write\n"));
-	if (asmc_command(dev, ASMC_CMDWRITE))
+	if (asmc_command(dev, ASMC_CMDWRITE) != 0)
 		goto out;
 
 	ASMC_DPRINTF(("data port: key\n"));
 	if (asmc_pio_send(dev, (const uint8_t *)key, ASMC_KEYLEN,
-	    ASMC_STATUS_AWAIT_DATA))
+	    ASMC_STATUS_AWAIT_DATA) != 0)
 		goto out;
 
 	ASMC_DPRINTF(("data port: length\n"));
@@ -302,14 +303,14 @@ begin:
 
 	ASMC_DPRINTF(("data port: buffer\n"));
 	for (int i = 0; i < len; i++) {
-		if (asmc_wait(dev, ASMC_STATUS_AWAIT_DATA))
+		if (asmc_wait(dev, ASMC_STATUS_AWAIT_DATA) != 0)
 			goto out;
 		ASMC_DATAPORT_WRITE(sc, buf[i]);
 	}
 
 	error = 0;
 out:
-	if (error) {
+	if (error != 0) {
 		if (++try < 10)
 			goto begin;
 		device_printf(dev, "%s for key %s failed %d times, giving up\n",
diff --git a/sys/dev/asmc/asmc_sysctl.c b/sys/dev/asmc/asmc_sysctl.c
index 6a6e482e9d63..d832e717c83e 100644
--- a/sys/dev/asmc/asmc_sysctl.c
+++ b/sys/dev/asmc/asmc_sysctl.c
@@ -788,7 +788,7 @@ asmc_mb_sysctl_fanmanual(SYSCTL_HANDLER_ARGS)
 		error = asmc_key_read(dev, fmkey, buf, 1);
 		if (error != 0)
 			return (error);
-		v = buf[0] ? 1 : 0;
+		v = buf[0] != 0 ? 1 : 0;
 
 		error = sysctl_handle_int(oidp, &v, 0, req);
 		if (error == 0 && req->newptr != NULL) {
@@ -823,7 +823,7 @@ asmc_mb_sysctl_fanmanual(SYSCTL_HANDLER_ARGS)
 			val = (buf[0] << 8) | buf[1];
 
 			/* Modify single bit */
-			if (v) {
+			if (v != 0) {
 				val |= (1 << fan);   /* Set to manual */
 			} else {
 				val &= ~(1 << fan);  /* Set to auto */
diff --git a/sys/dev/asmc/asmcmmio.c b/sys/dev/asmc/asmcmmio.c
index a083fa42e439..286aca7273ae 100644
--- a/sys/dev/asmc/asmcmmio.c
+++ b/sys/dev/asmc/asmcmmio.c
@@ -65,7 +65,7 @@ asmc_mmio_key_read(device_t dev, const char *key, uint8_t *buf, uint8_t len)
 	mtx_lock_spin(&sc->sc_mtx);
 
 	/* Clear status if non-zero */
-	if (bus_read_1(sc->sc_iomem, ASMC_MMIO_STATUS))
+	if (bus_read_1(sc->sc_iomem, ASMC_MMIO_STATUS) != 0)
 		bus_write_1(sc->sc_iomem, ASMC_MMIO_STATUS, 0);
 
 	/* Write key name as raw 4 bytes */