From: Fam Zheng <famz@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, Jeff Cody <jcody@redhat.com>
Cc: kwolf@redhat.com, qemu-block@nongnu.org, sw@weilnetz.de,
qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com,
pbonzini@redhat.com, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 1/8] util: Add UUID API
Date: Tue, 9 Aug 2016 10:34:17 +0800 [thread overview]
Message-ID: <20160809023417.GC16125@al.usersys.redhat.com> (raw)
In-Reply-To: <20160808195125.GK24882@localhost.localdomain>
On Mon, 08/08 15:51, Jeff Cody wrote:
> > > +typedef unsigned char QemuUUID[16];
> >
> > I'm afraid this typedef is problematic. Consider:
> >
> > void use_uuid(QemuUUID uuid)
> > {
> > printf("sizeof(uuid) %zd\n", sizeof(uuid));
> > uuid[0]++;
> > }
> >
> > QemuUUID is obviously a typedef name, so a reasonable reader may assume
> > (1) sizeof(uuid) is the size of the uuid, and (2) since uuid is passed
> > by value, the increment is not visible outside the function. Both
> > assumptions are wrong, because array arguments degenerate into pointers.
> >
> > I recommend to wrap it in a struct.
> >
>
> If we are going for a semantic drop-in replacement for libuuid's uuid_t,
> Fam's typedef here is consistent with libuuid:
>
> typedef unsigned char uuid_t[16];
>
> (Not to say that prohibits changing it, just pointing out there is value in
> mimicking libuuid's interfaces).
I am not 100% comforatble with libuuid way, so yes, it was for consistency. But
Markus' point is great, let's change it to the better way anyway, since it's
not a hard requirement to mimic libuuid.
Fam
next prev parent reply other threads:[~2016-08-09 2:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-08 6:09 [Qemu-devel] [PATCH v2 0/8] UUID clean ups for 2.8 Fam Zheng
2016-08-08 6:09 ` [Qemu-devel] [PATCH v2 1/8] util: Add UUID API Fam Zheng
2016-08-08 11:07 ` Markus Armbruster
2016-08-08 19:51 ` Jeff Cody
2016-08-09 2:34 ` Fam Zheng [this message]
2016-08-08 6:09 ` [Qemu-devel] [PATCH v2 2/8] tests: Add uuid tests Fam Zheng
2016-08-08 8:58 ` Daniel P. Berrange
2016-08-08 6:09 ` [Qemu-devel] [PATCH v2 3/8] vhdx: Use QEMU UUID API Fam Zheng
2016-08-08 20:45 ` Jeff Cody
2016-08-08 6:09 ` [Qemu-devel] [PATCH v2 4/8] vdi: " Fam Zheng
2016-08-08 6:09 ` [Qemu-devel] [PATCH v2 5/8] vpc: " Fam Zheng
2016-08-08 20:49 ` Jeff Cody
2016-08-09 2:31 ` Fam Zheng
2016-08-08 6:09 ` [Qemu-devel] [PATCH v2 6/8] crypto: Switch to " Fam Zheng
2016-08-08 9:00 ` Daniel P. Berrange
2016-08-08 6:09 ` [Qemu-devel] [PATCH v2 7/8] tests: No longer dependent on CONFIG_UUID Fam Zheng
2016-08-08 6:09 ` [Qemu-devel] [PATCH v2 8/8] configure: Remove detection code for UUID Fam Zheng
2016-08-08 20:52 ` Jeff Cody
2016-08-09 2:31 ` Fam Zheng
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=20160809023417.GC16125@al.usersys.redhat.com \
--to=famz@redhat.com \
--cc=armbru@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.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.