From: Joe Perches <joe@perches.com>
To: wharms@bfs.de, Colin King <colin.king@canonical.com>
Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org,
kernel-janitors@vger.kernel.org, Takashi Iwai <tiwai@suse.com>
Subject: Re: [PATCH] ALSA: drivers: make array 'names' const, reduces object code size
Date: Mon, 27 Nov 2017 07:40:07 -0800 [thread overview]
Message-ID: <1511797207.32426.41.camel@perches.com> (raw)
In-Reply-To: <5A1C2760.1030704@bfs.de>
On Mon, 2017-11-27 at 15:55 +0100, walter harms wrote:
> Am 27.11.2017 13:58, schrieb Colin King:
> > From: Colin Ian King <colin.king@canonical.com>
> > Don't populate array 'names' on the stack but instead make them static.
> > Makes the object code smaller by 50 bytes:
[]
> > diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
[]
> > @@ -830,7 +830,7 @@ static int snd_dummy_capsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
> > static int snd_dummy_iobox_info(struct snd_kcontrol *kcontrol,
> > struct snd_ctl_elem_info *info)
> > {
> > - const char *const names[] = { "None", "CD Player" };
> > + static const char *const names[] = { "None", "CD Player" };
> >
> > return snd_ctl_enum_info(info, 1, 2, names);
> > }
>
> nitpick: while here
> snd_ctl_enum_info(info, 1, ARRAY_SIZE(names), names);
>
> just my 2 cents,
True, but that seems counter style for most uses of snd_ctl_enum_info
$ git grep -w snd_ctl_enum_info | grep -v ARRAY_SIZE | wc -l
159
$ git grep -w snd_ctl_enum_info | grep ARRAY_SIZE | wc -l
10
but most of those seem to choose variable amounts of a single
array. Here, ARRAY_SIZE seems better to me too.
For another real nitpick, please prefer "const *" over "const*"
$ git grep -P "\*\s+const\b" | wc -l
7068
$ git grep -P "\*const\b" | wc -l
1801
WARNING: multiple messages have this Message-ID (diff)
From: Joe Perches <joe@perches.com>
To: wharms@bfs.de, Colin King <colin.king@canonical.com>
Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org,
kernel-janitors@vger.kernel.org, Takashi Iwai <tiwai@suse.com>
Subject: Re: [PATCH] ALSA: drivers: make array 'names' const, reduces object code size
Date: Mon, 27 Nov 2017 15:40:07 +0000 [thread overview]
Message-ID: <1511797207.32426.41.camel@perches.com> (raw)
In-Reply-To: <5A1C2760.1030704@bfs.de>
On Mon, 2017-11-27 at 15:55 +0100, walter harms wrote:
> Am 27.11.2017 13:58, schrieb Colin King:
> > From: Colin Ian King <colin.king@canonical.com>
> > Don't populate array 'names' on the stack but instead make them static.
> > Makes the object code smaller by 50 bytes:
[]
> > diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
[]
> > @@ -830,7 +830,7 @@ static int snd_dummy_capsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
> > static int snd_dummy_iobox_info(struct snd_kcontrol *kcontrol,
> > struct snd_ctl_elem_info *info)
> > {
> > - const char *const names[] = { "None", "CD Player" };
> > + static const char *const names[] = { "None", "CD Player" };
> >
> > return snd_ctl_enum_info(info, 1, 2, names);
> > }
>
> nitpick: while here
> snd_ctl_enum_info(info, 1, ARRAY_SIZE(names), names);
>
> just my 2 cents,
True, but that seems counter style for most uses of snd_ctl_enum_info
$ git grep -w snd_ctl_enum_info | grep -v ARRAY_SIZE | wc -l
159
$ git grep -w snd_ctl_enum_info | grep ARRAY_SIZE | wc -l
10
but most of those seem to choose variable amounts of a single
array. Here, ARRAY_SIZE seems better to me too.
For another real nitpick, please prefer "const *" over "const*"
$ git grep -P "\*\s+const\b" | wc -l
7068
$ git grep -P "\*const\b" | wc -l
1801
WARNING: multiple messages have this Message-ID (diff)
From: Joe Perches <joe@perches.com>
To: wharms@bfs.de, Colin King <colin.king@canonical.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: drivers: make array 'names' const, reduces object code size
Date: Mon, 27 Nov 2017 07:40:07 -0800 [thread overview]
Message-ID: <1511797207.32426.41.camel@perches.com> (raw)
In-Reply-To: <5A1C2760.1030704@bfs.de>
On Mon, 2017-11-27 at 15:55 +0100, walter harms wrote:
> Am 27.11.2017 13:58, schrieb Colin King:
> > From: Colin Ian King <colin.king@canonical.com>
> > Don't populate array 'names' on the stack but instead make them static.
> > Makes the object code smaller by 50 bytes:
[]
> > diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
[]
> > @@ -830,7 +830,7 @@ static int snd_dummy_capsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
> > static int snd_dummy_iobox_info(struct snd_kcontrol *kcontrol,
> > struct snd_ctl_elem_info *info)
> > {
> > - const char *const names[] = { "None", "CD Player" };
> > + static const char *const names[] = { "None", "CD Player" };
> >
> > return snd_ctl_enum_info(info, 1, 2, names);
> > }
>
> nitpick: while here
> snd_ctl_enum_info(info, 1, ARRAY_SIZE(names), names);
>
> just my 2 cents,
True, but that seems counter style for most uses of snd_ctl_enum_info
$ git grep -w snd_ctl_enum_info | grep -v ARRAY_SIZE | wc -l
159
$ git grep -w snd_ctl_enum_info | grep ARRAY_SIZE | wc -l
10
but most of those seem to choose variable amounts of a single
array. Here, ARRAY_SIZE seems better to me too.
For another real nitpick, please prefer "const *" over "const*"
$ git grep -P "\*\s+const\b" | wc -l
7068
$ git grep -P "\*const\b" | wc -l
1801
next prev parent reply other threads:[~2017-11-27 15:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-27 12:58 [PATCH] ALSA: drivers: make array 'names' const, reduces object code size Colin King
2017-11-27 14:55 ` walter harms
2017-11-27 14:55 ` walter harms
2017-11-27 15:40 ` Joe Perches [this message]
2017-11-27 15:40 ` Joe Perches
2017-11-27 15:40 ` Joe Perches
2017-11-27 16:00 ` walter harms
2017-11-27 16:00 ` walter harms
2017-11-27 17:34 ` Takashi Sakamoto
2017-11-27 17:34 ` Takashi Sakamoto
2017-11-27 17:34 ` Takashi Sakamoto
2017-11-27 19:51 ` Takashi Iwai
2017-11-27 19:51 ` Takashi Iwai
2017-11-27 19:51 ` Takashi Iwai
2017-11-28 10:39 ` Takashi Sakamoto
2017-11-28 10:39 ` Takashi Sakamoto
2017-11-28 10:39 ` Takashi Sakamoto
2017-11-27 19:51 ` Takashi Iwai
2017-11-27 19:51 ` Takashi Iwai
2017-11-27 19:51 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1511797207.32426.41.camel@perches.com \
--to=joe@perches.com \
--cc=alsa-devel@alsa-project.org \
--cc=colin.king@canonical.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tiwai@suse.com \
--cc=wharms@bfs.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.