Subject: Re: pkg/33979: sysutils/xentools20 fails to compile with gcc 4
To: None <bouyer@NetBSD.org, gnats-admin@netbsd.org,>
From: John R. Shannon <john@johnrshannon.com>
List: pkgsrc-bugs
Date: 07/11/2006 20:10:05
The following reply was made to PR pkg/33979; it has been noted by GNATS.

From: "John R. Shannon" <john@johnrshannon.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/33979: sysutils/xentools20 fails to compile with gcc 4
Date: Tue, 11 Jul 2006 14:08:51 -0600

 This is a multi-part message in MIME format.
 --------------060104090007020300010201
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 gnats-admin@netbsd.org wrote:
 > Thank you very much for your problem report.
 > It has the internal identification `pkg/33979'.
 > The individual assigned to look at your
 > report is: pkg-manager. 
 > 
 >> Category:       pkg
 >> Responsible:    pkg-manager
 >> Synopsis:       sysutils/xentools20 fails to compile with gcc 4
 >> Arrival-Date:   Tue Jul 11 16:25:00 +0000 2006
 > 
 
 I missed two updated patches in my report (attached).
 
 
 -- 
 John R. Shannon, CISSP
 jshannon@dsci-usa.com
 john.r.shannon@us.army.mil
 shannonjr@NetBSD.org
 (208)522-4506
 
 --------------060104090007020300010201
 Content-Type: text/plain;
  name="patch-ac"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="patch-ac"
 
 $NetBSD$
 
 --- python/xen/lowlevel/xu/xu.c.orig	2005-08-03 17:57:58.000000000 -0600
 +++ python/xen/lowlevel/xu/xu.c
 @@ -15,7 +15,9 @@
  #include <sys/socket.h>
  #include <sys/mman.h>
  #include <sys/poll.h>
 +#ifndef __NetBSD__
  #include <sys/sysmacros.h>
 +#endif
  #include <netinet/in.h>
  #include <fcntl.h>
  #include <unistd.h>
 @@ -25,7 +27,11 @@
  
  #include <xen/xen.h>
  #include <xen/io/domain_controller.h>
 +#ifdef __NetBSD__
 +#include <xen/NetBSD/xenio.h>
 +#else
  #include <xen/linux/privcmd.h>
 +#endif
  
  #define XENPKG "xen.lowlevel.xu"
  
 @@ -35,6 +41,9 @@
  #endif
  
  /* NB. The following should be kept in sync with the kernel's evtchn driver. */
 +#ifdef __NetBSD__
 +#define EVTCHN_DEV_NAME  "/dev/xenevt"
 +#else
  #define EVTCHN_DEV_NAME  "/dev/xen/evtchn"
  #define EVTCHN_DEV_MAJOR 10
  #define EVTCHN_DEV_MINOR 201
 @@ -45,6 +54,7 @@
  #define EVTCHN_BIND   _IO('E', 2)
  /* EVTCHN_UNBIND: Unbind from the specified event-channel port. */
  #define EVTCHN_UNBIND _IO('E', 3)
 +#endif
  
  /* Size of a machine page frame. */
  #define PAGE_SIZE 4096
 @@ -130,7 +140,11 @@ static PyObject *xu_notifier_bind(PyObje
      if ( !PyArg_ParseTuple(args, "i", &idx) )
          return NULL;
  
 +#ifdef __NetBSD__
 +    if ( ioctl(xun->evtchn_fd, EVTCHN_BIND, &idx) != 0 )
 +#else
      if ( ioctl(xun->evtchn_fd, EVTCHN_BIND, idx) != 0 )
 +#endif
          return PyErr_SetFromErrno(PyExc_IOError);
  
      Py_INCREF(Py_None);
 @@ -145,7 +159,11 @@ static PyObject *xu_notifier_unbind(PyOb
      if ( !PyArg_ParseTuple(args, "i", &idx) )
          return NULL;
  
 +#ifdef __NetBSD__
 +    if ( ioctl(xun->evtchn_fd, EVTCHN_UNBIND, &idx) != 0 )
 +#else
      if ( ioctl(xun->evtchn_fd, EVTCHN_UNBIND, idx) != 0 )
 +#endif
          return PyErr_SetFromErrno(PyExc_IOError);
  
      Py_INCREF(Py_None);
 @@ -192,13 +210,16 @@ staticforward PyTypeObject xu_notifier_t
  static PyObject *xu_notifier_new(PyObject *self, PyObject *args)
  {
      xu_notifier_object *xun;
 +#ifndef __NetBSD__
      struct stat st;
 +#endif
  
      if ( !PyArg_ParseTuple(args, "") )
          return NULL;
  
      xun = PyObject_New(xu_notifier_object, &xu_notifier_type);
  
 +#ifndef __NetBSD__
      /* Make sure any existing device file links to correct device. */
      if ( (lstat(EVTCHN_DEV_NAME, &st) != 0) ||
           !S_ISCHR(st.st_mode) ||
 @@ -206,14 +227,17 @@ static PyObject *xu_notifier_new(PyObjec
          (void)unlink(EVTCHN_DEV_NAME);
  
   reopen:
 +#endif
      xun->evtchn_fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR);
      if ( xun->evtchn_fd == -1 )
      {
 +#ifndef __NetBSD__
          if ( (errno == ENOENT) &&
               ((mkdir("/dev/xen", 0755) == 0) || (errno == EEXIST)) &&
               (mknod(EVTCHN_DEV_NAME, S_IFCHR|0600, 
                      makedev(EVTCHN_DEV_MAJOR,EVTCHN_DEV_MINOR)) == 0) )
              goto reopen;
 +#endif
          PyObject_Del((PyObject *)xun);
          return PyErr_SetFromErrno(PyExc_IOError);
      }
 @@ -508,7 +532,7 @@ static PyObject *xu_message_get_payload(
          return dict;
      }
  
 -    return PyString_FromStringAndSize(xum->msg.msg, xum->msg.length);
 +    return PyString_FromStringAndSize((char *)xum->msg.msg, xum->msg.length);
  }
  
  static PyObject *xu_message_get_header(PyObject *self, PyObject *args)
 @@ -1110,7 +1134,8 @@ static PyObject *xu_port_new(PyObject *s
           * The control-interface event channel for DOM0 is already set up.
           * We use an ioctl to discover the port at our end of the channel.
           */
 -        port1 = ioctl(xup->xc_handle, IOCTL_PRIVCMD_INITDOMAIN_EVTCHN, NULL);
 +        if (ioctl(xup->xc_handle, IOCTL_PRIVCMD_INITDOMAIN_EVTCHN, &port1))
 +            port1 = -1;
          port2 = -1; /* We don't need the remote end of the DOM0 link. */
          if ( port1 < 0 )
          {
 
 --------------060104090007020300010201
 Content-Type: text/plain;
  name="patch-ae"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="patch-ae"
 
 $NetBSD$
 
 --- xfrd/xfrd.c.orig	2005-08-03 17:57:58.000000000 -0600
 +++ xfrd/xfrd.c
 @@ -481,9 +481,9 @@ int xfr_hello(Conn *conn){
          err = -EINVAL;
          goto exit;
      }
 -    err = intof(sxpr_childN(sxpr, 0, ONONE), &hello_major);
 +    err = intof(sxpr_childN(sxpr, 0, ONONE), (int *)&hello_major);
      if(err) goto exit;
 -    err = intof(sxpr_childN(sxpr, 1, ONONE), &hello_minor);
 +    err = intof(sxpr_childN(sxpr, 1, ONONE), (int *)&hello_minor);
      if(err) goto exit;
      if(hello_major != major || hello_minor != minor){
          eprintf("> Wanted protocol version %d.%d, got %d.%d",
 @@ -646,7 +646,7 @@ int xfr_send_state(XfrState *state, Conn
          if(!err) err = errcode;
      } else if(sxpr_elementp(sxpr, oxfr_xfr_ok)){
          // Ok - get the new domain id.
 -        err = intof(sxpr_childN(sxpr, 0, ONONE), &state->vmid_new);
 +        err = intof(sxpr_childN(sxpr, 0, ONONE), (int *)&state->vmid_new);
          xfr_error(peer, err);
      } else {
          // Anything else is invalid. But it may be too late.
 @@ -917,7 +917,7 @@ int xfrd_service(Args *args, int peersoc
          int n = 0;
  
          dprintf("> xfr.migrate\n");
 -        err = intof(sxpr_childN(sxpr, n++, ONONE), &state->vmid);
 +        err = intof(sxpr_childN(sxpr, n++, ONONE), (int *)&state->vmid);
          if(err) goto exit;
          err = stringof(sxpr_childN(sxpr, n++, ONONE), &state->vmconfig);
          if(err) goto exit;
 @@ -939,7 +939,7 @@ int xfrd_service(Args *args, int peersoc
          int n = 0;
  
          dprintf("> xfr.save\n");
 -        err = intof(sxpr_childN(sxpr, n++, ONONE), &state->vmid);
 +        err = intof(sxpr_childN(sxpr, n++, ONONE), (int *)&state->vmid);
          if(err) goto exit;
          err = stringof(sxpr_childN(sxpr, n++, ONONE), &state->vmconfig);
          if(err) goto exit;
 @@ -965,7 +965,7 @@ int xfrd_service(Args *args, int peersoc
          int n = 0;
  
          dprintf("> xfr.xfr\n");
 -        err = intof(sxpr_childN(sxpr, n++, ONONE), &state->vmid);
 +        err = intof(sxpr_childN(sxpr, n++, ONONE), (int *)&state->vmid);
          if(err) goto exit;
          err = xfr_recv(args, state, conn);
  
 @@ -1230,8 +1230,8 @@ int main(int argc, char *argv[]){
  
  #ifndef DEBUG
      freopen(LOGFILE, "w+", stdout);
 -    fclose(stderr);
 -    stderr = stdout;
 +    close(2);
 +    dup2(1,2);
  #endif
      dprintf(">\n");
      set_defaults(args);
 
 --------------060104090007020300010201--