|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v10 3/5] libxl: add pvusb API
On 10/12/15 12:05, George Dunlap wrote:
> From: Chunyan Liu <cyliu@xxxxxxxx>
>
> Add pvusb APIs, including:
> - attach/detach (create/destroy) virtual usb controller.
> - attach/detach usb device
> - list usb controller and usb devices
> - some other helper functions
>
> Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx>
> Signed-off-by: Simon Cao <caobosimon@xxxxxxxxx>
> Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxx>
Attached is a diff of v9 -> v10 for convenience.
One remaining question I had regarding this patch...
> +static int usbdev_get_all_interfaces(libxl__gc *gc, const char *busid,
> + char ***intfs, int *num)
> +{
> + DIR *dir;
> + char *buf;
> + int rc;
> +
> + *intfs = NULL;
> + *num = 0;
> +
> + buf = GCSPRINTF("%s:", busid);
> +
> + dir = opendir(SYSFS_USB_DEV);
> + if (!dir) {
> + LOGE(ERROR, "opendir failed: '%s'", SYSFS_USB_DEV);
> + return ERROR_FAIL;
> + }
> +
> + size_t need = offsetof(struct dirent, d_name) +
> + pathconf(SYSFS_USB_DEV, _PC_NAME_MAX) + 1;
> + struct dirent *de_buf = libxl__zalloc(gc, need);
Is this thing with manually calculating the size of the structure really
necessary? Could we not just declare "struct dirent de_buf" on the stack?
If it is necessary, it would be better to have it inside a function or
macro called "alloc_dirent" or something like that.
-George
Attachment:
pvusb-p3-v9-v10.diff _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |