Skip to contentSkip to conversation

net: 3c509: make the array if_names static const, makes object smaller

PATCH Applied Colin King 2 participants 2 messages Aug 1, 2021 – Aug 2, 2021

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 net: 3c509: make the array if_names static const, makes object smaller

From: Colin Ian King <[email protected]>

Don't populate the array if_names on the stack but instead it static const. Makes the object code smaller by 99 bytes.

Before:
text data bss dec hex filename
27886 10752 672 39310 998e ./drivers/net/ethernet/3com/3c509.o

After:
text data bss dec hex filename
27723 10816 672 39211 992b ./drivers/net/ethernet/3com/3c509.o

(gcc version 10.2.0)

---
 drivers/net/ethernet/3com/3c509.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/3com/3c509.c +3 -1
index 96cc5fc36eb5..00c4b038be49 100644
@@ -514,7 +514,9 @@ static int el3_common_init(struct net_device *dev)
 {
 	struct el3_private *lp = netdev_priv(dev);
 	int err;
-	const char *if_names[] = {"10baseT", "AUI", "undefined", "BNC"};
+	static const char * const if_names[] = {
+		"10baseT", "AUI", "undefined", "BNC"
+	};
 
 	spin_lock_init(&lp->lock);
 
Signature · 1 line
2.31.1
#1 lore raw
This patch was applied to netdev/net-next.git (refs/heads/master):

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

Quoted 10 lines · On Sun, 1 Aug 2021 16:26:50 +0100 you wrote:

From: Colin Ian King <[email protected]>

Don't populate the array if_names on the stack but instead it static const. Makes the object code smaller by 99 bytes.

Before:
text data bss dec hex filename
27886 10752 672 39310 998e ./drivers/net/ethernet/3com/3c509.o

[...]

Here is the summary with links:
- net: 3c509: make the array if_names static const, makes object smaller

    https://git.kernel.org/netdev/net-next/c/771edeabcb95

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html