diff mbox series

[V2] ALSA: usb-audio: make array static const, makes object smaller

Message ID 20210803122839.7143-1-colin.king@canonical.com (mailing list archive)
State New, archived
Headers show
Series [V2] ALSA: usb-audio: make array static const, makes object smaller | expand

Commit Message

Colin King Aug. 3, 2021, 12:28 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Don't populate array names_to_check on the stack but instead it
static.  Makes the object code smaller by 56 bytes.  Also clean
up checkpatch warning by adding extra const for names_to_check
and pointer s.

Before:
    text    data     bss     dec     hex filename
  103512   34380       0  137892   21aa4 ./sound/usb/mixer.o

After:
    text    data     bss     dec     hex filename
  103264   34572       0  137836   21a6c ./sound/usb/mixer.o

(gcc version 10.2.0)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---

V2: Clean up checkpatch warning on const-ness for names_to_check.
    Add extra const to clean up build warning on pointer s.
---
 sound/usb/mixer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Takashi Iwai Aug. 3, 2021, 2:05 p.m. UTC | #1
On Tue, 03 Aug 2021 14:28:39 +0200,
Colin King wrote:
> 
> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate array names_to_check on the stack but instead it
> static.  Makes the object code smaller by 56 bytes.  Also clean
> up checkpatch warning by adding extra const for names_to_check
> and pointer s.
> 
> Before:
>     text    data     bss     dec     hex filename
>   103512   34380       0  137892   21aa4 ./sound/usb/mixer.o
> 
> After:
>     text    data     bss     dec     hex filename
>   103264   34572       0  137836   21a6c ./sound/usb/mixer.o
> 
> (gcc version 10.2.0)
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> 
> V2: Clean up checkpatch warning on const-ness for names_to_check.
>     Add extra const to clean up build warning on pointer s.

Thanks, applied.


Takashi
diff mbox series

Patch

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index db7cb6b6dc4e..43bc59575a6e 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1572,9 +1572,9 @@  static size_t append_ctl_name(struct snd_kcontrol *kctl, const char *str)
 static void check_no_speaker_on_headset(struct snd_kcontrol *kctl,
 					struct snd_card *card)
 {
-	const char *names_to_check[] = {
+	static const char * const names_to_check[] = {
 		"Headset", "headset", "Headphone", "headphone", NULL};
-	const char **s;
+	const char * const *s;
 	bool found = false;
 
 	if (strcmp("Speaker", kctl->id.name))