Re: [PATCH] virsh: change wexitstatus order to allow compilation on mac osx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[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.

--
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]