From d0f2c4c60263e29a87681433e696844401514194 Mon Sep 17 00:00:00 2001 From: malc Date: Sun, 7 Feb 2010 02:03:50 +0300 Subject: Do not use dprintf dprintf is already claimed by POSIX[1], and on at least one system is implemented as a macro [1] http://www.opengroup.org/onlinepubs/9699919799/functions/dprintf.html Signed-off-by: malc --- usb-linux.c | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'usb-linux.c') diff --git a/usb-linux.c b/usb-linux.c index 122cdbf..a9c15c6 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -68,9 +68,9 @@ typedef int USBScanFunc(void *opaque, int bus_num, int addr, int class_id, //#define DEBUG #ifdef DEBUG -#define dprintf printf +#define DPRINTF printf #else -#define dprintf(...) +#define DPRINTF(...) #endif #define USBDBG_DEVOPENED "husb: opened %s/devices\n" @@ -234,13 +234,13 @@ static void async_complete(void *opaque) return; } - dprintf("husb: async. reap urb failed errno %d\n", errno); + DPRINTF("husb: async. reap urb failed errno %d\n", errno); return; } p = aurb->packet; - dprintf("husb: async completed. aurb %p status %d alen %d\n", + DPRINTF("husb: async completed. aurb %p status %d alen %d\n", aurb, aurb->urb.status, aurb->urb.actual_length); if (p) { @@ -273,14 +273,14 @@ static void async_cancel(USBPacket *unused, void *opaque) AsyncURB *aurb = opaque; USBHostDevice *s = aurb->hdev; - dprintf("husb: async cancel. aurb %p\n", aurb); + DPRINTF("husb: async cancel. aurb %p\n", aurb); /* Mark it as dead (see async_complete above) */ aurb->packet = NULL; int r = ioctl(s->fd, USBDEVFS_DISCARDURB, aurb); if (r < 0) { - dprintf("husb: async. discard urb failed errno %d\n", errno); + DPRINTF("husb: async. discard urb failed errno %d\n", errno); } } @@ -293,7 +293,7 @@ static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration) if (configuration == 0) /* address state - ignore */ return 1; - dprintf("husb: claiming interfaces. config %d\n", configuration); + DPRINTF("husb: claiming interfaces. config %d\n", configuration); i = 0; dev_descr_len = dev->descr[0]; @@ -303,7 +303,7 @@ static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration) i += dev_descr_len; while (i < dev->descr_len) { - dprintf("husb: i is %d, descr_len is %d, dl %d, dt %d\n", i, dev->descr_len, + DPRINTF("husb: i is %d, descr_len is %d, dl %d, dt %d\n", i, dev->descr_len, dev->descr[i], dev->descr[i+1]); if (dev->descr[i+1] != USB_DT_CONFIG) { @@ -370,7 +370,7 @@ static int usb_host_release_interfaces(USBHostDevice *s) { int ret, i; - dprintf("husb: releasing interfaces\n"); + DPRINTF("husb: releasing interfaces\n"); for (i = 0; i < s->ninterfaces; i++) { ret = ioctl(s->fd, USBDEVFS_RELEASEINTERFACE, &i); @@ -387,7 +387,7 @@ static void usb_host_handle_reset(USBDevice *dev) { USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev); - dprintf("husb: reset device %u.%u\n", s->bus_num, s->addr); + DPRINTF("husb: reset device %u.%u\n", s->bus_num, s->addr); ioctl(s->fd, USBDEVFS_RESET); @@ -424,7 +424,7 @@ static int usb_host_handle_data(USBHostDevice *s, USBPacket *p) if (is_halted(s, p->devep)) { ret = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &urb->endpoint); if (ret < 0) { - dprintf("husb: failed to clear halt. ep 0x%x errno %d\n", + DPRINTF("husb: failed to clear halt. ep 0x%x errno %d\n", urb->endpoint, errno); return USB_RET_NAK; } @@ -449,10 +449,10 @@ static int usb_host_handle_data(USBHostDevice *s, USBPacket *p) ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb); - dprintf("husb: data submit. ep 0x%x len %u aurb %p\n", urb->endpoint, p->len, aurb); + DPRINTF("husb: data submit. ep 0x%x len %u aurb %p\n", urb->endpoint, p->len, aurb); if (ret < 0) { - dprintf("husb: submit failed. errno %d\n", errno); + DPRINTF("husb: submit failed. errno %d\n", errno); async_free(aurb); switch(errno) { @@ -478,7 +478,7 @@ static int ctrl_error(void) static int usb_host_set_address(USBHostDevice *s, int addr) { - dprintf("husb: ctrl set addr %u\n", addr); + DPRINTF("husb: ctrl set addr %u\n", addr); s->dev.addr = addr; return 0; } @@ -489,7 +489,7 @@ static int usb_host_set_config(USBHostDevice *s, int config) int ret = ioctl(s->fd, USBDEVFS_SETCONFIGURATION, &config); - dprintf("husb: ctrl set config %d ret %d errno %d\n", config, ret, errno); + DPRINTF("husb: ctrl set config %d ret %d errno %d\n", config, ret, errno); if (ret < 0) return ctrl_error(); @@ -507,7 +507,7 @@ static int usb_host_set_interface(USBHostDevice *s, int iface, int alt) si.altsetting = alt; ret = ioctl(s->fd, USBDEVFS_SETINTERFACE, &si); - dprintf("husb: ctrl set iface %d altset %d ret %d errno %d\n", + DPRINTF("husb: ctrl set iface %d altset %d ret %d errno %d\n", iface, alt, ret, errno); if (ret < 0) @@ -531,7 +531,7 @@ static int usb_host_handle_control(USBHostDevice *s, USBPacket *p) value = le16_to_cpu(s->ctrl.req.wValue); index = le16_to_cpu(s->ctrl.req.wIndex); - dprintf("husb: ctrl type 0x%x req 0x%x val 0x%x index %u len %u\n", + DPRINTF("husb: ctrl type 0x%x req 0x%x val 0x%x index %u len %u\n", s->ctrl.req.bRequestType, s->ctrl.req.bRequest, value, index, s->ctrl.len); @@ -580,10 +580,10 @@ static int usb_host_handle_control(USBHostDevice *s, USBPacket *p) ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb); - dprintf("husb: submit ctrl. len %u aurb %p\n", urb->buffer_length, aurb); + DPRINTF("husb: submit ctrl. len %u aurb %p\n", urb->buffer_length, aurb); if (ret < 0) { - dprintf("husb: submit failed. errno %d\n", errno); + DPRINTF("husb: submit failed. errno %d\n", errno); async_free(aurb); switch(errno) { @@ -786,7 +786,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s) if (descriptors[i + 1] != USB_DT_CONFIG || descriptors[i + 5] != configuration) { - dprintf("invalid descriptor data - configuration\n"); + DPRINTF("invalid descriptor data - configuration\n"); return 1; } i += descriptors[i]; @@ -847,7 +847,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s) type = USBDEVFS_URB_TYPE_INTERRUPT; break; default: - dprintf("usb_host: malformed endpoint type\n"); + DPRINTF("usb_host: malformed endpoint type\n"); type = USBDEVFS_URB_TYPE_BULK; } s->endp_table[(devep & 0xf) - 1].type = type; @@ -882,7 +882,7 @@ static int usb_host_open(USBHostDevice *dev, int bus_num, perror(buf); goto fail; } - dprintf("husb: opened %s\n", buf); + DPRINTF("husb: opened %s\n", buf); dev->bus_num = bus_num; dev->addr = addr; @@ -1313,7 +1313,7 @@ static int usb_host_scan(void *opaque, USBScanFunc *func) strcpy(devpath, USBDEVBUS_PATH); usb_fs_type = USB_FS_SYS; closedir(dir); - dprintf(USBDBG_DEVOPENED, USBSYSBUS_PATH); + DPRINTF(USBDBG_DEVOPENED, USBSYSBUS_PATH); goto found_devices; } f = fopen(USBPROCBUS_PATH "/devices", "r"); @@ -1322,7 +1322,7 @@ static int usb_host_scan(void *opaque, USBScanFunc *func) strcpy(devpath, USBPROCBUS_PATH); usb_fs_type = USB_FS_PROC; fclose(f); - dprintf(USBDBG_DEVOPENED, USBPROCBUS_PATH); + DPRINTF(USBDBG_DEVOPENED, USBPROCBUS_PATH); goto found_devices; } /* try additional methods if an access method hasn't been found yet */ @@ -1332,7 +1332,7 @@ static int usb_host_scan(void *opaque, USBScanFunc *func) strcpy(devpath, USBDEVBUS_PATH); usb_fs_type = USB_FS_DEV; fclose(f); - dprintf(USBDBG_DEVOPENED, USBDEVBUS_PATH); + DPRINTF(USBDBG_DEVOPENED, USBDEVBUS_PATH); goto found_devices; } found_devices: @@ -1399,7 +1399,7 @@ static int usb_host_auto_scan(void *opaque, int bus_num, int addr, if (s->fd != -1) return 0; - dprintf("husb: auto open: bus_num %d addr %d\n", bus_num, addr); + DPRINTF("husb: auto open: bus_num %d addr %d\n", bus_num, addr); usb_host_open(s, bus_num, addr, product_name); } -- cgit v1.1