[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-stable] [Qemu-devel] [PATCH] vmdk: byteswap VMDK4Header.desc_o
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-stable] [Qemu-devel] [PATCH] vmdk: byteswap VMDK4Header.desc_offset field |
Date: |
Mon, 10 Jun 2013 16:36:07 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Am 10.06.2013 um 16:32 hat Stefan Hajnoczi geschrieben:
> On Mon, Jun 10, 2013 at 04:04:55PM +0200, Kevin Wolf wrote:
> > Am 10.06.2013 um 11:07 hat Stefan Hajnoczi geschrieben:
> > > Remember to byteswap VMDK4Header.desc_offset on big-endian machines.
> > >
> > > Cc: address@hidden
> > > Signed-off-by: Stefan Hajnoczi <address@hidden>
> >
> > Thanks, applied to the block layer.
> >
> > > @@ -507,8 +507,11 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
> > > if (ret < 0) {
> > > return ret;
> > > }
> > > - if (header.capacity == 0 && header.desc_offset) {
> > > - return vmdk_open_desc_file(bs, flags, header.desc_offset << 9);
> > > + if (header.capacity == 0) {
> > > + int64_t desc_offset = le64_to_cpu(header.desc_offset);
> > > + if (desc_offset) {
> > > + return vmdk_open_desc_file(bs, flags, desc_offset << 9);
> > > + }
> > > }
> >
> > Splitting up the if condition wouldn't have been necessary, strictly
> > speaking. But I don't mind too much here.
>
> True. The reason I did it is because accessing header.desc_offset
> directly is a bad habit. Someone modifying the code might conclude it's
> safe to access directly when it actually only works for the limited
> cases of zero and non-zero.
It just looks a bit weird because you're still doing the same for
header.capacity and there's no real reason for treating the two fields
differently.
Kevin