All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] signrom.sh: portability fix
@ 2009-07-17 13:23 Christoph Egger
  2009-07-17 14:37 ` Alexander Graf
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Egger @ 2009-07-17 13:23 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 475 bytes --]


Hi!

Attached patch makes signrom.sh working on NetBSD.
The output of the 'od' command leads to a syntax error
which breaks the build.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>

-- 
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

[-- Attachment #2: qemu_signrom.diff --]
[-- Type: text/x-diff, Size: 516 bytes --]

diff --git a/pc-bios/optionrom/signrom.sh b/pc-bios/optionrom/signrom.sh
index 263ba5f..4322811 100755
--- a/pc-bios/optionrom/signrom.sh
+++ b/pc-bios/optionrom/signrom.sh
@@ -31,9 +31,10 @@ x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 -A n`
 size=$(( $x * 512 - 1 ))
 
 # now get the checksum
-for i in `od -A n -t u1 -v "$1"`; do
+nums=`od -A n -t u1 -v "$1"`
+for i in ${nums}; do
     # add each byte's value to sum
-    sum=$(( $sum + $i ))
+    sum=`expr $sum + $i`
 done
 
 sum=$(( $sum % 256 ))

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

* Re: [Qemu-devel] [PATCH] signrom.sh: portability fix
  2009-07-17 13:23 [Qemu-devel] [PATCH] signrom.sh: portability fix Christoph Egger
@ 2009-07-17 14:37 ` Alexander Graf
  2012-01-23 14:31   ` Jan Kiszka
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Graf @ 2009-07-17 14:37 UTC (permalink / raw)
  To: Christoph Egger; +Cc: qemu-devel


On 17.07.2009, at 15:23, Christoph Egger wrote:

>
> Hi!
>
> Attached patch makes signrom.sh working on NetBSD.
> The output of the 'od' command leads to a syntax error
> which breaks the build.

So why replace the $(( ... )) calculation with expr then? A few lines  
below there's another $(( )) that apparently works.

Btw: Inlined patches are very much appreciated :-)

Alex

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

* Re: [Qemu-devel] [PATCH] signrom.sh: portability fix
  2009-07-17 14:37 ` Alexander Graf
@ 2012-01-23 14:31   ` Jan Kiszka
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Kiszka @ 2012-01-23 14:31 UTC (permalink / raw)
  To: Christoph Egger; +Cc: Alexander Graf, qemu-devel

On 2009-07-17 16:37, Alexander Graf wrote:
> 
> On 17.07.2009, at 15:23, Christoph Egger wrote:
> 
>>
>> Hi!
>>
>> Attached patch makes signrom.sh working on NetBSD.
>> The output of the 'od' command leads to a syntax error
>> which breaks the build.
> 
> So why replace the $(( ... )) calculation with expr then? A few lines
> below there's another $(( )) that apparently works.

Picking up this old topic again: Forking expr in this tight loop is a
very bad idea. It makes signing a fairly long running step of the build
process for any non-trivial rom (I'm about to add one of those).

Can you please provide an example output for the ${nums} variable that
used to break for you so that we can find a fork-free algorithm?

Thanks,
Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

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

* Re: [Qemu-devel] [PATCH] signrom.sh: portability fix
  2009-07-17 16:06 Christoph Egger
@ 2009-07-20  7:48 ` Alexander Graf
  0 siblings, 0 replies; 5+ messages in thread
From: Alexander Graf @ 2009-07-20  7:48 UTC (permalink / raw)
  To: Christoph Egger; +Cc: qemu-devel


On 17.07.2009, at 18:06, Christoph Egger wrote:

> On Friday 17 July 2009 16:37:38 Alexander Graf wrote:
>> On 17.07.2009, at 15:23, Christoph Egger wrote:
>>> Hi!
>>>
>>> Attached patch makes signrom.sh working on NetBSD.
>>> The output of the 'od' command leads to a syntax error
>>> which breaks the build.
>>
>> So why replace the $(( ... )) calculation with expr then?
>
> because $i contains some whitespaces and leading zeros.
> This lets the bourne shell think, $i is a string and doing math with  
> strings
> results in syntax error.
> Passing it down into expr trims them.
>
>> A few lines below there's another $(( )) that apparently works.
>
> $sum is not a string there.

Ok, patch looks fine then.

Acked-By: Alexander Graf <agraf@suse.de>

>> Btw: Inlined patches are very much appreciated :-)
>
> Not for me because kmail malforms those with tabs,
> so that they don't apply cleanly.

Use git-send-email then. It's really no fun to review attached patches.

Alex

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

* Re: [Qemu-devel] [PATCH] signrom.sh: portability fix
@ 2009-07-17 16:06 Christoph Egger
  2009-07-20  7:48 ` Alexander Graf
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Egger @ 2009-07-17 16:06 UTC (permalink / raw)
  To: qemu-devel, Alexander Graf

On Friday 17 July 2009 16:37:38 Alexander Graf wrote:
> On 17.07.2009, at 15:23, Christoph Egger wrote:
> > Hi!
> >
> > Attached patch makes signrom.sh working on NetBSD.
> > The output of the 'od' command leads to a syntax error
> > which breaks the build.
>
> So why replace the $(( ... )) calculation with expr then?

because $i contains some whitespaces and leading zeros.
This lets the bourne shell think, $i is a string and doing math with strings 
results in syntax error.
Passing it down into expr trims them.

> A few lines below there's another $(( )) that apparently works.

$sum is not a string there.

> Btw: Inlined patches are very much appreciated :-)

Not for me because kmail malforms those with tabs,
so that they don't apply cleanly.

Christoph


-- 
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

-------------------------------------------------------

-- 
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

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

end of thread, other threads:[~2012-01-23 14:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-17 13:23 [Qemu-devel] [PATCH] signrom.sh: portability fix Christoph Egger
2009-07-17 14:37 ` Alexander Graf
2012-01-23 14:31   ` Jan Kiszka
2009-07-17 16:06 Christoph Egger
2009-07-20  7:48 ` Alexander Graf

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.