From: Vincent Palatin Date: Mon, 25 Jul 2011 23:19:05 +0000 (-0700) Subject: sd: do not add one sector to the disk size X-Git-Tag: qemu-xen-4.3.0-rc1~2628^2~38 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5e37141bbb9796ef139aee902a882ca97d59b84d;p=qemu-upstream-4.5-testing.git sd: do not add one sector to the disk size This leads to random off-by-one error. When the size of the SD is exactly 1GB, the emulation was returning a wrong SDHC CSD descriptor. Signed-off-by: Vincent Palatin Signed-off-by: Andrzej Zaborowski --- diff --git a/hw/sd.c b/hw/sd.c index 219a0dd29..c2c80ab7b 100644 --- a/hw/sd.c +++ b/hw/sd.c @@ -393,9 +393,7 @@ static void sd_reset(SDState *sd, BlockDriverState *bdrv) } else { sect = 0; } - sect <<= 9; - - size = sect + 1; + size = sect << 9; sect = (size >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT)) + 1;