mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-08 13:30:03 -05:00
control: use position offset macro of TLV data
A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset of TLV data. This commit applies a code optimization. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
5eb78219f6
commit
f61193c96c
4 changed files with 51 additions and 40 deletions
|
|
@ -240,11 +240,13 @@ static int snd_ctl_hw_elem_tlv(snd_ctl_t *handle, int op_flag,
|
|||
return -errno;
|
||||
}
|
||||
if (op_flag == 0) {
|
||||
if (xtlv->tlv[1] + 2 * sizeof(unsigned int) > tlv_size) {
|
||||
unsigned int size;
|
||||
size = xtlv->tlv[SNDRV_CTL_TLVO_LEN] + 2 * sizeof(unsigned int);
|
||||
if (size > tlv_size) {
|
||||
free(xtlv);
|
||||
return -EFAULT;
|
||||
}
|
||||
memcpy(tlv, xtlv->tlv, xtlv->tlv[1] + 2 * sizeof(unsigned int));
|
||||
memcpy(tlv, xtlv->tlv, size);
|
||||
}
|
||||
free(xtlv);
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue