Re: [PATCH] wifi: brcm80211: use sizeof(*pointer) instead of sizeof(type)

From: Arend van Spriel
Date: Mon May 27 2024 - 08:55:33 EST


On 5/26/2024 5:53 PM, Erick Archer wrote:
It is preferred to use sizeof(*pointer) instead of sizeof(type)
due to the type of the variable can change and one needs not
change the former (unlike the latter). This patch has no effect
on runtime behavior.

Thanks. A bit long list, but mostly trivial. Just a few remarks...

Acked-by: Arend van Spriel <arend.vanspriel@xxxxxxxxxxxx>
Signed-off-by: Erick Archer <erick.archer@xxxxxxxxxxx>
---
.../broadcom/brcm80211/brcmfmac/bcmsdh.c | 4 ++--
.../broadcom/brcm80211/brcmfmac/btcoex.c | 2 +-
.../broadcom/brcm80211/brcmfmac/sdio.c | 2 +-
.../broadcom/brcm80211/brcmfmac/usb.c | 2 +-
.../broadcom/brcm80211/brcmsmac/aiutils.c | 2 +-
.../broadcom/brcm80211/brcmsmac/ampdu.c | 2 +-
.../broadcom/brcm80211/brcmsmac/antsel.c | 2 +-
.../broadcom/brcm80211/brcmsmac/channel.c | 2 +-
.../broadcom/brcm80211/brcmsmac/dma.c | 2 +-
.../broadcom/brcm80211/brcmsmac/mac80211_if.c | 2 +-
.../broadcom/brcm80211/brcmsmac/main.c | 23 +++++++++----------
.../broadcom/brcm80211/brcmsmac/phy/phy_cmn.c | 4 ++--
.../broadcom/brcm80211/brcmsmac/phy/phy_lcn.c | 2 +-
.../broadcom/brcm80211/brcmsmac/phy_shim.c | 2 +-
14 files changed, 26 insertions(+), 27 deletions(-)

[...]

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
index aae2cf95fe95..8696061bf2dd 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
@@ -4968,7 +4968,7 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi)
{
struct brcms_phy_lcnphy *pi_lcn;
- pi->u.pi_lcnphy = kzalloc(sizeof(struct brcms_phy_lcnphy), GFP_ATOMIC);
+ pi->u.pi_lcnphy = kzalloc(sizeof(*pi->u.pi_lcnphy), GFP_ATOMIC);
Better use pi_lcn here and assign it to pi->u.pi_lcnphy after the if-statement.

if (pi->u.pi_lcnphy == NULL)
return false;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c
index b72381791536..4b916f3a087b 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c
@@ -40,7 +40,7 @@ struct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw,
struct brcms_c_info *wlc) {
struct phy_shim_info *physhim = NULL;

While at it please remove the redundant NULL initialization.

- physhim = kzalloc(sizeof(struct phy_shim_info), GFP_ATOMIC);
+ physhim = kzalloc(sizeof(*physhim), GFP_ATOMIC);
if (!physhim)
return NULL;

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature