From 5fd637e7a75fb2a4c0b62683c08dae959160fedf Mon Sep 17 00:00:00 2001 From: Rastislav Barlik Date: Wed, 17 Dec 2014 21:14:48 +0100 Subject: samples/kobject: Use kstrtoint instead of sscanf Use kstrtoint function instead of sscanf and check for return values. Signed-off-by: Rastislav Barlik Signed-off-by: Greg Kroah-Hartman --- samples/kobject/kobject-example.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'samples/kobject/kobject-example.c') diff --git a/samples/kobject/kobject-example.c b/samples/kobject/kobject-example.c index 01562e0d4992..063aaece0bcd 100644 --- a/samples/kobject/kobject-example.c +++ b/samples/kobject/kobject-example.c @@ -36,7 +36,12 @@ static ssize_t foo_show(struct kobject *kobj, struct kobj_attribute *attr, static ssize_t foo_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { - sscanf(buf, "%du", &foo); + int ret; + + ret = kstrtoint(buf, 10, &foo); + if (ret < 0) + return ret; + return count; } @@ -63,9 +68,12 @@ static ssize_t b_show(struct kobject *kobj, struct kobj_attribute *attr, static ssize_t b_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { - int var; + int var, ret; + + ret = kstrtoint(buf, 10, &var); + if (ret < 0) + return ret; - sscanf(buf, "%du", &var); if (strcmp(attr->attr.name, "baz") == 0) baz = var; else -- cgit v1.2.3 From 07afb6ace3bde4ffdce26befa6b2f38c5d708dd0 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 25 Mar 2015 13:41:42 +0100 Subject: samples/kobject: be explicit in the module license Rusty pointed out that the module license should be "GPL v2" to properly match the notice at the top of the files, so make that change. Reported-by: Rusty Russell Signed-off-by: Greg Kroah-Hartman --- samples/kobject/kobject-example.c | 2 +- samples/kobject/kset-example.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'samples/kobject/kobject-example.c') diff --git a/samples/kobject/kobject-example.c b/samples/kobject/kobject-example.c index 063aaece0bcd..2e0740f06cd7 100644 --- a/samples/kobject/kobject-example.c +++ b/samples/kobject/kobject-example.c @@ -142,5 +142,5 @@ static void __exit example_exit(void) module_init(example_init); module_exit(example_exit); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Greg Kroah-Hartman "); diff --git a/samples/kobject/kset-example.c b/samples/kobject/kset-example.c index e80ced3a5203..a55bff52bde3 100644 --- a/samples/kobject/kset-example.c +++ b/samples/kobject/kset-example.c @@ -285,5 +285,5 @@ static void __exit example_exit(void) module_init(example_init); module_exit(example_exit); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Greg Kroah-Hartman "); -- cgit v1.2.3