summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Fiddaman <omnios@citrus-it.co.uk>2022-07-25 20:54:21 +0000
committerAndy Fiddaman <omnios@citrus-it.co.uk>2022-07-26 14:55:29 +0000
commitce17336ed725d3b7fdff67bf0a0ee2b55018fec6 (patch)
treec0ce3edf86bd30c812879916c192b1866fd61e5a
parentfe441c7591b77f09d92eddfd633b49b4ccc92027 (diff)
downloadillumos-gate-ce17336ed725d3b7fdff67bf0a0ee2b55018fec6.tar.gz
14852 Enable smatch 'sizeof' checks in the kernel
Reviewed by: Jason King <jason.brian.king+illumos@gmail.com> Reviewed by: Dan McDonald <danmcd@mnx.io> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Gordon Ross <gordon.w.ross@gmail.com>
-rw-r--r--usr/src/uts/Makefile.uts6
-rw-r--r--usr/src/uts/common/io/bridge.c2
-rw-r--r--usr/src/uts/common/io/fibre-channel/fca/oce/oce_gld.c2
-rw-r--r--usr/src/uts/common/io/fibre-channel/fca/qlge/qlge.c2
-rw-r--r--usr/src/uts/common/io/nxge/nxge_main.c2
-rw-r--r--usr/src/uts/common/sys/sockio.h14
-rw-r--r--usr/src/uts/i86pc/io/acpi_drv/acpi_drv.c4
7 files changed, 13 insertions, 19 deletions
diff --git a/usr/src/uts/Makefile.uts b/usr/src/uts/Makefile.uts
index 841e84e40a..db66dd229d 100644
--- a/usr/src/uts/Makefile.uts
+++ b/usr/src/uts/Makefile.uts
@@ -184,12 +184,6 @@ CERRWARN += -_smatch=-p=illumos_kernel
include $(SRC)/Makefile.smatch
#
-# Unfortunately, _IOWR() is regularly used with a third argument of 0,
-# so we have to disable all these smatch checks.
-#
-SMOFF += sizeof
-
-#
# Ensure that the standard function prologue remains at the very start
# of a function, so DTrace fbt will instrument the right place.
#
diff --git a/usr/src/uts/common/io/bridge.c b/usr/src/uts/common/io/bridge.c
index 389948e295..1f7d3fa680 100644
--- a/usr/src/uts/common/io/bridge.c
+++ b/usr/src/uts/common/io/bridge.c
@@ -504,7 +504,7 @@ bridge_m_getprop(void *arg, const char *pr_name, mac_prop_id_t pr_num,
switch (pr_num) {
case MAC_PROP_STATUS:
ASSERT(pr_valsize >= sizeof (bmp->bm_linkstate));
- bcopy(&bmp->bm_linkstate, pr_val, sizeof (&bmp->bm_linkstate));
+ bcopy(&bmp->bm_linkstate, pr_val, sizeof (bmp->bm_linkstate));
break;
default:
diff --git a/usr/src/uts/common/io/fibre-channel/fca/oce/oce_gld.c b/usr/src/uts/common/io/fibre-channel/fca/oce/oce_gld.c
index 846f8896d9..b16d6434b3 100644
--- a/usr/src/uts/common/io/fibre-channel/fca/oce/oce_gld.c
+++ b/usr/src/uts/common/io/fibre-channel/fca/oce/oce_gld.c
@@ -174,7 +174,7 @@ oce_m_multicast(void *arg, boolean_t add, const uint8_t *mca)
return (EINVAL);
}
/* Allocate the local array for holding the addresses temporarily */
- bzero(&mca_hw_list, sizeof (&mca_hw_list));
+ bzero(&mca_hw_list, sizeof (mca_hw_list));
mca_drv_list = &dev->multi_cast[0];
DEV_LOCK(dev);
diff --git a/usr/src/uts/common/io/fibre-channel/fca/qlge/qlge.c b/usr/src/uts/common/io/fibre-channel/fca/qlge/qlge.c
index cf20b75a66..239ac6f624 100644
--- a/usr/src/uts/common/io/fibre-channel/fca/qlge/qlge.c
+++ b/usr/src/uts/common/io/fibre-channel/fca/qlge/qlge.c
@@ -3388,7 +3388,7 @@ ql_alloc_tx_resources(qlge_t *qlge, struct tx_ring *tx_ring)
(size_t)128, /* alignment:128 bytes boundary */
(caddr_t *)&tx_ring->wq_dma.vaddr,
&dma_cookie) != 0) {
- bzero(&tx_ring->wq_dma, sizeof (&tx_ring->wq_dma));
+ bzero(&tx_ring->wq_dma, sizeof (tx_ring->wq_dma));
cmn_err(CE_WARN, "%s(%d): reqQ allocation failed.",
__func__, qlge->instance);
return (DDI_FAILURE);
diff --git a/usr/src/uts/common/io/nxge/nxge_main.c b/usr/src/uts/common/io/nxge/nxge_main.c
index 26da4c5af0..8c21366225 100644
--- a/usr/src/uts/common/io/nxge/nxge_main.c
+++ b/usr/src/uts/common/io/nxge/nxge_main.c
@@ -6533,7 +6533,7 @@ nxge_mac_register(p_nxge_t nxgep)
} else {
macp->m_src_addr = KMEM_ZALLOC(MAXMACADDRLEN, KM_SLEEP);
macp->m_dst_addr = KMEM_ZALLOC(MAXMACADDRLEN, KM_SLEEP);
- (void) memset(macp->m_src_addr, 0xff, sizeof (MAXMACADDRLEN));
+ (void) memset(macp->m_src_addr, 0xff, MAXMACADDRLEN);
}
macp->m_callbacks = &nxge_m_callbacks;
macp->m_min_sdu = 0;
diff --git a/usr/src/uts/common/sys/sockio.h b/usr/src/uts/common/sys/sockio.h
index 40613c2a30..5f020ac99d 100644
--- a/usr/src/uts/common/sys/sockio.h
+++ b/usr/src/uts/common/sys/sockio.h
@@ -253,7 +253,7 @@ extern "C" {
/*
* IOCTL private to sockfs.
*/
-#define _SIOCSOCKFALLBACK _IOW('i', 169, 0)
+#define _SIOCSOCKFALLBACK _IOW('i', 169, int)
/*
* IOCTLs for getting and setting zone associated with an interface, and
@@ -287,15 +287,15 @@ extern "C" {
* source filter for a particular multicast group. Argument is
* a struct group_filter. Defined in RFC 3678.
*/
-#define SIOCGMSFILTER _IOWR('i', 178, 0)
-#define SIOCSMSFILTER _IOW('i', 179, 0)
+#define SIOCGMSFILTER _IOWR('i', 178, int)
+#define SIOCSMSFILTER _IOW('i', 179, int)
/*
* IPv4-specific versions of the above; get or set a socket's source
* filter for a particular multicast group, for PF_INET sockets only.
* Argument is a struct ip_msfilter.
*/
-#define SIOCGIPMSFILTER _IOWR('i', 180, 0)
-#define SIOCSIPMSFILTER _IOW('i', 181, 0)
+#define SIOCGIPMSFILTER _IOWR('i', 180, int)
+#define SIOCSIPMSFILTER _IOW('i', 181, int)
/*
* 182 can be reused (was consolidation-private SIOCSIPMPFAILBACK).
@@ -316,14 +316,14 @@ extern "C" {
/*
* Private ioctl for Integrated Load Balancer. The ioctl length varies.
*/
-#define SIOCILB _IOWR('i', 187, 0)
+#define SIOCILB _IOWR('i', 187, int)
/*
* IOCTL's to get/set module specific or interface specific properties.
* Argument is a struct mod_ioc_prop_s. These ioctls are Consolidation Private.
*/
#define SIOCGETPROP _IOWRN('p', 188, 0)
-#define SIOCSETPROP _IOW('p', 189, 0)
+#define SIOCSETPROP _IOW('p', 189, int)
/*
* IOCTL used to check for the given ipif, whether DAD is in progress or
diff --git a/usr/src/uts/i86pc/io/acpi_drv/acpi_drv.c b/usr/src/uts/i86pc/io/acpi_drv/acpi_drv.c
index c40b2d8c02..da3a84fedc 100644
--- a/usr/src/uts/i86pc/io/acpi_drv/acpi_drv.c
+++ b/usr/src/uts/i86pc/io/acpi_drv/acpi_drv.c
@@ -607,7 +607,7 @@ acpi_drv_cbat_ioctl(int index, int cmd, intptr_t arg, int mode, cred_t *cr,
bwarn.bw_enabled = acpi_drv_warn_enabled;
bwarn.bw_charge_warn = acpi_drv_syn_warn_per;
bwarn.bw_charge_low = acpi_drv_syn_low_per;
- if (copyout(&bwarn, (void *)arg, sizeof (&bwarn))) {
+ if (copyout(&bwarn, (void *)arg, sizeof (bwarn))) {
res = EFAULT;
}
break;
@@ -731,7 +731,7 @@ acpi_drv_lid_ioctl(int index, int cmd, intptr_t arg, int mode, cred_t *cr,
/*ARGSUSED*/
static int
acpi_drv_chpoll(dev_t dev, short events, int anyyet, short *reventsp,
- struct pollhead **phpp)
+ struct pollhead **phpp)
{
if (!anyyet) {
*phpp = &acpi_drv_pollhead;