From 06243e7c3cd313e2d4d4b34fe0d2c3f35d9aee6d Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 7 Feb 2022 08:57:42 +0100 Subject: [PATCH] Avoid PRIx16 printf format on Windows Convert uint16_t to unsigned to avoid using PRIx16, which may not exist on Windows. PR #3011 --- app/src/usb/scrcpy_otg.c | 4 ++-- app/src/usb/usb.c | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/usb/scrcpy_otg.c b/app/src/usb/scrcpy_otg.c index d3a45679..1eaa2537 100644 --- a/app/src/usb/scrcpy_otg.c +++ b/app/src/usb/scrcpy_otg.c @@ -91,8 +91,8 @@ scrcpy_otg(struct scrcpy_options *options) { usb_device_initialized = true; - LOGI("USB device: %s (%04" PRIx16 ":%04" PRIx16 ") %s %s", - usb_device.serial, usb_device.vid, usb_device.pid, + LOGI("USB device: %s (%04x:%04x) %s %s", usb_device.serial, + (unsigned) usb_device.vid, (unsigned) usb_device.pid, usb_device.manufacturer, usb_device.product); ok = sc_usb_connect(&s->usb, usb_device.device, &cbs, NULL); diff --git a/app/src/usb/usb.c b/app/src/usb/usb.c index 799ada94..2d3fc3a6 100644 --- a/app/src/usb/usb.c +++ b/app/src/usb/usb.c @@ -40,8 +40,9 @@ sc_usb_read_device(libusb_device *device, struct sc_usb_device *out) { if (result < 0) { // Log at debug level because it is expected that some non-Android USB // devices present on the computer require special permissions - LOGD("Open USB device %04" PRIx16 ":%04" PRIx16 ": libusb error: %s", - desc.idVendor, desc.idProduct, libusb_strerror(result)); + LOGD("Open USB device %04x:%04x: libusb error: %s", + (unsigned) desc.idVendor, (unsigned) desc.idProduct, + libusb_strerror(result)); return false; } @@ -146,8 +147,10 @@ sc_usb_devices_log(enum sc_log_level level, struct sc_usb_device *devices, for (size_t i = 0; i < count; ++i) { struct sc_usb_device *d = &devices[i]; const char *selection = d->selected ? "-->" : " "; - LOG(level, " %s %-18s (%04" PRIx16 ":%04" PRIx16 ") %s %s", - selection, d->serial, d->vid, d->pid, d->manufacturer, d->product); + // Convert uint16_t to unsigned because PRIx16 may not exist on Windows + LOG(level, " %s %-18s (%04x:%04x) %s %s", + selection, d->serial, (unsigned) d->vid, (unsigned) d->pid, + d->manufacturer, d->product); } }