diff mbox

[U-Boot,v1] cmd: itest: correct calculus for long format

Message ID 20170210125915.73744-1-andriy.shevchenko@linux.intel.com
State Accepted
Commit 2c79fd401982c7d6c5e77c09bc7035f8a3766c88
Delegated to: Tom Rini
Headers show

Commit Message

Andy Shevchenko Feb. 10, 2017, 12:59 p.m. UTC
From: Sebastien Colleur <sebastienx.colleur@intel.com>

itest shell command doesn't work correctly in long format when
doing comparaison due to wrong mask value calculus that overflow
on 32 bits values.

Signed-off-by: Sebastien Colleur <sebastienx.colleur@intel.com>
---
 cmd/itest.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Simon Glass Feb. 10, 2017, 6:38 p.m. UTC | #1
On 10 February 2017 at 05:59, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> From: Sebastien Colleur <sebastienx.colleur@intel.com>
>
> itest shell command doesn't work correctly in long format when
> doing comparaison due to wrong mask value calculus that overflow
> on 32 bits values.
>
> Signed-off-by: Sebastien Colleur <sebastienx.colleur@intel.com>
> ---
>  cmd/itest.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Seems reasonable to me.

Reviewed-by: Simon Glass <sjg@chromium.org>
Andy Shevchenko Feb. 17, 2017, 12:57 p.m. UTC | #2
On Fri, Feb 10, 2017 at 8:38 PM, Simon Glass <sjg@chromium.org> wrote:
> On 10 February 2017 at 05:59, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
>> From: Sebastien Colleur <sebastienx.colleur@intel.com>
>>
>> itest shell command doesn't work correctly in long format when
>> doing comparaison due to wrong mask value calculus that overflow
>> on 32 bits values.

> Reviewed-by: Simon Glass <sjg@chromium.org>

Thanks!

To whom should I send this to get it applied? Or just wait when
maintainers pick this up?
Stefan Roese Feb. 17, 2017, 1 p.m. UTC | #3
On 17.02.2017 13:57, Andy Shevchenko wrote:
> On Fri, Feb 10, 2017 at 8:38 PM, Simon Glass <sjg@chromium.org> wrote:
>> On 10 February 2017 at 05:59, Andy Shevchenko
>> <andriy.shevchenko@linux.intel.com> wrote:
>>> From: Sebastien Colleur <sebastienx.colleur@intel.com>
>>>
>>> itest shell command doesn't work correctly in long format when
>>> doing comparaison due to wrong mask value calculus that overflow
>>> on 32 bits values.
>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> Thanks!
>
> To whom should I send this to get it applied? Or just wait when
> maintainers pick this up?

As this patch doesn't fall into a special custodian responsibility, Tom
usually keeps track of it and will apply it - most likely after the
next release. But it's always a good idea to check from time to time, if
such patches have been applied and "ping" again if not.

Thanks,
Stefan
Andy Shevchenko Feb. 17, 2017, 1:04 p.m. UTC | #4
On Fri, Feb 17, 2017 at 3:00 PM, Stefan Roese <sr@denx.de> wrote:
> On 17.02.2017 13:57, Andy Shevchenko wrote:

>> To whom should I send this to get it applied? Or just wait when
>> maintainers pick this up?

> As this patch doesn't fall into a special custodian responsibility, Tom
> usually keeps track of it and will apply it - most likely after the
> next release. But it's always a good idea to check from time to time, if
> such patches have been applied and "ping" again if not.

Okay, thanks for clarification.
Andy Shevchenko Feb. 28, 2017, 10:55 a.m. UTC | #5
On Fri, Feb 17, 2017 at 3:00 PM, Stefan Roese <sr@denx.de> wrote:
> On 17.02.2017 13:57, Andy Shevchenko wrote:
>> On Fri, Feb 10, 2017 at 8:38 PM, Simon Glass <sjg@chromium.org> wrote:
>>> On 10 February 2017 at 05:59, Andy Shevchenko
>>> <andriy.shevchenko@linux.intel.com> wrote:

>>>> itest shell command doesn't work correctly in long format when
>>>> doing comparaison due to wrong mask value calculus that overflow
>>>> on 32 bits values.

>>> Reviewed-by: Simon Glass <sjg@chromium.org>

>> Thanks!
>>
>> To whom should I send this to get it applied? Or just wait when
>> maintainers pick this up?

> As this patch doesn't fall into a special custodian responsibility, Tom
> usually keeps track of it and will apply it - most likely after the
> next release. But it's always a good idea to check from time to time, if
> such patches have been applied and "ping" again if not.

Tom, there is no such in -rc3, please apply if no objections.
Tom Rini March 18, 2017, 12:15 a.m. UTC | #6
On Fri, Feb 10, 2017 at 03:59:15PM +0300, Andy Shevchenko wrote:

> From: Sebastien Colleur <sebastienx.colleur@intel.com>
> 
> itest shell command doesn't work correctly in long format when
> doing comparaison due to wrong mask value calculus that overflow
> on 32 bits values.
> 
> Signed-off-by: Sebastien Colleur <sebastienx.colleur@intel.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/cmd/itest.c b/cmd/itest.c
index 60626c7fe9..e1896d9f97 100644
--- a/cmd/itest.c
+++ b/cmd/itest.c
@@ -80,7 +80,8 @@  static long evalexp(char *s, int w)
 		l = simple_strtoul(s, NULL, 16);
 	}
 
-	return l & ((1UL << (w * 8)) - 1);
+	/* avoid overflow on mask calculus */
+	return (w >= sizeof(long)) ? l : (l & ((1UL << (w * 8)) - 1));
 }
 
 static char * evalstr(char *s)