[alsa-devel] [PATCH 1/5] amixer: gather local variables in the beginning of functions

Takashi Iwai tiwai at suse.de
Thu Apr 9 08:06:56 CEST 2015


At Thu,  9 Apr 2015 01:30:54 +0900,
Takashi Sakamoto wrote:
> 
> Following to basic principles of C language programing.

It's pretty normal (and often more useful) to define a variable in a
block.


Takashi

> 
> Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
> ---
>  amixer/amixer.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/amixer/amixer.c b/amixer/amixer.c
> index 36c92eb..ff1a927 100644
> --- a/amixer/amixer.c
> +++ b/amixer/amixer.c
> @@ -1278,13 +1278,16 @@ static int get_enum_item_index(snd_mixer_elem_t *elem, char **ptrp)
>  
>  static int sset_enum(snd_mixer_elem_t *elem, unsigned int argc, char **argv)
>  {
> -	unsigned int idx, item = 0;
> +	unsigned int idx;
> +	unsigned int item = 0;
>  	int check_flag = ignore_error ? 0 : -1;
> +	int ival;
> +	char *ptr;
>  
>  	for (idx = 1; idx < argc; idx++) {
> -		char *ptr = argv[idx];
> +		ptr = argv[idx];
>  		while (*ptr) {
> -			int ival = get_enum_item_index(elem, &ptr);
> +			ival = get_enum_item_index(elem, &ptr);
>  			if (ival < 0)
>  				return check_flag;
>  			if (snd_mixer_selem_set_enum_item(elem, item++, ival) >= 0)
> -- 
> 2.1.0
> 


More information about the Alsa-devel mailing list