On Mon, Apr 19, 2010 at 3:10 PM, Kevin Wolf <kw...@redhat.com> wrote: >> @@ -416,9 +417,7 @@ static int bdrv_open_common(BlockDriverState *bs, const >> char *filename, >> } >> >> bs->keep_read_only = bs->read_only = !(open_flags & BDRV_O_RDWR); >> - if (drv->bdrv_getlength) { >> - bs->total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; >> - } >> + bs->total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; > > Does this hunk make a difference? If drv->bdrv_getlength == NULL, we'll > just get back the current value.
The if statement could be left as is. I removed it to reduce the number of places where if (drv->bdrv_getlength) is explicitly checked. If callers don't know the internals of bdrv_getlength() then it is easier to extend it without auditing and changing callers. Having said that, I did add an if (drv->bdrv_getlength) check into bdrv_truncate... > But now that you sent this hunk for review, one thing about the existing > code: We should probably check the return value of bdrv_getlength. You're right. I'll clean this up and send a v2. Stefan