control: keep consistent usage of assertion

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@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Sakamoto 2016-02-22 22:13:31 +09:00 committed by Takashi Iwai
parent 2b0ea7eefb
commit 6d4736197e

View file

@ -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) void snd_ctl_elem_set_bytes(snd_ctl_elem_value_t *obj, void *data, size_t size)
{ {
assert(obj); assert(obj);
if (size >= ARRAY_SIZE(obj->value.bytes.data)) { assert(size < ARRAY_SIZE(obj->value.bytes.data));
assert(0);
return;
}
memcpy(obj->value.bytes.data, data, size); memcpy(obj->value.bytes.data, data, size);
} }