All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] vmdk: byteswap VMDK4Header.desc_offset field
Date: Thu, 13 Jun 2013 10:06:43 +0800	[thread overview]
Message-ID: <20130613020643.GC4350@localhost.nay.redhat.com> (raw)
In-Reply-To: <20130610143223.GA4838@stefanha-thinkpad.redhat.com>

On Mon, 06/10 16:32, Stefan Hajnoczi wrote:
> 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: qemu-stable@nongnu.org
> > > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > 
> > 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.
> 

Not byteswapping header.capacity here, any reason?

-- 
Fam

  parent reply	other threads:[~2013-06-13  2:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-10  9:07 [Qemu-devel] [PATCH] vmdk: byteswap VMDK4Header.desc_offset field Stefan Hajnoczi
2013-06-10 14:04 ` Kevin Wolf
2013-06-10 14:32   ` Stefan Hajnoczi
2013-06-10 14:36     ` Kevin Wolf
2013-06-13  2:06     ` Fam Zheng [this message]
2013-06-13  8:33       ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130613020643.GC4350@localhost.nay.redhat.com \
    --to=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.