* [PATCH] can: isotp: make const array static, makes object smaller
@ 2020-10-20 15:42 Colin King
2020-10-20 15:52 ` Marc Kleine-Budde
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2020-10-20 15:42 UTC (permalink / raw)
To: Oliver Hartkopp, Marc Kleine-Budde, David S . Miller,
Jakub Kicinski, linux-can, netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Don't populate the const array plen on the stack but instead it
static. Makes the object code smaller by 926 bytes.
Before:
text data bss dec hex filename
26531 1943 64 28538 6f7a net/can/isotp.o
After:
text data bss dec hex filename
25509 2039 64 27612 6bdc net/can/isotp.o
(gcc version 10.2.0)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
net/can/isotp.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/net/can/isotp.c b/net/can/isotp.c
index 4c2062875893..3fd714f81875 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -252,14 +252,16 @@ static void isotp_rcv_skb(struct sk_buff *skb, struct sock *sk)
static u8 padlen(u8 datalen)
{
- const u8 plen[] = {8, 8, 8, 8, 8, 8, 8, 8, 8, /* 0 - 8 */
- 12, 12, 12, 12, /* 9 - 12 */
- 16, 16, 16, 16, /* 13 - 16 */
- 20, 20, 20, 20, /* 17 - 20 */
- 24, 24, 24, 24, /* 21 - 24 */
- 32, 32, 32, 32, 32, 32, 32, 32, /* 25 - 32 */
- 48, 48, 48, 48, 48, 48, 48, 48, /* 33 - 40 */
- 48, 48, 48, 48, 48, 48, 48, 48}; /* 41 - 48 */
+ static const u8 plen[] = {
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, /* 0 - 8 */
+ 12, 12, 12, 12, /* 9 - 12 */
+ 16, 16, 16, 16, /* 13 - 16 */
+ 20, 20, 20, 20, /* 17 - 20 */
+ 24, 24, 24, 24, /* 21 - 24 */
+ 32, 32, 32, 32, 32, 32, 32, 32, /* 25 - 32 */
+ 48, 48, 48, 48, 48, 48, 48, 48, /* 33 - 40 */
+ 48, 48, 48, 48, 48, 48, 48, 48 /* 41 - 48 */
+ };
if (datalen > 48)
return 64;
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] can: isotp: make const array static, makes object smaller
2020-10-20 15:42 [PATCH] can: isotp: make const array static, makes object smaller Colin King
@ 2020-10-20 15:52 ` Marc Kleine-Budde
0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2020-10-20 15:52 UTC (permalink / raw)
To: Colin King, Oliver Hartkopp, David S . Miller, Jakub Kicinski,
linux-can, netdev
Cc: kernel-janitors, linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 883 bytes --]
On 10/20/20 5:42 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Don't populate the const array plen on the stack but instead it
> static. Makes the object code smaller by 926 bytes.
>
> Before:
> text data bss dec hex filename
> 26531 1943 64 28538 6f7a net/can/isotp.o
>
> After:
> text data bss dec hex filename
> 25509 2039 64 27612 6bdc net/can/isotp.o
>
> (gcc version 10.2.0)
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
applied to linux-can/testing.
Thanks,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-20 15:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-20 15:42 [PATCH] can: isotp: make const array static, makes object smaller Colin King
2020-10-20 15:52 ` Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).