Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Jan 2020 05:42:24 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357248 - head/sys/dev/bnxt
Message-ID:  <202001290542.00T5gO3k028645@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Wed Jan 29 05:42:24 2020
New Revision: 357248
URL: https://svnweb.freebsd.org/changeset/base/357248

Log:
  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

Modified:
  head/sys/dev/bnxt/bnxt_hwrm.c

Modified: head/sys/dev/bnxt/bnxt_hwrm.c
==============================================================================
--- head/sys/dev/bnxt/bnxt_hwrm.c	Wed Jan 29 05:31:40 2020	(r357247)
+++ head/sys/dev/bnxt/bnxt_hwrm.c	Wed Jan 29 05:42:24 2020	(r357248)
@@ -1778,16 +1778,14 @@ int bnxt_hwrm_func_rgtr_async_events(struct bnxt_softc
 	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
 		}
 	}
 
-	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);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001290542.00T5gO3k028645>