lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5A1C3683.7080901@bfs.de>
Date:   Mon, 27 Nov 2017 17:00:03 +0100
From:   walter harms <wharms@....de>
To:     Joe Perches <joe@...ches.com>
CC:     Colin King <colin.king@...onical.com>,
        Jaroslav Kysela <perex@...ex.cz>,
        Takashi Iwai <tiwai@...e.com>, alsa-devel@...a-project.org,
        kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ALSA: drivers: make array 'names' const, reduces object
 code size



Am 27.11.2017 16:40, schrieb Joe Perches:
> 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@...onical.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.

I will not argue. I was curious about the magic numbers and
int this case it seems an obvious choice in other cases
it may be wrong i did not and i will not investigate.

re,
 wh

> 
> 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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ