From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752793AbdK0PkM (ORCPT ); Mon, 27 Nov 2017 10:40:12 -0500 Received: from smtprelay0072.hostedemail.com ([216.40.44.72]:33784 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752291AbdK0PkL (ORCPT ); Mon, 27 Nov 2017 10:40:11 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3653:3865:3866:3867:3874:4321:5007:7576:7874:7903:7974:10004:10400:10848:11026:11232:11473:11658:11914:12049:12296:12438:12740:12760:12895:13069:13311:13357:13439:14181:14659:14721:21080:21451:21627:30012:30030:30054:30075:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: slave62_1e5c17fdb964d X-Filterd-Recvd-Size: 2249 Message-ID: <1511797207.32426.41.camel@perches.com> Subject: Re: [PATCH] ALSA: drivers: make array 'names' const, reduces object code size From: Joe Perches To: wharms@bfs.de, Colin King Cc: Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 27 Nov 2017 07:40:07 -0800 In-Reply-To: <5A1C2760.1030704@bfs.de> References: <20171127125851.10076-1-colin.king@canonical.com> <5A1C2760.1030704@bfs.de> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > 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