From 9106fb165b5df2c7f20b2ff07382b170a08da867 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Wed, 29 Jan 2020 05:42:24 +0000 Subject: bnxt(4): Eliminate wrong sizeof() expression in memset() While here, clean up magic numbers. The memset(,0,) (and M_ZERO!) can just be removed; the bit_alloc() API already zeros the allocation. No functional change. Reported by: Coverity CID: 1378286 --- sys/dev/bnxt/bnxt_hwrm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'sys') diff --git a/sys/dev/bnxt/bnxt_hwrm.c b/sys/dev/bnxt/bnxt_hwrm.c index cbf76ba13b4a..8023051be37f 100644 --- a/sys/dev/bnxt/bnxt_hwrm.c +++ b/sys/dev/bnxt/bnxt_hwrm.c @@ -1778,16 +1778,14 @@ int bnxt_hwrm_func_rgtr_async_events(struct bnxt_softc *softc, unsigned long *bm uint32_t *events; int i; - async_events_bmap = bit_alloc(256, M_DEVBUF, M_WAITOK|M_ZERO); - events = (uint32_t *)async_events_bmap; +#define AE_BMAP_SZ_BITS 256 + async_events_bmap = bit_alloc(AE_BMAP_SZ_BITS, M_DEVBUF, M_WAITOK); bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_DRV_RGTR); req.enables = htole32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_ASYNC_EVENT_FWD); - memset(async_events_bmap, 0, sizeof(256 / 8)); - bit_set(async_events_bmap, HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE); bit_set(async_events_bmap, HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD); bit_set(async_events_bmap, HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED); @@ -1801,8 +1799,12 @@ int bnxt_hwrm_func_rgtr_async_events(struct bnxt_softc *softc, unsigned long *bm } } - for (i = 0; i < 8; i++) +#define AE_BMAP_SZ_WORDS (AE_BMAP_SZ_BITS / 8 / sizeof(uint32_t)) + events = (uint32_t *)async_events_bmap; + for (i = 0; i < AE_BMAP_SZ_WORDS; i++) req.async_event_fwd[i] |= htole32(events[i]); +#undef AE_BMAP_SZ_WORDS +#undef AE_BMAP_SZ_BITS free(async_events_bmap, M_DEVBUF); -- cgit v1.3