All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH - UCM 1/2] control: enable octal and hexadecimal parse
@ 2015-01-14  1:08 han.lu
  2015-01-14 11:16 ` Takashi Iwai
  0 siblings, 1 reply; 7+ messages in thread
From: han.lu @ 2015-01-14  1:08 UTC (permalink / raw)
  To: patch; +Cc: Lu, Han, alsa-devel

From: "Lu, Han" <han.lu@intel.com>

Use zero-base for strtol(), so get_integer() and get_integer64()
can parse decimal, octal and hexadecimal data from input string.

Signed-off-by: Lu, Han <han.lu@intel.com>

diff --git a/src/control/ctlparse.c b/src/control/ctlparse.c
index 978977d..8d6c385 100644
--- a/src/control/ctlparse.c
+++ b/src/control/ctlparse.c
@@ -59,7 +59,7 @@ static long get_integer(const char **ptr, long min, long max)
 		goto out;
 
 	s = p;
-	val = strtol(s, &p, 10);
+	val = strtol(s, &p, 0);
 	if (*p == '.') {
 		p++;
 		strtol(p, &p, 10);
@@ -87,7 +87,7 @@ static long long get_integer64(const char **ptr, long long min, long long max)
 		goto out;
 
 	s = p;
-	val = strtol(s, &p, 10);
+	val = strtol(s, &p, 0);
 	if (*p == '.') {
 		p++;
 		strtol(p, &p, 10);
-- 
1.9.1

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

* Re: [PATCH - UCM 1/2] control: enable octal and hexadecimal parse
  2015-01-14  1:08 [PATCH - UCM 1/2] control: enable octal and hexadecimal parse han.lu
@ 2015-01-14 11:16 ` Takashi Iwai
  0 siblings, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2015-01-14 11:16 UTC (permalink / raw)
  To: han.lu; +Cc: alsa-devel

At Wed, 14 Jan 2015 09:08:30 +0800,
han.lu@intel.com wrote:
> 
> From: "Lu, Han" <han.lu@intel.com>
> 
> Use zero-base for strtol(), so get_integer() and get_integer64()
> can parse decimal, octal and hexadecimal data from input string.
> 
> Signed-off-by: Lu, Han <han.lu@intel.com>

Applied, thanks.


Takashi

> 
> diff --git a/src/control/ctlparse.c b/src/control/ctlparse.c
> index 978977d..8d6c385 100644
> --- a/src/control/ctlparse.c
> +++ b/src/control/ctlparse.c
> @@ -59,7 +59,7 @@ static long get_integer(const char **ptr, long min, long max)
>  		goto out;
>  
>  	s = p;
> -	val = strtol(s, &p, 10);
> +	val = strtol(s, &p, 0);
>  	if (*p == '.') {
>  		p++;
>  		strtol(p, &p, 10);
> @@ -87,7 +87,7 @@ static long long get_integer64(const char **ptr, long long min, long long max)
>  		goto out;
>  
>  	s = p;
> -	val = strtol(s, &p, 10);
> +	val = strtol(s, &p, 0);
>  	if (*p == '.') {
>  		p++;
>  		strtol(p, &p, 10);
> -- 
> 1.9.1
> 

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

* Re: [PATCH - UCM 1/2] control: enable octal and hexadecimal parse
  2015-01-13 20:01   ` Takashi Iwai
@ 2015-01-14  1:28     ` Lu, Han
  0 siblings, 0 replies; 7+ messages in thread
From: Lu, Han @ 2015-01-14  1:28 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Liam Girdwood, alsa-devel

> -----Original Message-----
> From: Takashi Iwai [mailto:tiwai@suse.de]
> Sent: Wednesday, January 14, 2015 4:02 AM
> To: Takashi Iwai
> Cc: Lu, Han; Liam Girdwood; alsa-devel@alsa-project.org
> Subject: Re: [PATCH - UCM 1/2] control: enable octal and hexadecimal parse
> 
> At Tue, 13 Jan 2015 17:53:14 +0100,
> Takashi Iwai wrote:
> >
> > At Tue, 13 Jan 2015 11:00:38 +0800,
> > han.lu@intel.com wrote:
> > >
> > > From: "Lu, Han" <han.lu@intel.com>
> > >
> > > Signed-off-by: Lu, Han <han.lu@intel.com>
> >
> > Looks good to me.  Liam, any objection for this extension?
> 
> Erm, sorry, I correct my statement: this is buggy.  Look at the code:
> 
> > > -	val = strtol(s, &p, 10);
> > > +	val = strtol(s, &p, 0);
> > >  	if (*p == '.') {
> > >  		p++;
> > > -		strtol(p, &p, 10);
> > > +		strtol(p, &p, 0);
> 
> The second strtol() is for skipping the decimals.  So this has to be 10-based.
> That is, use zero-base only for the first strtol().
> 
Yes. I thought of skipping hexadecimal, but string begin with ".0x" looks not reasonable, and string begin with ".0" will not be skipped as expected with this patch.
I have removed the second change and resend the patch. Please review, Thanks.

BR,
Han Lu
> 
> Takashi

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

* Re: [PATCH - UCM 1/2] control: enable octal and hexadecimal parse
  2015-01-13 16:53 ` Takashi Iwai
  2015-01-13 18:21   ` Liam Girdwood
@ 2015-01-13 20:01   ` Takashi Iwai
  2015-01-14  1:28     ` Lu, Han
  1 sibling, 1 reply; 7+ messages in thread
From: Takashi Iwai @ 2015-01-13 20:01 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Liam Girdwood, han.lu, alsa-devel

At Tue, 13 Jan 2015 17:53:14 +0100,
Takashi Iwai wrote:
> 
> At Tue, 13 Jan 2015 11:00:38 +0800,
> han.lu@intel.com wrote:
> > 
> > From: "Lu, Han" <han.lu@intel.com>
> > 
> > Signed-off-by: Lu, Han <han.lu@intel.com>
> 
> Looks good to me.  Liam, any objection for this extension?

Erm, sorry, I correct my statement: this is buggy.  Look at the code:

> > -	val = strtol(s, &p, 10);
> > +	val = strtol(s, &p, 0);
> >  	if (*p == '.') {
> >  		p++;
> > -		strtol(p, &p, 10);
> > +		strtol(p, &p, 0);

The second strtol() is for skipping the decimals.  So this has to be
10-based.  That is, use zero-base only for the first strtol().


Takashi

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

* Re: [PATCH - UCM 1/2] control: enable octal and hexadecimal parse
  2015-01-13 16:53 ` Takashi Iwai
@ 2015-01-13 18:21   ` Liam Girdwood
  2015-01-13 20:01   ` Takashi Iwai
  1 sibling, 0 replies; 7+ messages in thread
From: Liam Girdwood @ 2015-01-13 18:21 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: han.lu, alsa-devel

On Tue, 2015-01-13 at 17:53 +0100, Takashi Iwai wrote:
> At Tue, 13 Jan 2015 11:00:38 +0800,
> han.lu@intel.com wrote:
> > 
> > From: "Lu, Han" <han.lu@intel.com>
> > 
> > Signed-off-by: Lu, Han <han.lu@intel.com>
> 
> Looks good to me.  Liam, any objection for this extension?
> 

Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

> 
> thanks,
> 
> Takashi
> 
> > 
> > diff --git a/src/control/ctlparse.c b/src/control/ctlparse.c
> > index 978977d..acaf734 100644
> > --- a/src/control/ctlparse.c
> > +++ b/src/control/ctlparse.c
> > @@ -59,10 +59,10 @@ static long get_integer(const char **ptr, long min, long max)
> >  		goto out;
> >  
> >  	s = p;
> > -	val = strtol(s, &p, 10);
> > +	val = strtol(s, &p, 0);
> >  	if (*p == '.') {
> >  		p++;
> > -		strtol(p, &p, 10);
> > +		strtol(p, &p, 0);
> >  	}
> >  	if (*p == '%') {
> >  		val = (long)convert_prange1(strtod(s, NULL), min, max);
> > @@ -87,10 +87,10 @@ static long long get_integer64(const char **ptr, long long min, long long max)
> >  		goto out;
> >  
> >  	s = p;
> > -	val = strtol(s, &p, 10);
> > +	val = strtol(s, &p, 0);
> >  	if (*p == '.') {
> >  		p++;
> > -		strtol(p, &p, 10);
> > +		strtol(p, &p, 0);
> >  	}
> >  	if (*p == '%') {
> >  		val = (long long)convert_prange1(strtod(s, NULL), min, max);
> > -- 
> > 2.1.0
> > 

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

* Re: [PATCH - UCM 1/2] control: enable octal and hexadecimal parse
  2015-01-13  3:00 han.lu
@ 2015-01-13 16:53 ` Takashi Iwai
  2015-01-13 18:21   ` Liam Girdwood
  2015-01-13 20:01   ` Takashi Iwai
  0 siblings, 2 replies; 7+ messages in thread
From: Takashi Iwai @ 2015-01-13 16:53 UTC (permalink / raw)
  To: han.lu; +Cc: Liam Girdwood, alsa-devel

At Tue, 13 Jan 2015 11:00:38 +0800,
han.lu@intel.com wrote:
> 
> From: "Lu, Han" <han.lu@intel.com>
> 
> Signed-off-by: Lu, Han <han.lu@intel.com>

Looks good to me.  Liam, any objection for this extension?


thanks,

Takashi

> 
> diff --git a/src/control/ctlparse.c b/src/control/ctlparse.c
> index 978977d..acaf734 100644
> --- a/src/control/ctlparse.c
> +++ b/src/control/ctlparse.c
> @@ -59,10 +59,10 @@ static long get_integer(const char **ptr, long min, long max)
>  		goto out;
>  
>  	s = p;
> -	val = strtol(s, &p, 10);
> +	val = strtol(s, &p, 0);
>  	if (*p == '.') {
>  		p++;
> -		strtol(p, &p, 10);
> +		strtol(p, &p, 0);
>  	}
>  	if (*p == '%') {
>  		val = (long)convert_prange1(strtod(s, NULL), min, max);
> @@ -87,10 +87,10 @@ static long long get_integer64(const char **ptr, long long min, long long max)
>  		goto out;
>  
>  	s = p;
> -	val = strtol(s, &p, 10);
> +	val = strtol(s, &p, 0);
>  	if (*p == '.') {
>  		p++;
> -		strtol(p, &p, 10);
> +		strtol(p, &p, 0);
>  	}
>  	if (*p == '%') {
>  		val = (long long)convert_prange1(strtod(s, NULL), min, max);
> -- 
> 2.1.0
> 

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

* [PATCH - UCM 1/2] control: enable octal and hexadecimal parse
@ 2015-01-13  3:00 han.lu
  2015-01-13 16:53 ` Takashi Iwai
  0 siblings, 1 reply; 7+ messages in thread
From: han.lu @ 2015-01-13  3:00 UTC (permalink / raw)
  To: patch; +Cc: Lu, Han, alsa-devel

From: "Lu, Han" <han.lu@intel.com>

Signed-off-by: Lu, Han <han.lu@intel.com>

diff --git a/src/control/ctlparse.c b/src/control/ctlparse.c
index 978977d..acaf734 100644
--- a/src/control/ctlparse.c
+++ b/src/control/ctlparse.c
@@ -59,10 +59,10 @@ static long get_integer(const char **ptr, long min, long max)
 		goto out;
 
 	s = p;
-	val = strtol(s, &p, 10);
+	val = strtol(s, &p, 0);
 	if (*p == '.') {
 		p++;
-		strtol(p, &p, 10);
+		strtol(p, &p, 0);
 	}
 	if (*p == '%') {
 		val = (long)convert_prange1(strtod(s, NULL), min, max);
@@ -87,10 +87,10 @@ static long long get_integer64(const char **ptr, long long min, long long max)
 		goto out;
 
 	s = p;
-	val = strtol(s, &p, 10);
+	val = strtol(s, &p, 0);
 	if (*p == '.') {
 		p++;
-		strtol(p, &p, 10);
+		strtol(p, &p, 0);
 	}
 	if (*p == '%') {
 		val = (long long)convert_prange1(strtod(s, NULL), min, max);
-- 
2.1.0

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

end of thread, other threads:[~2015-01-14 11:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-14  1:08 [PATCH - UCM 1/2] control: enable octal and hexadecimal parse han.lu
2015-01-14 11:16 ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2015-01-13  3:00 han.lu
2015-01-13 16:53 ` Takashi Iwai
2015-01-13 18:21   ` Liam Girdwood
2015-01-13 20:01   ` Takashi Iwai
2015-01-14  1:28     ` Lu, Han

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.