Re: [alsa-lib][PATCH] control: correct assertion in snd_ctl_elem_set_bytes()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 21 Feb 2016 17:54:09 +0100,
Takashi Sakamoto wrote:
> 
> The assert(3) aborts running process when expression arguments is
> false (zero). Although, the snd_ctl_elem_set_bytes() has return
> statement after assert(3). It has meaningless.

Admittedly this isn't an optimal code, but it has its purpose.
The intention of the original code was to perform the check always but
triggers the assert signal unless NDEBUG is set (remember that
assert() is nop when NDEBUG is defined).


Takashi

> 
> This commit corrects the statements.
> 
> Fixes: 7893ea238d5a('Added mode argument to open functions where it was missing. First part of CTL documentation')
> Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
> ---
>  src/control/control.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/src/control/control.c b/src/control/control.c
> index 328920d..70d168d 100644
> --- a/src/control/control.c
> +++ b/src/control/control.c
> @@ -2627,10 +2627,7 @@ void snd_ctl_elem_value_set_byte(snd_ctl_elem_value_t *obj, unsigned int idx, un
>  void snd_ctl_elem_set_bytes(snd_ctl_elem_value_t *obj, void *data, size_t size)
>  {
>  	assert(obj);
> -	if (size >= ARRAY_SIZE(obj->value.bytes.data)) {
> -		assert(0);
> -		return;
> -	}
> +	assert(size < ARRAY_SIZE(obj->value.bytes.data));
>  	memcpy(obj->value.bytes.data, data, size);
>  }
>  
> -- 
> 2.5.0
> 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux