[alsa-devel] [PATCH] control: keep consistent usage of assertion

Takashi Iwai tiwai at suse.de
Mon Feb 22 15:01:09 CET 2016


On Mon, 22 Feb 2016 14:13:31 +0100,
Takashi Sakamoto wrote:
> 
> In most codes for control APIs, assertions are used to check given
> arguments from applications. If the arguments are not expected, the
> application is forced to abort. When NDEBUG is defined in the beginning
> of the codes, no checks are performed.
> 
> Although, in snd_ctl_elem_set_bytes(), assertion is used with condition
> statement. There's an intention to check the arguments regardless of
> NDEBUG. However, this is not the same fashion in the codes.
> 
> This commit applies the same fashion to the function, to keep consistent
> usage of assertion.
> 
> Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>

Applied, thanks.


Takashi

> ---
>  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
> 


More information about the Alsa-devel mailing list