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

Re: [Xen-devel] [PATCH v12 02/17] libxl: refactor disk addition to take a helper



Roger Pau Monne writes ("[PATCH v12 02/17] libxl: refactor disk addition to 
take a helper"):
> Change libxl__device_disk_add to no longer take a xs transaction and
> instead pass a helper for the local attach case that's used to get the
> free vdev.
...
> +static int device_disk_add(libxl__gc *gc, uint32_t domid,
> +                           libxl_device_disk *disk,
> +                           void *get_vdev(libxl__gc *, void *,
> +                                          xs_transaction_t),
> +                           void *get_vdev_user)

get_vdev needs to return a char*.

The point of the void* is that if another caller of device_disk_add
needs to use this feature, the type of get_vdev_user may need to be
something different for this user; this is why passthrough pointers
like this need to be void*s.

But another user of this feature will have to have their get_vdev
return a char*, since that's how the value is used.

So:
  +static int device_disk_add(libxl__gc *gc, uint32_t domid,
  +                           libxl_device_disk *disk,
  +                           char *get_vdev(libxl__gc *, void *,
  +                                          xs_transaction_t),
  +                           void *get_vdev_user)


> +                                    (void *) libxl__alloc_vdev,

This is not permitted.  The (malicious) compiler might choose to
misoptimise the program as a result.  You must not cast a function
from one type to another.  The actual type of the function must be the
same where it is defined and called.

So either libxl__alloc_vdev needs to change its type to match, or you
need to make a wrapper function which contains the upcast from void*
to const char*.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.