public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1 linux-next] exofs: convert simple_str to kstr
@ 2015-04-29 17:58 Fabian Frederick
  2015-04-30  7:55 ` Boaz Harrosh
  0 siblings, 1 reply; 5+ messages in thread
From: Fabian Frederick @ 2015-04-29 17:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alexander Viro, Fabian Frederick, Boaz Harrosh, Benny Halevy,
	osd-dev

replace obsolete function.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
This is untested.

 fs/exofs/super.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/exofs/super.c b/fs/exofs/super.c
index b795c56..b667f73 100644
--- a/fs/exofs/super.c
+++ b/fs/exofs/super.c
@@ -108,9 +108,14 @@ static int parse_options(char *options, struct exofs_mountopt *opts)
 			opts->is_osdname = true;
 			break;
 		case Opt_pid:
+		{
+			int rc;
+
 			if (0 == match_strlcpy(str, &args[0], sizeof(str)))
 				return -EINVAL;
-			opts->pid = simple_strtoull(str, NULL, 0);
+			rc = kstrtoull(str, 0, &opts->pid);
+			if (rc)
+				return rc;
 			if (opts->pid < EXOFS_MIN_PID) {
 				EXOFS_ERR("Partition ID must be >= %u",
 					  EXOFS_MIN_PID);
@@ -118,6 +123,7 @@ static int parse_options(char *options, struct exofs_mountopt *opts)
 			}
 			s_pid = 1;
 			break;
+		}
 		case Opt_to:
 			if (match_int(&args[0], &option))
 				return -EINVAL;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1 linux-next] exofs: convert simple_str to kstr
  2015-04-29 17:58 [PATCH 1/1 linux-next] exofs: convert simple_str to kstr Fabian Frederick
@ 2015-04-30  7:55 ` Boaz Harrosh
  2015-04-30 18:47   ` Fabian Frederick
  0 siblings, 1 reply; 5+ messages in thread
From: Boaz Harrosh @ 2015-04-30  7:55 UTC (permalink / raw)
  To: Fabian Frederick, linux-kernel; +Cc: Alexander Viro, Benny Halevy, osd-dev

On 04/29/2015 08:58 PM, Fabian Frederick wrote:
> replace obsolete function.
> 
> Signed-off-by: Fabian Frederick <fabf@skynet.be>

Thanks.
ACK-by: Boaz Harrosh <ooo@electrozaur.com>

Are you pushing all these through some tree, or
You need that I push it? Maybe push all these changes
through some central place, like Andrew's tree?

Boaz

> ---
> This is untested.
> 
>  fs/exofs/super.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/exofs/super.c b/fs/exofs/super.c
> index b795c56..b667f73 100644
> --- a/fs/exofs/super.c
> +++ b/fs/exofs/super.c
> @@ -108,9 +108,14 @@ static int parse_options(char *options, struct exofs_mountopt *opts)
>  			opts->is_osdname = true;
>  			break;
>  		case Opt_pid:
> +		{
> +			int rc;
> +
>  			if (0 == match_strlcpy(str, &args[0], sizeof(str)))
>  				return -EINVAL;
> -			opts->pid = simple_strtoull(str, NULL, 0);
> +			rc = kstrtoull(str, 0, &opts->pid);
> +			if (rc)
> +				return rc;
>  			if (opts->pid < EXOFS_MIN_PID) {
>  				EXOFS_ERR("Partition ID must be >= %u",
>  					  EXOFS_MIN_PID);
> @@ -118,6 +123,7 @@ static int parse_options(char *options, struct exofs_mountopt *opts)
>  			}
>  			s_pid = 1;
>  			break;
> +		}
>  		case Opt_to:
>  			if (match_int(&args[0], &option))
>  				return -EINVAL;
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1 linux-next] exofs: convert simple_str to kstr
@ 2015-04-30 11:06 Alexey Dobriyan
  2015-04-30 11:32 ` Alexey Dobriyan
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Dobriyan @ 2015-04-30 11:06 UTC (permalink / raw)
  To: fabf, ooo; +Cc: Linux Kernel

>   case Opt_pid:
> + {
> + int rc;
> +
>   if (0 == match_strlcpy(str, &args[0], sizeof(str)))
>   return -EINVAL;
> - opts->pid = simple_strtoull(str, NULL, 0);
> + rc = kstrtoull(str, 0, &opts->pid);
> + if (rc)
> + return rc;

kstrto*() functions were designed for proc/sysfs/sysctl/debugfs/...
files accepting 1 value from shell:

  echo 42 >/proc/foo

To keep this simplest usecase simple kstrto*() functions accept
one optional newline character before mandatory NUL.
But in mount option parsing newlines aren't supposed to be.

I'll resend parse_integer() shortly which is better suited for such code
http://marc.info/?l=linux-kernel&m=142876674416451&w=4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1 linux-next] exofs: convert simple_str to kstr
  2015-04-30 11:06 Alexey Dobriyan
@ 2015-04-30 11:32 ` Alexey Dobriyan
  0 siblings, 0 replies; 5+ messages in thread
From: Alexey Dobriyan @ 2015-04-30 11:32 UTC (permalink / raw)
  To: fabf, ooo; +Cc: Linux Kernel

On Thu, Apr 30, 2015 at 2:06 PM, Alexey Dobriyan <adobriyan@gmail.com> wrote:
>>   case Opt_pid:
>> + {
>> + int rc;
>> +
>>   if (0 == match_strlcpy(str, &args[0], sizeof(str)))
>>   return -EINVAL;
>> - opts->pid = simple_strtoull(str, NULL, 0);
>> + rc = kstrtoull(str, 0, &opts->pid);
>> + if (rc)
>> + return rc;
>
> kstrto*() functions were designed for proc/sysfs/sysctl/debugfs/...
> files accepting 1 value from shell:
>
>   echo 42 >/proc/foo
>
> To keep this simplest usecase simple kstrto*() functions accept
> one optional newline character before mandatory NUL.
> But in mount option parsing newlines aren't supposed to be.
>
> I'll resend parse_integer() shortly which is better suited for such code
> http://marc.info/?l=linux-kernel&m=142876674416451&w=4

It should be better:
* strsep/match_token/match_*() doesn't support u64 type,
* even if it did current code does useless copy:

char str[32];
token = match_token(p, tokens, args);
switch (token) {
case Opt_pid:
    if (0 == match_strlcpy(str, &args[0], sizeof(str)))
        return -EINVAL;
    opts->pid = simple_strtoull(str, NULL, 0);


With parse_integer() code would look like:

case Opt_pid:
    rv = parse_integer(args[0].from, 0, &opts->pid);
    if (rv < 0)
        return rv;
    if (args[0].from[rv] != '\0')
        return -EINVAL;

And if and when match_token interface will start verifying
that integer occupies whole options wihout junk at the end,
that second NUL check can be removed as well.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1 linux-next] exofs: convert simple_str to kstr
  2015-04-30  7:55 ` Boaz Harrosh
@ 2015-04-30 18:47   ` Fabian Frederick
  0 siblings, 0 replies; 5+ messages in thread
From: Fabian Frederick @ 2015-04-30 18:47 UTC (permalink / raw)
  To: linux-kernel, Boaz Harrosh
  Cc: Benny Halevy, Alexander Viro, osd-dev, adobriyan



> On 30 April 2015 at 09:55 Boaz Harrosh <ooo@electrozaur.com> wrote:
>
>
> On 04/29/2015 08:58 PM, Fabian Frederick wrote:
> > replace obsolete function.
> >
> > Signed-off-by: Fabian Frederick <fabf@skynet.be>
>
> Thanks.
> ACK-by: Boaz Harrosh <ooo@electrozaur.com>
>
> Are you pushing all these through some tree, or
> You need that I push it? Maybe push all these changes
> through some central place, like Andrew's tree?

Thanks Boaz, I don't use any tree ; I could forward this patch to Andrew but I
guess you
prefer Alexey's solution which uses parse_integer() instead of
match_strlcpy() ?

http://marc.info/?l=linux-kernel&m=143039354303440&w=2

Regards,
Fabian

>
> Boaz
>
> > ---
> > This is untested.
> >
> >  fs/exofs/super.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/exofs/super.c b/fs/exofs/super.c
> > index b795c56..b667f73 100644
> > --- a/fs/exofs/super.c
> > +++ b/fs/exofs/super.c
> > @@ -108,9 +108,14 @@ static int parse_options(char *options, struct
> > exofs_mountopt *opts)
> >                     opts->is_osdname = true;
> >                     break;
> >             case Opt_pid:
> > +           {
> > +                   int rc;
> > +
> >                     if (0 == match_strlcpy(str, &args[0], sizeof(str)))
> >                             return -EINVAL;
> > -                   opts->pid = simple_strtoull(str, NULL, 0);
> > +                   rc = kstrtoull(str, 0, &opts->pid);
> > +                   if (rc)
> > +                           return rc;
> >                     if (opts->pid < EXOFS_MIN_PID) {
> >                             EXOFS_ERR("Partition ID must be >= %u",
> >                                       EXOFS_MIN_PID);
> > @@ -118,6 +123,7 @@ static int parse_options(char *options, struct
> > exofs_mountopt *opts)
> >                     }
> >                     s_pid = 1;
> >                     break;
> > +           }
> >             case Opt_to:
> >                     if (match_int(&args[0], &option))
> >                             return -EINVAL;
> >
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-04-30 18:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-29 17:58 [PATCH 1/1 linux-next] exofs: convert simple_str to kstr Fabian Frederick
2015-04-30  7:55 ` Boaz Harrosh
2015-04-30 18:47   ` Fabian Frederick
  -- strict thread matches above, loose matches on Subject: below --
2015-04-30 11:06 Alexey Dobriyan
2015-04-30 11:32 ` Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox