Re: different return value from some ioctl commands for x86 binary executed on x86_64

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

 



On Mar 17 2016 18:51, Takashi Iwai wrote:
> On Thu, 17 Mar 2016 04:52:52 +0100,
> Takashi Sakamoto wrote:
>>
>> Hi,
>>
>> When testing ioctl compatibility layer for ALSA ctl interface, I found
>> that error code of some ioctl commands are different depending on binary
>> architecture.
>>
>> The commands are SNDRV_CTL_IOCTL_ELEM_READ/SNDRV_CTL_IOCTL_ELEM_WRITE.
>> When passing data for non-existent element, ENOENT is returned by the
>> core implementation. On the other hand, ENXIO is returned by the
>> compatibility layer.
>>
>> This code is for reproduction of this bug.
>>
>> (snip)
>>
>> I tested on x86_64 machine with enough support for multi-arch.
>>
>> $ gcc -Wall -m64 -o ./test ./test.c ; ./test
>> ioctl(SNDRV_CTL_IOCTL_ELEM_READ): No such file or directory
>> ioctl(SNDRV_CTL_IOCTL_ELEM_WRITE): No such file or directory
>>
>> $ gcc -Wall -m32 -o ./test ./test.c ; ./test
>> ioctl(SNDRV_CTL_IOCTL_ELEM_READ): No such device or address
>> ioctl(SNDRV_CTL_IOCTL_ELEM_WRITE): No such device or address
>>
>>
>> This bug is due to return value of condition statement for
>> 'snd_ctl_find()'. I wrote a patch to fix it.
>>
>>
>> >From d7a8fd14a1bc100dbaf9bf28af47094d5ccb882b Mon Sep 17 00:00:00 2001
>> From: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
>> Date: Wed, 16 Mar 2016 13:40:31 +0900
>> Subject: [PATCH] ALSA: ctl: change error code in compatibility layer so that
>>  it's the same code as core implementation
>>
>> In control compatibility layer, when no elements are found by
>> ELEM_READ/ELEM_WRITE ioctl commands, ENXIO is returned. On the other
>> hand, in core implementation, ENOENT is returned. This is not good for
>> applications.
>>
>> This commit changes the return value from the compatibility layer so
>> that the same error code is returned.
>>
>> diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
>> index 0608f21..1fa7076 100644
>> --- a/sound/core/control_compat.c
>> +++ b/sound/core/control_compat.c
>> @@ -196,7 +196,7 @@ static int get_ctl_type(struct snd_card *card,
>> struct snd_ctl_elem_id *id,
>>         kctl = snd_ctl_find_id(card, id);
>>         if (! kctl) {
>>                 up_read(&card->controls_rwsem);
>> -               return -ENXIO;
>> +               return -ENOENT;
>>         }
>>         info = kzalloc(sizeof(*info), GFP_KERNEL);
>>         if (info == NULL) {
>>
>> Well, it's already in merge window for Linux 4.6. I don't mind to
>> postpone this patch to next developing cycle, while I also think it
>> better to fix the bug now. So I leave the decision to maintainers.
> 
> Looks good to me, and trivial enough to be merged for 4.6.
> Please resubmit with a proper sign off.

OK, thanks.


Takashi Sakamoto
_______________________________________________
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