Re: [RFC] gatt: Fix wrong function exit

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

 



Hi Arman,

On 27 October 2014 15:41, Arman Uguray <armansito@xxxxxxxxxxxx> wrote:
> Hi Marcin,
>
> On Mon, Oct 27, 2014 at 7:14 AM, Marcin Kraglak
> <marcin.kraglak@xxxxxxxxx> wrote:
>> Hi Andrei,
>>
>> On 27 October 2014 15:01, Andrei Emeltchenko
>> <Andrei.Emeltchenko.news@xxxxxxxxx> wrote:
>>> From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>
>>>
>>> ---
>>>  src/shared/gatt-helpers.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/src/shared/gatt-helpers.c b/src/shared/gatt-helpers.c
>>> index d751d5a..4f53de3 100644
>>> --- a/src/shared/gatt-helpers.c
>>> +++ b/src/shared/gatt-helpers.c
>>> @@ -1029,7 +1029,7 @@ static void discover_included_cb(uint8_t opcode, const void *pdu,
>>>                 data = new_read_included(cur_result);
>>>                 if (!data) {
>>>                         success = false;
>>> -                       goto done;
>>> +                       goto failed;
>>>                 }
>>>
>>>                 read_included(data);
>>> --
>>> 1.9.1
>> In fact exit here is wrong and should be goto failed.
>> Anyway, I found that we call goto failed more times in this function
>> than goto done, so maybe it is better to change labels like this:
>> failed:
>>     success = false;
>>
>> done:
>>     if (op->callback)
>>         op->callback(success, att_ecode, final_result, op->user_data);
>>
>> and set success = true before goto done;
>>
>
> Might actually be better leave the current structure as it is, except
> initialize success = false at declaration. Then code would simply call
> goto fail and not set success to false every time.

Sounds good
>
> -Arman

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