Patchwork [1/1] bootimg: Fix a math thinko in the block count calculation

login
register
mail settings
Submitter Darren Hart
Date Jan. 25, 2012, 5:20 a.m.
Message ID <68ac20e3e44f7da9e9732c1dc38448c07708475e.1327468756.git.dvhart@linux.intel.com>
Download mbox | patch
Permalink /patch/20107/
State Accepted
Commit b35384fa3ca96b31c63d764322215abced2066e4
Headers show

Comments

Darren Hart - Jan. 25, 2012, 5:20 a.m.
Fixes [YOCTO #1852] ... again.

The conversion from sectors to blocks was multiplying by 2 instead
of dividing by 2. Blocks are 1024 bytes, sectors are 512 bytes. The
result was images being much larger than intended.

Reported-by: Tom Zanussi <tom.zanussi@intel.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
CC: Joshua Lock <josh@linux.intel.com>
---
 meta/classes/bootimg.bbclass |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Tom Zanussi - Jan. 25, 2012, 5:53 a.m.
On Tue, 2012-01-24 at 21:20 -0800, Darren Hart wrote:
> Fixes [YOCTO #1852] ... again.
> 
> The conversion from sectors to blocks was multiplying by 2 instead
> of dividing by 2. Blocks are 1024 bytes, sectors are 512 bytes. The
> result was images being much larger than intended.
> 

Much better, thanks for the quick fix.

Tested-by: Tom Zanussi <tom.zanussi@intel.com>

> Reported-by: Tom Zanussi <tom.zanussi@intel.com>
> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
> CC: Joshua Lock <josh@linux.intel.com>
> ---
>  meta/classes/bootimg.bbclass |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/meta/classes/bootimg.bbclass b/meta/classes/bootimg.bbclass
> index df3ee73..e65bef7 100644
> --- a/meta/classes/bootimg.bbclass
> +++ b/meta/classes/bootimg.bbclass
> @@ -133,7 +133,7 @@ build_hddimg() {
>  		SECTORS=$(expr $SECTORS + $(expr $DIR_SECTORS + $FAT_SECTORS))
>  
>  		# Determine the final size in blocks accounting for some padding
> -		BLOCKS=$(expr $(expr $SECTORS \* 2) + ${BOOTIMG_EXTRA_SPACE})
> +		BLOCKS=$(expr $(expr $SECTORS / 2) + ${BOOTIMG_EXTRA_SPACE})
>  
>  		# Ensure total sectors is an integral number of sectors per
>  		# track or mcopy will complain. Sectors are 512 bytes, and we
Richard Purdie - Jan. 25, 2012, 3:21 p.m.
On Tue, 2012-01-24 at 21:20 -0800, Darren Hart wrote:
> Fixes [YOCTO #1852] ... again.
> 
> The conversion from sectors to blocks was multiplying by 2 instead
> of dividing by 2. Blocks are 1024 bytes, sectors are 512 bytes. The
> result was images being much larger than intended.
> 
> Reported-by: Tom Zanussi <tom.zanussi@intel.com>
> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
> CC: Joshua Lock <josh@linux.intel.com>
> ---
>  meta/classes/bootimg.bbclass |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Merged to master, thanks.

Richard

Patch

diff --git a/meta/classes/bootimg.bbclass b/meta/classes/bootimg.bbclass
index df3ee73..e65bef7 100644
--- a/meta/classes/bootimg.bbclass
+++ b/meta/classes/bootimg.bbclass
@@ -133,7 +133,7 @@  build_hddimg() {
 		SECTORS=$(expr $SECTORS + $(expr $DIR_SECTORS + $FAT_SECTORS))
 
 		# Determine the final size in blocks accounting for some padding
-		BLOCKS=$(expr $(expr $SECTORS \* 2) + ${BOOTIMG_EXTRA_SPACE})
+		BLOCKS=$(expr $(expr $SECTORS / 2) + ${BOOTIMG_EXTRA_SPACE})
 
 		# Ensure total sectors is an integral number of sectors per
 		# track or mcopy will complain. Sectors are 512 bytes, and we