All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: stefanha@redhat.com, w.bumiller@proxmox.com, eblake@redhat.com,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] vvfat: Fix volume name assertion
Date: Wed, 27 Apr 2016 16:02:50 +0200	[thread overview]
Message-ID: <5720C68A.4090605@redhat.com> (raw)
In-Reply-To: <1461759883-8589-2-git-send-email-kwolf@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 1904 bytes --]

On 27.04.2016 14:24, Kevin Wolf wrote:
> Commit d5941dd made the volume name configurable, but it didn't consider
> that the rw code compares the volume name string to assert that the
> first directory entry is the volume name. This made vvfat crash in rw
> mode.
> 
> This fixes the assertion to compare with the configured volume name
> instead of a literal string.
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/vvfat.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/block/vvfat.c b/block/vvfat.c
> index 6b85314..f9d4e82 100644
> --- a/block/vvfat.c
> +++ b/block/vvfat.c
> @@ -2288,7 +2288,11 @@ DLOG(fprintf(stderr, "commit_direntries for %s, parent_mapping_index %d\n", mapp
>  		s->sectors_per_cluster);
>  	if (ret)
>  	    return ret;
> -	assert(!strncmp(s->directory.pointer, "QEMU", 4));
> +
> +        /* The first directory entry on the filesystem is the volume name */
> +        direntry_t *first_direntry = s->directory.pointer;

I am afraid this does not conform to the QEMU coding style. Declaration
of variables ("first_direntry" in this case) needs to be done at the
beginning of the block, and this block starts with the for () loop.

Fortunately, the vvfat code provides plenty of examples on how to do
this right. I strongly support choosing the well-established style of
creating a non-conditional block just around these three lines so that
the declaration does not need to be moved. See the declaration of the
direntry_t pointer "entry" in init_directories(), for instance.

> +        assert(!memcmp(first_direntry->name, s->volume_label, 11));

The code mentioned above also teaches us that we can use
sizeof(first_direntry->name) instead of 11. However, I'll leave that up
to you.

Max

> +
>  	current_dir_index += factor;
>      }
>  
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2016-04-27 14:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27 12:24 [Qemu-devel] [PATCH 0/2] vvfat: Fix regressions introduced in 2.4 Kevin Wolf
2016-04-27 12:24 ` [Qemu-devel] [PATCH 1/2] vvfat: Fix volume name assertion Kevin Wolf
2016-04-27 14:02   ` Max Reitz [this message]
2016-04-27 12:24 ` [Qemu-devel] [PATCH 2/2] vvfat: Fix default volume label Kevin Wolf
2016-04-27 14:06   ` Max Reitz

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=5720C68A.4090605@redhat.com \
    --to=mreitz@redhat.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=w.bumiller@proxmox.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.