Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1730826 > unrolled thread

[PATCH] usb: storage: make const arrays static, reduces object code size

Started byColin King <colin.king@canonical.com>
First post2017-09-12 13:40 +0200
Last post2017-09-13 05:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] usb: storage: make const arrays static, reduces object code size Colin King <colin.king@canonical.com> - 2017-09-12 13:40 +0200
    Re: [PATCH] usb: storage: make const arrays static, reduces object  code size Alan Stern <stern@rowland.harvard.edu> - 2017-09-13 05:40 +0200

#1730826 — [PATCH] usb: storage: make const arrays static, reduces object code size

FromColin King <colin.king@canonical.com>
Date2017-09-12 13:40 +0200
Subject[PATCH] usb: storage: make const arrays static, reduces object code size
Message-ID<uoRHP-Fn-9@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

Don't populate const arrays on the stack, instead make them
static.  Makes the object code smaller by over 1070 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
   3505	    880	      0	   4385	   1121	drivers/usb/storage/option_ms.o

After:
   text	   data	    bss	    dec	    hex	filename
   2269	   1040	      0	   3309	    ced	drivers/usb/storage/option_ms.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/usb/storage/option_ms.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c
index 57282f12317b..4a73cd4783ae 100644
--- a/drivers/usb/storage/option_ms.c
+++ b/drivers/usb/storage/option_ms.c
@@ -41,7 +41,7 @@ MODULE_PARM_DESC(option_zero_cd, "ZeroCD mode (1=Force Modem (default),"
 
 static int option_rezero(struct us_data *us)
 {
-	const unsigned char rezero_msg[] = {
+	static const unsigned char rezero_msg[] = {
 	  0x55, 0x53, 0x42, 0x43, 0x78, 0x56, 0x34, 0x12,
 	  0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x01,
 	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -87,7 +87,7 @@ static int option_rezero(struct us_data *us)
 
 static int option_inquiry(struct us_data *us)
 {
-	const unsigned char inquiry_msg[] = {
+	static const unsigned char inquiry_msg[] = {
 	  0x55, 0x53, 0x42, 0x43, 0x12, 0x34, 0x56, 0x78,
 	  0x24, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x12,
 	  0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00,
-- 
2.14.1

[toc] | [next] | [standalone]


#1731352 — Re: [PATCH] usb: storage: make const arrays static, reduces object code size

FromAlan Stern <stern@rowland.harvard.edu>
Date2017-09-13 05:40 +0200
SubjectRe: [PATCH] usb: storage: make const arrays static, reduces object code size
Message-ID<up6GR-1WP-5@gated-at.bofh.it>
In reply to#1730826
On Tue, 12 Sep 2017, Colin King wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate const arrays on the stack, instead make them
> static.  Makes the object code smaller by over 1070 bytes:
> 
> Before:
>    text	   data	    bss	    dec	    hex	filename
>    3505	    880	      0	   4385	   1121	drivers/usb/storage/option_ms.o
> 
> After:
>    text	   data	    bss	    dec	    hex	filename
>    2269	   1040	      0	   3309	    ced	drivers/usb/storage/option_ms.o
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/usb/storage/option_ms.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c
> index 57282f12317b..4a73cd4783ae 100644
> --- a/drivers/usb/storage/option_ms.c
> +++ b/drivers/usb/storage/option_ms.c
> @@ -41,7 +41,7 @@ MODULE_PARM_DESC(option_zero_cd, "ZeroCD mode (1=Force Modem (default),"
>  
>  static int option_rezero(struct us_data *us)
>  {
> -	const unsigned char rezero_msg[] = {
> +	static const unsigned char rezero_msg[] = {
>  	  0x55, 0x53, 0x42, 0x43, 0x78, 0x56, 0x34, 0x12,
>  	  0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x01,
>  	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> @@ -87,7 +87,7 @@ static int option_rezero(struct us_data *us)
>  
>  static int option_inquiry(struct us_data *us)
>  {
> -	const unsigned char inquiry_msg[] = {
> +	static const unsigned char inquiry_msg[] = {
>  	  0x55, 0x53, 0x42, 0x43, 0x12, 0x34, 0x56, 0x78,
>  	  0x24, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x12,
>  	  0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00,

Acked-by: Alan Stern <stern@rowland.harvard.edu>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web