Re: [PATCHv3 3/6] shared/hfp: Add get_number implementation

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

 



Hi Marcel,

On 1 March 2014 04:27, Marcel Holtmann <marcel@xxxxxxxxxxxx> wrote:
> Hi Marcin,
>
>> User can call this function with hfp_gw_result, which will
>> be passed to prefix handler.
>> ---
>> src/shared/hfp.c | 33 +++++++++++++++++++++++++++++++++
>> src/shared/hfp.h |  2 ++
>> 2 files changed, 35 insertions(+)
>>
>> diff --git a/src/shared/hfp.c b/src/shared/hfp.c
>> index 8feaf16..d168ac4 100644
>> --- a/src/shared/hfp.c
>> +++ b/src/shared/hfp.c
>> @@ -218,6 +218,39 @@ done:
>>       return true;
>> }
>>
>> +static void next_field(struct hfp_gw_result *result)
>> +{
>> +     if (result->data[result->offset] == ',')
>> +             result->offset++;
>> +}
>> +
>> +bool hfp_gw_result_get_number(struct hfp_gw_result *result, int *val)
>> +{
>> +     int temp = 0;
>> +     int i;
>
>         int i, tmp = 0;
>
>> +
>> +     skip_whitespace(result);
>> +
>> +     i = result->offset;
>> +
>> +     while (result->data[i] >= '0' && result->data[i] <= '9') {
>> +             temp *= 10;
>> +             temp += result->data[i++] - '0';
>
>         tmp = (tmp * 10) + (result->data[i++] - '0';
>
> This should be the cheaper operation since tmp does not need be reevaluated twice.
>
> Are we going to support negative number? I do not even remember if they are valid in AT commands. Has been too long. Might also go straight to unsigned int *val in that case.
>
> Regards
>
> Marcel
>

ok, I'll change it to be cheaper,

In spec V.250 stays:

"Decimal numeric constants shall consist of a sequence of one or more
of the characters "0"
(IA5 3/0) through "9" (IA5 3/9), inclusive."

and

"No spaces, hyphens, periods, commas, parentheses, or other generally-
accepted numeric formatting characters are permitted in numeric constants;"

co i suppose that it shuouldn't be accepted

I'll send next version

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