public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ethernet: sis900: use sizeof(*pointer) instead of sizeof(type)
@ 2024-06-08 10:20 Erick Archer
  2024-06-13  0:55 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Erick Archer @ 2024-06-08 10:20 UTC (permalink / raw)
  To: Daniele Venzano, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Kees Cook, Gustavo A. R. Silva, Justin Stitt
  Cc: Erick Archer, netdev, linux-kernel, linux-hardening

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).

At the same time remove some unnecessary initializations and
refactor a bit to make the code clearer.

This patch has no effect on runtime behavior.

Signed-off-by: Erick Archer <erick.archer@outlook.com>
---
 drivers/net/ethernet/sis/sis900.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c
index 85b850372efe..5b82c4763de9 100644
--- a/drivers/net/ethernet/sis/sis900.c
+++ b/drivers/net/ethernet/sis/sis900.c
@@ -614,11 +614,10 @@ static int sis900_mii_probe(struct net_device *net_dev)
 
 	/* search for total of 32 possible mii phy addresses */
 	for (phy_addr = 0; phy_addr < 32; phy_addr++) {
-		struct mii_phy * mii_phy = NULL;
+		struct mii_phy *mii_phy;
 		u16 mii_status;
 		int i;
 
-		mii_phy = NULL;
 		for(i = 0; i < 2; i++)
 			mii_status = mdio_read(net_dev, phy_addr, MII_STATUS);
 
@@ -630,7 +629,8 @@ static int sis900_mii_probe(struct net_device *net_dev)
 			continue;
 		}
 
-		if ((mii_phy = kmalloc(sizeof(struct mii_phy), GFP_KERNEL)) == NULL) {
+		mii_phy = kmalloc(sizeof(*mii_phy), GFP_KERNEL);
+		if (!mii_phy) {
 			mii_phy = sis_priv->first_mii;
 			while (mii_phy) {
 				struct mii_phy *phy;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-13  0:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-08 10:20 [PATCH] ethernet: sis900: use sizeof(*pointer) instead of sizeof(type) Erick Archer
2024-06-13  0:55 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox