Re: [RFCv2 3/4] Bluetooth: Use ERR_PTR to return error from hci_connect

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

 



Hi Gustavo,

On Thu, Feb 17, 2011 at 2:25 PM, Gustavo F. Padovan
<padovan@xxxxxxxxxxxxxx> wrote:
>> @@ -459,8 +459,10 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
>>               le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
>>               if (!le)
>>                       le = hci_conn_add(hdev, LE_LINK, dst);
>> -             if (!le)
>> -                     return NULL;
>> +             else
>> +                     return ERR_PTR(-EBUSY);
>> +             if (IS_ERR(le))
>> +                     return le;
>
> I prefer this instead:
>
>                le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
>                if (le)
>                        return ERR_PTR(-EBUSY);
>
>                le = hci_conn_add(hdev, LE_LINK, dst);
>                if (!le)
>                        return ERR_PTR(-ENOMEM);

I think the code above (besides the "if (le)" typo) is not equivalent
to the original one. See:

>>               le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
>>               if (!le)
>>                       le = hci_conn_add(hdev, LE_LINK, dst);
>> -             if (!le)
>> -                     return NULL;

if hci_conn_hash_lookup_ba() returns NULL, it should call
hci_conn_add(), and if that fails, then return NULL (or some
ERR_PTR()).

Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux