vct.c trunk compilation failure

191919 191919 at gmail.com
Fri Mar 6 15:34:18 CET 2009


I found that perhaps it is a MacOS-specific problem (I am not sure).

In Leopard:

#if __DARWIN_UNIX03
#define WEXITSTATUS(x)  ((_W_INT(x) >> 8) & 0x000000ff)
#else /* !__DARWIN_UNIX03 */
#define WEXITSTATUS(x)  (_W_INT(x) >> 8)
#endif /* !__DARWIN_UNIX03 */

and _W_INT is defined as:

#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 */
...
#endif

(In Linux:

#define WEXITSTATUS(status)    __WEXITSTATUS(__WAIT_INT(status))

where __WAIT_INT is defined as:

#  if defined __GNUC__ && !defined __cplusplus
#   define
__WAIT_INT(status)                                                 \
  (__extension__ ({ union { __typeof(status) __in; int __i; }
__u;            \
                    __u.__in = (status); __u.__i; }))
#  else
#   define __WAIT_INT(status)   (*(int *) &(status))
#  endif
)

So the 250th line of vtc.c

       assert(WEXITSTATUS(system(av[1])) == 0);

will be expanded as

assert((*(int *)&(system(av[1]))) == 0);

and gcc reported that error.

Rewriting cmd_shell as follows solved the problem.

238 static void
239 cmd_shell(CMD_ARGS)
240 {
241     int sr;
242     (void)priv;
243     (void)cmd;
244
245     if (av == NULL)
246         return;
247     AN(av[1]);
248     AZ(av[2]);
249     vtc_dump(vl, 4, "shell", av[1]);
250
251     sr = system(av[1]);
252     assert(WEXITSTATUS(sr) == 0);
253 }


2009/3/6 Poul-Henning Kamp <phk at phk.freebsd.dk>

> In message <de894c690903052342l170472cclf94ad23d13fc694a at mail.gmail.com>,
> 19191
> 9 writes:
>
> >Making all in varnishtest
> >gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../.. -I../../include    -g -O2 -MT
> >vtc.o -MD -MP -MF .deps/vtc.Tpo -c -o vtc.o vtc.c
> >vtc.c: In function 'cmd_shell':
> >vtc.c:250: error: invalid lvalue in unary '&'
>
> critter phk> sed -n 250p vtc.c
>        assert(WEXITSTATUS(system(av[1])) == 0);
>
> I have no idea what the trouble is.
>
> As a first sanity-check, remove the vtc.c file and run "svn update"
> to make sure your local copy is not corrupt.
>
> --
> Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
> phk at FreeBSD.ORG         | TCP/IP since RFC 956
> FreeBSD committer       | BSD since 4.3-tahoe
> Never attribute to malice what can adequately be explained by incompetence.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20090306/eacf68d2/attachment-0002.html>


More information about the varnish-dev mailing list