mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-22 20:30:58 +02:00
mm: cleanup kstrto*() usage
Range checks can folded into proper conversion function. kstrto*() exist for all arithmetic types. Link: https://lkml.kernel.org/r/20201122123759.GC92364@localhost.localdomain Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
01359eb201
commit
dfefd226b0
@@ -133,11 +133,11 @@ static ssize_t scan_sleep_millisecs_store(struct kobject *kobj,
|
|||||||
struct kobj_attribute *attr,
|
struct kobj_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
unsigned long msecs;
|
unsigned int msecs;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = kstrtoul(buf, 10, &msecs);
|
err = kstrtouint(buf, 10, &msecs);
|
||||||
if (err || msecs > UINT_MAX)
|
if (err)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
khugepaged_scan_sleep_millisecs = msecs;
|
khugepaged_scan_sleep_millisecs = msecs;
|
||||||
@@ -161,11 +161,11 @@ static ssize_t alloc_sleep_millisecs_store(struct kobject *kobj,
|
|||||||
struct kobj_attribute *attr,
|
struct kobj_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
unsigned long msecs;
|
unsigned int msecs;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = kstrtoul(buf, 10, &msecs);
|
err = kstrtouint(buf, 10, &msecs);
|
||||||
if (err || msecs > UINT_MAX)
|
if (err)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
khugepaged_alloc_sleep_millisecs = msecs;
|
khugepaged_alloc_sleep_millisecs = msecs;
|
||||||
@@ -188,11 +188,11 @@ static ssize_t pages_to_scan_store(struct kobject *kobj,
|
|||||||
struct kobj_attribute *attr,
|
struct kobj_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
|
unsigned int pages;
|
||||||
int err;
|
int err;
|
||||||
unsigned long pages;
|
|
||||||
|
|
||||||
err = kstrtoul(buf, 10, &pages);
|
err = kstrtouint(buf, 10, &pages);
|
||||||
if (err || !pages || pages > UINT_MAX)
|
if (err || !pages)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
khugepaged_pages_to_scan = pages;
|
khugepaged_pages_to_scan = pages;
|
||||||
|
18
mm/ksm.c
18
mm/ksm.c
@@ -2840,11 +2840,11 @@ static ssize_t sleep_millisecs_store(struct kobject *kobj,
|
|||||||
struct kobj_attribute *attr,
|
struct kobj_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
unsigned long msecs;
|
unsigned int msecs;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = kstrtoul(buf, 10, &msecs);
|
err = kstrtouint(buf, 10, &msecs);
|
||||||
if (err || msecs > UINT_MAX)
|
if (err)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
ksm_thread_sleep_millisecs = msecs;
|
ksm_thread_sleep_millisecs = msecs;
|
||||||
@@ -2864,11 +2864,11 @@ static ssize_t pages_to_scan_store(struct kobject *kobj,
|
|||||||
struct kobj_attribute *attr,
|
struct kobj_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
|
unsigned int nr_pages;
|
||||||
int err;
|
int err;
|
||||||
unsigned long nr_pages;
|
|
||||||
|
|
||||||
err = kstrtoul(buf, 10, &nr_pages);
|
err = kstrtouint(buf, 10, &nr_pages);
|
||||||
if (err || nr_pages > UINT_MAX)
|
if (err)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
ksm_thread_pages_to_scan = nr_pages;
|
ksm_thread_pages_to_scan = nr_pages;
|
||||||
@@ -2886,11 +2886,11 @@ static ssize_t run_show(struct kobject *kobj, struct kobj_attribute *attr,
|
|||||||
static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
|
static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
|
unsigned int flags;
|
||||||
int err;
|
int err;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
err = kstrtoul(buf, 10, &flags);
|
err = kstrtouint(buf, 10, &flags);
|
||||||
if (err || flags > UINT_MAX)
|
if (err)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (flags > KSM_RUN_UNMERGE)
|
if (flags > KSM_RUN_UNMERGE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
Reference in New Issue
Block a user