On 08/30/2010 12:38 PM, Jes Sorensen wrote:
On 08/30/10 18:56, malc wrote:
On Mon, 30 Aug 2010, Anthony Liguori wrote:
On 08/30/2010 10:35 AM, jes.soren...@redhat.com wrote:
From: Jes Sorensen<jes.soren...@redhat.com>
diff --git a/linux-aio.c b/linux-aio.c
index 68f4b3d..3240996 100644
--- a/linux-aio.c
+++ b/linux-aio.c
@@ -118,7 +118,7 @@ static void qemu_laio_completion_cb(void *opaque)
struct io_event events[MAX_EVENTS];
uint64_t val;
ssize_t ret;
- struct timespec ts = { 0 };
+ struct timespec ts = { 0, 0 };
I don't like these. What's wrong with { } or { 0 }? Implicit zeroing of
members is a critical feature of structure initialization so if there is
something wrong with this, it's important to know why because otherwise we've
got a massive amount of broken code.
Apart from gcc complaining about fields not being initialized explicitly
there's nothing wrong with it.
Sure it compiles, it works, but it's not pretty. What does it mean if
you write = { 1 } in the above case?
Initialize first field to 1 and all remaining fields to 0.
That's precisely what it means and there's a lot of code written today
that relies on this behavior. No doubt, c99 initializers are an
improvement but { 0 } still looks better to me than {}.
However, I wouldn't object to replacing {0} with {}. Avoiding {} in
favor of memset is crazy though.
Regards,
Anthony Liguori