[v2] examples/pipeline: support CLI hex args

Message ID 1616588553-47065-1-git-send-email-churchill.khangar@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] examples/pipeline: support CLI hex args |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success travis build: passed
ci/github-robot success github build: passed
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Churchill Khangar March 24, 2021, 12:22 p.m. UTC
  This patch allows specification of integer arguments for the
CLI commands in hexadecimal and octal as well as decimal.

Signed-off-by: Churchill Khangar <churchill.khangar@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 examples/pipeline/cli.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

David Marchand March 24, 2021, 12:31 p.m. UTC | #1
On Wed, Mar 24, 2021 at 1:20 PM Churchill Khangar
<churchill.khangar@intel.com> wrote:
>
> This patch allows specification of integer arguments for the
> CLI commands in hexadecimal and octal as well as decimal.
>
> Signed-off-by: Churchill Khangar <churchill.khangar@intel.com>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> ---
>  examples/pipeline/cli.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
> index ae06658..ef49eb8 100644
> --- a/examples/pipeline/cli.c
> +++ b/examples/pipeline/cli.c
> @@ -55,7 +55,7 @@
>         if (!isdigit(*p))

Not directly related to this change, but the isdigit() check is
probably useless.
strtoul returns the first invalid char.

>                 return -EINVAL;
>
> -       val = strtoul(p, &next, 10);
> +       val = strtoul(p, &next, 0);
  
Cristian Dumitrescu March 24, 2021, 12:52 p.m. UTC | #2
> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Wednesday, March 24, 2021 12:31 PM
> To: Khangar, Churchill <churchill.khangar@intel.com>
> Cc: dev <dev@dpdk.org>; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>; P, Venkata Suresh Kumar
> <venkata.suresh.kumar.p@intel.com>; Jangra, Yogesh
> <yogesh.jangra@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v2] examples/pipeline: support CLI hex args
> 
> On Wed, Mar 24, 2021 at 1:20 PM Churchill Khangar
> <churchill.khangar@intel.com> wrote:
> >
> > This patch allows specification of integer arguments for the
> > CLI commands in hexadecimal and octal as well as decimal.
> >
> > Signed-off-by: Churchill Khangar <churchill.khangar@intel.com>
> > Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> > ---
> >  examples/pipeline/cli.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
> > index ae06658..ef49eb8 100644
> > --- a/examples/pipeline/cli.c
> > +++ b/examples/pipeline/cli.c
> > @@ -55,7 +55,7 @@
> >         if (!isdigit(*p))
> 
> Not directly related to this change, but the isdigit() check is
> probably useless.
> strtoul returns the first invalid char.
> 

Yes, correct, more improvements could be made, we'll put it on the to-do list. Thanks, David.

> >                 return -EINVAL;
> >
> > -       val = strtoul(p, &next, 10);
> > +       val = strtoul(p, &next, 0);
> 
> 
> --
> David Marchand
  
Thomas Monjalon March 24, 2021, 5:25 p.m. UTC | #3
24/03/2021 13:22, Churchill Khangar:
> This patch allows specification of integer arguments for the
> CLI commands in hexadecimal and octal as well as decimal.
> 
> Signed-off-by: Churchill Khangar <churchill.khangar@intel.com>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks.
  

Patch

diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
index ae06658..ef49eb8 100644
--- a/examples/pipeline/cli.c
+++ b/examples/pipeline/cli.c
@@ -55,7 +55,7 @@ 
 	if (!isdigit(*p))
 		return -EINVAL;
 
-	val = strtoul(p, &next, 10);
+	val = strtoul(p, &next, 0);
 	if (p == next)
 		return -EINVAL;