From: Anthony Liguori <anthony@codemonkey.ws>
To: Stefan Weil <weil@mail.berlios.de>
Cc: Kevin Wolf <kwolf@redhat.com>, QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] block/vdi: Fix wrong size in conditionally used memset, memcmp
Date: Fri, 04 Feb 2011 14:19:19 -0600 [thread overview]
Message-ID: <4D4C5F47.8060700@codemonkey.ws> (raw)
In-Reply-To: <1296849676-7429-1-git-send-email-weil@mail.berlios.de>
On 02/04/2011 02:01 PM, Stefan Weil wrote:
> Error report from cppcheck:
> block/vdi.c:122: error: Using sizeof for array given as function argument returns the size of pointer.
> block/vdi.c:128: error: Using sizeof for array given as function argument returns the size of pointer.
>
> Fix both by setting the correct size.
>
> The buggy code is only used when QEMU is build without uuid support.
> The bug is not critical, so there is no urgent need to apply it to
> old versions of QEMU.
>
> Cc: Kevin Wolf<kwolf@redhat.com>
> Signed-off-by: Stefan Weil<weil@mail.berlios.de>
>
Huh, I wouldn't have thought this was the case. I almost feel that
doing a #define UUID_SIZE may be better because sizeof(typeof(v)) !=
sizeof(v) is weird even by C standards.
Regards,
Anthony Liguori
> ---
> block/vdi.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/vdi.c b/block/vdi.c
> index 83b9c04..083266e 100644
> --- a/block/vdi.c
> +++ b/block/vdi.c
> @@ -119,13 +119,13 @@ void uuid_unparse(const uuid_t uu, char *out);
> #if !defined(CONFIG_UUID)
> void uuid_generate(uuid_t out)
> {
> - memset(out, 0, sizeof(out));
> + memset(out, 0, sizeof(uuid_t));
> }
>
> int uuid_is_null(const uuid_t uu)
> {
> uuid_t null_uuid = { 0 };
> - return memcmp(uu, null_uuid, sizeof(uu)) == 0;
> + return memcmp(uu, null_uuid, sizeof(uuid_t)) == 0;
> }
>
> void uuid_unparse(const uuid_t uu, char *out)
>
next prev parent reply other threads:[~2011-02-04 20:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-04 20:01 [Qemu-devel] [PATCH] block/vdi: Fix wrong size in conditionally used memset, memcmp Stefan Weil
2011-02-04 20:19 ` Anthony Liguori [this message]
2011-02-07 9:12 ` Kevin Wolf
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=4D4C5F47.8060700@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=weil@mail.berlios.de \
/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.