This is the simple fix Daniel Veillard suggested last year: http://www.redhat.com/archives/libvir-list/20... --- tools/virsh.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 57ea618..c148f7b 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -8646,7 +8646,7 @@ editFile (vshControl *ctl, const char *filename) VIR_FREE(command); return -1; } - if (command_ret != WEXITSTATUS (0)) { + if (WEXITSTATUS(command_ret) != 0) { vshError(ctl, _("%s: command exited with non-zero status"), command); VIR_FREE(command);
On 09/15/2010 09:22 AM, Justin Clift wrote: > This is the simple fix Daniel Veillard suggested last year: > > http://www.redhat.com/archives/libvir-list/20... > --- > > tools/virsh.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/tools/virsh.c b/tools/virsh.c > index 57ea618..c148f7b 100644 > --- a/tools/virsh.c > +++ b/tools/virsh.c > @@ -8646,7 +8646,7 @@ editFile (vshControl *ctl, const char *filename) > VIR_FREE(command); > return -1; > } > - if (command_ret != WEXITSTATUS (0)) { > + if (WEXITSTATUS(command_ret) != 0) {ACK. By the way, what was the compilation failure?
On 09/16/2010 01:59 AM, Eric Blake wrote: > On 09/15/2010 09:22 AM, Justin Clift wrote: >> This is the simple fix Daniel Veillard suggested last year: >> >> http://www.redhat.com/archives/libvir-list/20... >> --- >> >> tools/virsh.c | 2 +- >> 1 files changed, 1 insertions(+), 1 deletions(-) >> >> diff --git a/tools/virsh.c b/tools/virsh.c >> index 57ea618..c148f7b 100644 >> --- a/tools/virsh.c >> +++ b/tools/virsh.c >> @@ -8646,7 +8646,7 @@ editFile (vshControl *ctl, const char *filename) >> VIR_FREE(command); >> return -1; >> } >> - if (command_ret != WEXITSTATUS (0)) { >> + if (WEXITSTATUS(command_ret) != 0) { > > ACK. By the way, what was the compilation failure?Thanks, pushed. The compilation failure was: virsh.c:8605: error: lvalue required as unary '&' operand Which seems weird, but this patch really did fix it. :) This is some of the other compilation mess before it, you have insight about: ************************************************************************* ranlib: file: .libs/libvirt.a(libvirt_driver_la-driver.o) has no symbols ranlib: file: .libs/libvirt.a(close-hook.o) has no symbols CC libvirt_qemu_la-libvirt-qemu.lo CCLD libvirt-qemu.la ld: warning: in ./libvirt_qemu.syms, file was built for unsupported file format which is not the architecture being linked (x86_64) CCLD libvirt_test.la /usr/bin/ranlib: file: .libs/libvirt_test.a(libvirt_util_la-bridge.o) has no symbols /usr/bin/ranlib: file: .libs/libvirt_test.a(libvirt_util_la-macvtap.o) has no symbols /usr/bin/ranlib: file: .libs/libvirt_test.a(libvirt_util_la-stats_linux.o) has no symbols /usr/bin/ranlib: file: .libs/libvirt_test.a(libvirt_driver_la-driver.o) has no symbols /usr/bin/ranlib: file: .libs/libvirt_test.a(close-hook.o) has no symbols ranlib: file: .libs/libvirt_test.a(libvirt_util_la-bridge.o) has no symbols ranlib: file: .libs/libvirt_test.a(libvirt_util_la-macvtap.o) has no symbols ranlib: file: .libs/libvirt_test.a(libvirt_util_la-stats_linux.o) has no symbols ranlib: file: .libs/libvirt_test.a(libvirt_driver_la-driver.o) has no symbols ranlib: file: .libs/libvirt_test.a(close-hook.o) has no symbols Making all in daemon make all-am make[3]: Nothing to be done for `all-am'. Making all in tools make all-am CC virsh-console.o CC virsh-virsh.o virsh.c: In function 'editFile': virsh.c:8605: error: lvalue required as unary '&' operand virsh.c: In function 'vshReadlineInit': virsh.c:10781: warning: assignment discards qualifiers from pointer target type make[3]: *** [virsh-virsh.o] Error 1 make[2]: *** [all] Error 2 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 $
[adding bug-gnulib; replies can drop libvir-list]>>> - if (command_ret != WEXITSTATUS (0)) { >>> + if (WEXITSTATUS(command_ret) != 0) { >> >> ACK. By the way, what was the compilation failure? > > Thanks, pushed. The compilation failure was: > > virsh.c:8605: error: lvalue required as unary '&' operand > > Which seems weird, but this patch really did fix it. :)Aha - the darwin <sys/wait.h> contains: #if defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE) #define _W_INT(i) (i) #else #define _W_INT(w) (*(int *)&(w)) /* convert union wait to int */ #define WCOREFLAG 0200 #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ ... #if __DARWIN_UNIX03 #define WEXITSTATUS(x) ((_W_INT(x) >> 8) & 0x000000ff) #else /* !__DARWIN_UNIX03 */ #define WEXITSTATUS(x) (_W_INT(x) >> 8) #endif /* !__DARWIN_UNIX03 */ ... union wait { int w_status; /* used in syscall */ /* * Terminated process status. */ struct { #if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN unsigned int w_Termsig:7, /* termination signal */ w_Coredump:1, /* core dump indicator */ w_Retcode:8, /* exit code if w_termsig==0 */ w_Filler:16; /* upper bits filler */ #endif #if __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN unsigned int w_Filler:16, /* upper bits filler */ w_Retcode:8, /* exit code if w_termsig==0 */ w_Coredump:1, /* core dump indicator */ w_Termsig:7; /* termination signal */ #endif } w_T; /* * Stopped process status. Returned * only for traced children unless requested * with the WUNTRACED option bit. */ struct { #if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN unsigned int w_Stopval:8, /* == W_STOPPED if stopped */ w_Stopsig:8, /* signal that stopped us */ w_Filler:16; /* upper bits filler */ #endif #if __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN unsigned int w_Filler:16, /* upper bits filler */ w_Stopsig:8, /* signal that stopped us */ w_Stopval:8; /* == W_STOPPED if stopped */ #endif } w_S; }; Obviously, the Darwin folks are (mistakenly) assuming that you would only ever use WEXITSTATUS with a 'union wait' lvalue; in which case, (*(int*)&(0)) is indeed invalid C (notice that they do the right thing if you request POSIX compliance with _POSIX_C_SOURCE, but since gnulib [rightfully] wants to expose and take advantage of system extensions, we can't define _POSIX_C_SOURCE). Since WEXITSTATUS should be usable on constants; it is a bug in their headers, and one that Gnulib should be able to work around.