diff mbox series

[v2] drivers/block/loop: Replace deprecated function in option parsing code

Message ID 20190625175517.31133-1-florian.knauf@stud.uni-hannover.de (mailing list archive)
State New, archived
Headers show
Series [v2] drivers/block/loop: Replace deprecated function in option parsing code | expand

Commit Message

Florian Knauf June 25, 2019, 5:55 p.m. UTC
This patch removes the deprecated simple_strtol function from the option
parsing logic in the loopback device driver. Instead kstrtoint is used to
parse int max_loop, to ensure that input values it cannot represent are
ignored.

Signed-off-by: Florian Knauf <florian.knauf@stud.uni-hannover.de>
Signed-off-by: Christian Ewert <christian.ewert@stud.uni-hannover.de>
---
Thank you for your feedback.

There's no specific reason to use kstrtol, other than the fact that we
weren't yet aware that kstrtoint exists. (We're new at this, I'm afraid.)

We've amended the patch to make use of kstrtoint, which is of course much
more straightforward.

drivers/block/loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chaitanya Kulkarni June 25, 2019, 7:24 p.m. UTC | #1
I believe you have tested this patch with loop testcases present in the 
:- https://github.com/osandov/blktests/tree/master/tests/loop.

With that, looks good.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>.

On 06/25/2019 10:55 AM, Florian Knauf wrote:
> This patch removes the deprecated simple_strtol function from the option
> parsing logic in the loopback device driver. Instead kstrtoint is used to
> parse int max_loop, to ensure that input values it cannot represent are
> ignored.
>
> Signed-off-by: Florian Knauf <florian.knauf@stud.uni-hannover.de>
> Signed-off-by: Christian Ewert <christian.ewert@stud.uni-hannover.de>
> ---
> Thank you for your feedback.
>
> There's no specific reason to use kstrtol, other than the fact that we
> weren't yet aware that kstrtoint exists. (We're new at this, I'm afraid.)
>
> We've amended the patch to make use of kstrtoint, which is of course much
> more straightforward.
>
> drivers/block/loop.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 102d79575895..adfaf4ad37d1 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -2289,7 +2289,7 @@ module_exit(loop_exit);
>   #ifndef MODULE
>   static int __init max_loop_setup(char *str)
>   {
> -	max_loop = simple_strtol(str, NULL, 0);
> +	kstrtoint(str, 0, &max_loop);
>   	return 1;
>   }
>
>
Florian Knauf June 29, 2019, 7:46 p.m. UTC | #2
I have now, on the latest staging master (test log attached, everything 
green), and also learned a lesson about looking more thoroughly for 
automated test cases. That's a mea culpa, I suppose. :P

Before this I'd only found the Linux Test Project, which (if I'm not 
mistaken) contains tests that use loopback devices but no tests that 
specifically test the loopback driver itself. Given the small scope of 
the change, we then considered it sufficient to test manually that the 
loop device still worked and that the max_loop parameter was handled 
correctly. Of course, the blktests way is better.

Thanks for taking the time to answer and review.

Am 25.06.19 um 21:24 schrieb Chaitanya Kulkarni:
> I believe you have tested this patch with loop testcases present in the
> :- https://github.com/osandov/blktests/tree/master/tests/loop.
> 
> With that, looks good.
> 
> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>.
> 
> On 06/25/2019 10:55 AM, Florian Knauf wrote:
>> This patch removes the deprecated simple_strtol function from the option
>> parsing logic in the loopback device driver. Instead kstrtoint is used to
>> parse int max_loop, to ensure that input values it cannot represent are
>> ignored.
>>
>> Signed-off-by: Florian Knauf <florian.knauf@stud.uni-hannover.de>
>> Signed-off-by: Christian Ewert <christian.ewert@stud.uni-hannover.de>
>> ---
>> Thank you for your feedback.
>>
>> There's no specific reason to use kstrtol, other than the fact that we
>> weren't yet aware that kstrtoint exists. (We're new at this, I'm afraid.)
>>
>> We've amended the patch to make use of kstrtoint, which is of course much
>> more straightforward.
>>
>> drivers/block/loop.c | 2 +-
>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
>> index 102d79575895..adfaf4ad37d1 100644
>> --- a/drivers/block/loop.c
>> +++ b/drivers/block/loop.c
>> @@ -2289,7 +2289,7 @@ module_exit(loop_exit);
>>    #ifndef MODULE
>>    static int __init max_loop_setup(char *str)
>>    {
>> -	max_loop = simple_strtol(str, NULL, 0);
>> +	kstrtoint(str, 0, &max_loop);
>>    	return 1;
>>    }
>>
>>
>
Chaitanya Kulkarni July 2, 2019, 5:04 a.m. UTC | #3
You are welcome.
> On Jun 29, 2019, at 12:46 PM, Florian Knauf <florian.knauf@stud.uni-hannover.de> wrote:
> 
> I have now, on the latest staging master (test log attached, everything green), and also learned a lesson about looking more thoroughly for automated test cases. That's a mea culpa, I suppose. :P
> 
> Before this I'd only found the Linux Test Project, which (if I'm not mistaken) contains tests that use loopback devices but no tests that specifically test the loopback driver itself. Given the small scope of the change, we then considered it sufficient to test manually that the loop device still worked and that the max_loop parameter was handled correctly. Of course, the blktests way is better.
> 
> Thanks for taking the time to answer and review.
> 
>> Am 25.06.19 um 21:24 schrieb Chaitanya Kulkarni:
>> I believe you have tested this patch with loop testcases present in the
>> :- https://github.com/osandov/blktests/tree/master/tests/loop.
>> With that, looks good.
>> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>.
>>> On 06/25/2019 10:55 AM, Florian Knauf wrote:
>>> This patch removes the deprecated simple_strtol function from the option
>>> parsing logic in the loopback device driver. Instead kstrtoint is used to
>>> parse int max_loop, to ensure that input values it cannot represent are
>>> ignored.
>>> 
>>> Signed-off-by: Florian Knauf <florian.knauf@stud.uni-hannover.de>
>>> Signed-off-by: Christian Ewert <christian.ewert@stud.uni-hannover.de>
>>> ---
>>> Thank you for your feedback.
>>> 
>>> There's no specific reason to use kstrtol, other than the fact that we
>>> weren't yet aware that kstrtoint exists. (We're new at this, I'm afraid.)
>>> 
>>> We've amended the patch to make use of kstrtoint, which is of course much
>>> more straightforward.
>>> 
>>> drivers/block/loop.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
>>> index 102d79575895..adfaf4ad37d1 100644
>>> --- a/drivers/block/loop.c
>>> +++ b/drivers/block/loop.c
>>> @@ -2289,7 +2289,7 @@ module_exit(loop_exit);
>>>   #ifndef MODULE
>>>   static int __init max_loop_setup(char *str)
>>>   {
>>> -    max_loop = simple_strtol(str, NULL, 0);
>>> +    kstrtoint(str, 0, &max_loop);
>>>       return 1;
>>>   }
>>> 
>>> 
> <check.log>
diff mbox series

Patch

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 102d79575895..adfaf4ad37d1 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2289,7 +2289,7 @@  module_exit(loop_exit);
 #ifndef MODULE
 static int __init max_loop_setup(char *str)
 {
-	max_loop = simple_strtol(str, NULL, 0);
+	kstrtoint(str, 0, &max_loop);
 	return 1;
 }