endpoint->extra = extra;
if (!extra) {
endpoint->extralen = 0;
- return -ENOMEM;
+ return LIBUSB_ERROR_NO_MEM;
}
memcpy(extra, begin, len);
sizeof(struct libusb_interface_descriptor) *
(interface->num_altsetting + 1));
if (!altsetting) {
- r = -ENOMEM;
+ r = LIBUSB_ERROR_NO_MEM;
goto err;
}
interface->altsetting = altsetting;
usbi_parse_descriptor(buffer, "bb", &header);
if (header.bLength < 2) {
usbi_err("invalid descriptor of length %d", header.bLength);
- r = -EINVAL;
+ r = LIBUSB_ERROR_IO;
goto err;
}
if (len) {
ifp->extra = malloc(len);
if (!ifp->extra) {
- r = -ENOMEM;
+ r = LIBUSB_ERROR_NO_MEM;
goto err;
}
memcpy((unsigned char *) ifp->extra, begin, len);
if (ifp->bNumEndpoints > USB_MAXENDPOINTS) {
usbi_err("too many endpoints (%d)", ifp->bNumEndpoints);
- r = -EOVERFLOW;
+ r = LIBUSB_ERROR_IO;
goto err;
}
endpoint = malloc(tmp);
ifp->endpoint = endpoint;
if (!endpoint) {
- r = -ENOMEM;
+ r = LIBUSB_ERROR_NO_MEM;
goto err;
}
if (header.bLength > size) {
usbi_err("ran out of descriptors parsing");
- r = -ENOSPC;
+ r = LIBUSB_ERROR_IO;
goto err;
}
if (config->bNumInterfaces > USB_MAXINTERFACES) {
usbi_err("too many interfaces (%d)", config->bNumInterfaces);
- return -EOVERFLOW;
+ return LIBUSB_ERROR_IO;
}
tmp = config->bNumInterfaces * sizeof(struct libusb_interface);
interface = malloc(tmp);
config->interface = interface;
if (!config->interface)
- return -ENOMEM;
+ return LIBUSB_ERROR_NO_MEM;
memset(interface, 0, tmp);
buffer += config->bLength;
if ((header.bLength > size) ||
(header.bLength < DESC_HEADER_LENGTH)) {
usbi_err("invalid descriptor length of %d", header.bLength);
- r = -EIO;
+ r = LIBUSB_ERROR_IO;
goto err;
}
if (!config->extralen) {
config->extra = malloc(len);
if (!config->extra) {
- r = -ENOMEM;
+ r = LIBUSB_ERROR_NO_MEM;
goto err;
}
busnum, devaddr, session_id);
dev = usbi_alloc_device(session_id);
if (!dev) {
- r = -ENOMEM;
+ r = LIBUSB_ERROR_NO_MEM;
goto out;
}
need_unref = 1;
discdevs = discovered_devs_append(*_discdevs, dev);
if (!discdevs)
- r = -ENOMEM;
+ r = LIBUSB_ERROR_NO_MEM;
else
*_discdevs = discdevs;
"Permission denied.\n"
"libusb requires write access to USB device nodes.\n",
dpriv->nodepath);
- return -EACCES;
+ return LIBUSB_ERROR_ACCESS;
} else {
usbi_err("open failed, code %d errno %d", hpriv->fd, errno);
- return -EIO;
+ return LIBUSB_ERROR_IO;
}
}
}
if (urb_idx == 0) {
usbi_err("could not locate urb!");
- return -EIO;
+ return LIBUSB_ERROR_NOT_FOUND;
}
usbi_dbg("handling completion status %d of iso urb %d/%d", urb->status,
return handle_control_completion(itransfer, urb);
default:
usbi_err("unrecognised endpoint type %x", transfer->type);
- return -EINVAL;
+ return LIBUSB_ERROR_OTHER;
}
}