* [bluetooth-next V2] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul
@ 2010-03-09 19:38 Tomas Winkler
2010-03-09 20:41 ` Marcel Holtmann
0 siblings, 1 reply; 4+ messages in thread
From: Tomas Winkler @ 2010-03-09 19:38 UTC (permalink / raw)
To: marcel, linux-bluetooth; +Cc: guy.cohen, ron.rindjunsky, Tomas Winkler
use strict_strtoul as suggested by checkpatch.pl
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
V2:
1. more verbose commit message
2. return the error code that was produced by strict_strtoul
net/bluetooth/hci_sysfs.c | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 1a79a6c..dd11d61 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -282,12 +282,12 @@ static ssize_t show_idle_timeout(struct device *dev, struct device_attribute *at
static ssize_t store_idle_timeout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct hci_dev *hdev = dev_get_drvdata(dev);
- char *ptr;
- __u32 val;
+ unsigned long val;
+ int ret;
- val = simple_strtoul(buf, &ptr, 10);
- if (ptr == buf)
- return -EINVAL;
+ ret = strict_strtoul(buf, 0, &val);
+ if (ret)
+ return ret;
if (val != 0 && (val < 500 || val > 3600000))
return -EINVAL;
@@ -306,12 +306,12 @@ 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);
- char *ptr;
- __u16 val;
+ unsigned long val;
+ int ret;
- val = simple_strtoul(buf, &ptr, 10);
- if (ptr == buf)
- return -EINVAL;
+ ret = strict_strtoul(buf, 0, &val);
+ if (ret)
+ return ret;
if (val < 0x0002 || val > 0xFFFE || val % 2)
return -EINVAL;
@@ -333,12 +333,12 @@ static ssize_t show_sniff_min_interval(struct device *dev, struct device_attribu
static ssize_t store_sniff_min_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct hci_dev *hdev = dev_get_drvdata(dev);
- char *ptr;
- __u16 val;
+ unsigned long val;
+ int ret;
- val = simple_strtoul(buf, &ptr, 10);
- if (ptr == buf)
- return -EINVAL;
+ ret = strict_strtoul(buf, 0, &val);
+ if (ret)
+ return ret;
if (val < 0x0002 || val > 0xFFFE || val % 2)
return -EINVAL;
--
1.6.6.1
---------------------------------------------------------------------
Intel Israel (74) Limited
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [bluetooth-next V2] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul
2010-03-09 19:38 [bluetooth-next V2] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul Tomas Winkler
@ 2010-03-09 20:41 ` Marcel Holtmann
2010-03-09 21:13 ` Winkler, Tomas
0 siblings, 1 reply; 4+ messages in thread
From: Marcel Holtmann @ 2010-03-09 20:41 UTC (permalink / raw)
To: Tomas Winkler; +Cc: linux-bluetooth, guy.cohen, ron.rindjunsky
Hi Tomas,
> use strict_strtoul as suggested by checkpatch.pl
>
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> ---
> V2:
> 1. more verbose commit message
> 2. return the error code that was produced by strict_strtoul
why do you bother actually. Reading the comment about struct_strtoul it
will only return -EINVAL or 0. So using my proposal would be just fine.
I also don't prefer to differ the return value to user space until it
actually makes sense. Invalid argument is just fine for all error cases.
Regards
Marcel
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [bluetooth-next V2] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul
2010-03-09 20:41 ` Marcel Holtmann
@ 2010-03-09 21:13 ` Winkler, Tomas
2010-03-12 0:28 ` Marcel Holtmann
0 siblings, 1 reply; 4+ messages in thread
From: Wink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bCB3b3VsZCBiZSBqdXN0IGZpbmUuDQo+
IEkgYWxzbyBkb24ndCBwcmVmZXIgdG8gZGlmZmVyIHRoZSByZXR1cm4gdmFsdWUgdG8gdXNlciBz
cGFjZSB1bnRpbCBpdA0KPiBhY3R1YWxseSBtYWtlcyBzZW5zZS4gSW52YWxpZCBhcmd1bWVudCBp
cyBqdXN0IGZpbmUgZm9yIGFsbCBlcnJvciBjYXNlcy4NCj4NClllcyBJIGtub3cgYnV0IEkndmUg
dXNlIG9mIHRoaXMgb3ZlciB0aGUga2VybmVsIGNvZGUgYW5kIHdoYXQgSSd2ZSB1c2VkIGlzIHRo
ZSBtb3N0bHkgdXNlZCBpZGlvbQ0KDQpUaGFua3MNClRvbWFzDQoNCg0KDQotLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0K
SW50ZWwgSXNyYWVsICg3NCkgTGltaXRlZAoKVGhpcyBlLW1haWwgYW5kIGFueSBhdHRhY2htZW50
cyBtYXkgY29udGFpbiBjb25maWRlbnRpYWwgbWF0ZXJpYWwgZm9yCnRoZSBzb2xlIHVzZSBvZiB0
aGUgaW50ZW5kZWQgcmVjaXBpZW50KHMpLiBBbnkgcmV2aWV3IG9yIGRpc3RyaWJ1dGlvbgpieSBv
dGhlcnMgaXMgc3RyaWN0bHkgcHJvaGliaXRlZC4gSWYgeW91IGFyZSBub3QgdGhlIGludGVuZGVk
CnJlY2lwaWVudCwgcGxlYXNlIGNvbnRhY3QgdGhlIHNlbmRlciBhbmQgZGVsZXRlIGFsbCBjb3Bp
ZXMuCg==
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [bluetooth-next V2] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul
2010-03-09 21:13 ` Winkler, Tomas
@ 2010-03-12 0:28 ` Marcel Holtmann
0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2010-03-12 0:28 UTC (permalink / raw)
To: Winkler, Tomas
Cc: linux-bluetooth@vger.kernel.org, Cohen, Guy, Rindjunsky, Ron
Hi Tomas,
> > > use strict_strtoul as suggested by checkpatch.pl
> > >
> > > Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> > > ---
> > > V2:
> > > 1. more verbose commit message
> > > 2. return the error code that was produced by strict_strtoul
> >
> > why do you bother actually. Reading the comment about struct_strtoul it
> > will only return -EINVAL or 0. So using my proposal would be just fine.
> > I also don't prefer to differ the return value to user space until it
> > actually makes sense. Invalid argument is just fine for all error cases.
> >
> Yes I know but I've use of this over the kernel code and what I've used is the mostly used idiom
I choose to have it as I originally proposed. Patch has been pushed into
bluetooth-testing tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-03-12 0:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-09 19:38 [bluetooth-next V2] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul Tomas Winkler
2010-03-09 20:41 ` Marcel Holtmann
2010-03-09 21:13 ` Winkler, Tomas
2010-03-12 0:28 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).