diff mbox series

[v1,1/2] mm/damon/sysfs: remove unnecessary variables

Message ID 20220919151201.66696-1-xhao@linux.alibaba.com (mailing list archive)
State New
Headers show
Series [v1,1/2] mm/damon/sysfs: remove unnecessary variables | expand

Commit Message

haoxin Sept. 19, 2022, 3:12 p.m. UTC
Just do a little change here, the 'err' variable really no need to stay
here.

Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
---
 mm/damon/sysfs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--
2.31.0

Comments

SeongJae Park Sept. 19, 2022, 5:03 p.m. UTC | #1
On Mon, 19 Sep 2022 23:12:00 +0800 Xin Hao <xhao@linux.alibaba.com> wrote:

> Just do a little change here, the 'err' variable really no need to stay
> here.
> 
> Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
> ---
>  mm/damon/sysfs.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
> index 0cca1909bf67..b852a75b9f39 100644
> --- a/mm/damon/sysfs.c
> +++ b/mm/damon/sysfs.c
> @@ -1109,9 +1109,8 @@ static ssize_t start_store(struct kobject *kobj, struct kobj_attribute *attr,
>  {
>  	struct damon_sysfs_region *region = container_of(kobj,
>  			struct damon_sysfs_region, kobj);
> -	int err = kstrtoul(buf, 0, &region->start);
> 
> -	if (err)
> +	if (kstrtoul(buf, 0, &region->start))
>  		return -EINVAL;

Good finding.  But, I'd like to let the user know why it really fails by giving
them the error code that returned by 'kstrtoul()' here.  Let's keep the 'err'
but return 'err' here.

>  	return count;
>  }
> @@ -1130,9 +1129,8 @@ static ssize_t end_store(struct kobject *kobj, struct kobj_attribute *attr,
>  {
>  	struct damon_sysfs_region *region = container_of(kobj,
>  			struct damon_sysfs_region, kobj);
> -	int err = kstrtoul(buf, 0, &region->end);
> 
> -	if (err)
> +	if (kstrtoul(buf, 0, &region->end))
>  		return -EINVAL;

ditto.

>  	return count;
>  }
> --
> 2.31.0


Thanks,
SJ
haoxin Sept. 20, 2022, 1:54 a.m. UTC | #2
在 2022/9/20 上午1:03, SeongJae Park 写道:
> On Mon, 19 Sep 2022 23:12:00 +0800 Xin Hao <xhao@linux.alibaba.com> wrote:
>
>> Just do a little change here, the 'err' variable really no need to stay
>> here.
>>
>> Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
>> ---
>>   mm/damon/sysfs.c | 6 ++----
>>   1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
>> index 0cca1909bf67..b852a75b9f39 100644
>> --- a/mm/damon/sysfs.c
>> +++ b/mm/damon/sysfs.c
>> @@ -1109,9 +1109,8 @@ static ssize_t start_store(struct kobject *kobj, struct kobj_attribute *attr,
>>   {
>>   	struct damon_sysfs_region *region = container_of(kobj,
>>   			struct damon_sysfs_region, kobj);
>> -	int err = kstrtoul(buf, 0, &region->start);
>>
>> -	if (err)
>> +	if (kstrtoul(buf, 0, &region->start))
>>   		return -EINVAL;
> Good finding.  But, I'd like to let the user know why it really fails by giving
> them the error code that returned by 'kstrtoul()' here.  Let's keep the 'err'
> but return 'err' here.
Ok,  it make sense.
>
>>   	return count;
>>   }
>> @@ -1130,9 +1129,8 @@ static ssize_t end_store(struct kobject *kobj, struct kobj_attribute *attr,
>>   {
>>   	struct damon_sysfs_region *region = container_of(kobj,
>>   			struct damon_sysfs_region, kobj);
>> -	int err = kstrtoul(buf, 0, &region->end);
>>
>> -	if (err)
>> +	if (kstrtoul(buf, 0, &region->end))
>>   		return -EINVAL;
> ditto.
>
>>   	return count;
>>   }
>> --
>> 2.31.0
>
> Thanks,
> SJ
diff mbox series

Patch

diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 0cca1909bf67..b852a75b9f39 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1109,9 +1109,8 @@  static ssize_t start_store(struct kobject *kobj, struct kobj_attribute *attr,
 {
 	struct damon_sysfs_region *region = container_of(kobj,
 			struct damon_sysfs_region, kobj);
-	int err = kstrtoul(buf, 0, &region->start);

-	if (err)
+	if (kstrtoul(buf, 0, &region->start))
 		return -EINVAL;
 	return count;
 }
@@ -1130,9 +1129,8 @@  static ssize_t end_store(struct kobject *kobj, struct kobj_attribute *attr,
 {
 	struct damon_sysfs_region *region = container_of(kobj,
 			struct damon_sysfs_region, kobj);
-	int err = kstrtoul(buf, 0, &region->end);

-	if (err)
+	if (kstrtoul(buf, 0, &region->end))
 		return -EINVAL;
 	return count;
 }