Re: [libvirt] [PATCH] bhyve: fix build with gcc48
Eric Blake wrote: On 05/23/2015 02:45 PM, Martin Kletzander wrote: On Sat, May 23, 2015 at 08:05:23PM +0300, Roman Bogorodskiy wrote: Build with gcc 4.8 fails with: Arguably a bug in gcc; but since we can work around it without too much pain, we should. bhyve/bhyve_monitor.c: In function 'bhyveMonitorIO': bhyveMonitorIO(int watch, int kq, int events ATTRIBUTE_UNUSED, void *opaque) { -const struct timespec zerowait = {}; +const struct timespec zerowait = { 0, 0 }; Would also be sufficient to do 'zerowait = { 0 };' - any C compiler that warns about an initializer of { 0 } is broken, because that is THE idiomatic way to zero-initialize anything (scalar or structure) according to C99. You need to set at least minimum one field, all others will be set to 0. But this is of course very right thing to do. ACK, structures shouldn't be initialized this way. Go ahead and push as you have it, though, with two members, since we know struct timespec has (at least) two members. Pushed, thanks! Roman Bogorodskiy pgpPA5xOzLb6o.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] bhyve: fix build with gcc48
On 05/23/2015 02:45 PM, Martin Kletzander wrote: On Sat, May 23, 2015 at 08:05:23PM +0300, Roman Bogorodskiy wrote: Build with gcc 4.8 fails with: Arguably a bug in gcc; but since we can work around it without too much pain, we should. bhyve/bhyve_monitor.c: In function 'bhyveMonitorIO': bhyveMonitorIO(int watch, int kq, int events ATTRIBUTE_UNUSED, void *opaque) { -const struct timespec zerowait = {}; +const struct timespec zerowait = { 0, 0 }; Would also be sufficient to do 'zerowait = { 0 };' - any C compiler that warns about an initializer of { 0 } is broken, because that is THE idiomatic way to zero-initialize anything (scalar or structure) according to C99. You need to set at least minimum one field, all others will be set to 0. But this is of course very right thing to do. ACK, structures shouldn't be initialized this way. Go ahead and push as you have it, though, with two members, since we know struct timespec has (at least) two members. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] bhyve: fix build with gcc48
On Sat, May 23, 2015 at 08:05:23PM +0300, Roman Bogorodskiy wrote: Build with gcc 4.8 fails with: bhyve/bhyve_monitor.c: In function 'bhyveMonitorIO': bhyve/bhyve_monitor.c:51:18: error: missing initializer for field 'tv_sec' of 'const struct timespec' [-Werror=missing-field-initializers] const struct timespec zerowait = {}; Explicitly initialize zerowait to fix the build. --- src/bhyve/bhyve_monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bhyve/bhyve_monitor.c b/src/bhyve/bhyve_monitor.c index 7f19c6e..1316720 100644 --- a/src/bhyve/bhyve_monitor.c +++ b/src/bhyve/bhyve_monitor.c @@ -48,7 +48,7 @@ struct _bhyveMonitor { static void bhyveMonitorIO(int watch, int kq, int events ATTRIBUTE_UNUSED, void *opaque) { -const struct timespec zerowait = {}; +const struct timespec zerowait = { 0, 0 }; You need to set at least minimum one field, all others will be set to 0. But this is of course very right thing to do. ACK, structures shouldn't be initialized this way. bhyveMonitorPtr mon = opaque; struct kevent kev; int rc, status; -- 2.3.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list signature.asc Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] bhyve: fix build with gcc48
Build with gcc 4.8 fails with: bhyve/bhyve_monitor.c: In function 'bhyveMonitorIO': bhyve/bhyve_monitor.c:51:18: error: missing initializer for field 'tv_sec' of 'const struct timespec' [-Werror=missing-field-initializers] const struct timespec zerowait = {}; Explicitly initialize zerowait to fix the build. --- src/bhyve/bhyve_monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bhyve/bhyve_monitor.c b/src/bhyve/bhyve_monitor.c index 7f19c6e..1316720 100644 --- a/src/bhyve/bhyve_monitor.c +++ b/src/bhyve/bhyve_monitor.c @@ -48,7 +48,7 @@ struct _bhyveMonitor { static void bhyveMonitorIO(int watch, int kq, int events ATTRIBUTE_UNUSED, void *opaque) { -const struct timespec zerowait = {}; +const struct timespec zerowait = { 0, 0 }; bhyveMonitorPtr mon = opaque; struct kevent kev; int rc, status; -- 2.3.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list