Re: [PATCH] kstrtox: convert net/bluetooth/

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

 



On Tue, Apr 5, 2011 at 1:00 AM, Gustavo F. Padovan
<padovan@xxxxxxxxxxxxxx> wrote:

>> @@ -299,15 +300,13 @@ static ssize_t show_sniff_max_interval(struct device *dev, struct device_attribu
>>  static ssize_t store_sniff_max_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
>>  {
>>       struct hci_dev *hdev = dev_get_drvdata(dev);
>> -     unsigned long val;
>> -
>> -     if (strict_strtoul(buf, 0, &val) < 0)
>> -             return -EINVAL;
>> -
>> -     if (val < 0x0002 || val > 0xFFFE || val % 2)
>> -             return -EINVAL;
>> +     u16 val;
>> +     int rv;
>>
>> -     if (val < hdev->sniff_min_interval)
>> +     rv = kstrtou16(buf, 0, &val);
>> +     if (rv < 0)
>> +             return rv;
>> +     if (val == 0 || val % 2 || val < hdev->sniff_min_interval)
>>               return -EINVAL;
>
> Why are you changing other things besides the string conversions?

Because this is not mindless s/foo/bar/g conversion.

> The checks for val should stay the same.

No, they should not. kstrtou16() takes care of [0x0000, 0xFFFF] interval,
then you check for even values, then you have only 0 to ban.

WIth previous checks, say, "val > 0xFFFE" is not necessary,
kstrtou16 + "val % 2" do it.
--
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