Avoid PRIx16 printf format on Windows

Convert uint16_t to unsigned to avoid using PRIx16, which may not exist
on Windows.

PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011>
This commit is contained in:
Romain Vimont 2022-02-07 08:57:42 +01:00
parent b9b2879789
commit 06243e7c3c
2 changed files with 9 additions and 6 deletions

View file

@ -91,8 +91,8 @@ scrcpy_otg(struct scrcpy_options *options) {
usb_device_initialized = true; usb_device_initialized = true;
LOGI("USB device: %s (%04" PRIx16 ":%04" PRIx16 ") %s %s", LOGI("USB device: %s (%04x:%04x) %s %s", usb_device.serial,
usb_device.serial, usb_device.vid, usb_device.pid, (unsigned) usb_device.vid, (unsigned) usb_device.pid,
usb_device.manufacturer, usb_device.product); usb_device.manufacturer, usb_device.product);
ok = sc_usb_connect(&s->usb, usb_device.device, &cbs, NULL); ok = sc_usb_connect(&s->usb, usb_device.device, &cbs, NULL);

View file

@ -40,8 +40,9 @@ sc_usb_read_device(libusb_device *device, struct sc_usb_device *out) {
if (result < 0) { if (result < 0) {
// Log at debug level because it is expected that some non-Android USB // Log at debug level because it is expected that some non-Android USB
// devices present on the computer require special permissions // devices present on the computer require special permissions
LOGD("Open USB device %04" PRIx16 ":%04" PRIx16 ": libusb error: %s", LOGD("Open USB device %04x:%04x: libusb error: %s",
desc.idVendor, desc.idProduct, libusb_strerror(result)); (unsigned) desc.idVendor, (unsigned) desc.idProduct,
libusb_strerror(result));
return false; 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) { for (size_t i = 0; i < count; ++i) {
struct sc_usb_device *d = &devices[i]; struct sc_usb_device *d = &devices[i];
const char *selection = d->selected ? "-->" : " "; const char *selection = d->selected ? "-->" : " ";
LOG(level, " %s %-18s (%04" PRIx16 ":%04" PRIx16 ") %s %s", // Convert uint16_t to unsigned because PRIx16 may not exist on Windows
selection, d->serial, d->vid, d->pid, d->manufacturer, d->product); LOG(level, " %s %-18s (%04x:%04x) %s %s",
selection, d->serial, (unsigned) d->vid, (unsigned) d->pid,
d->manufacturer, d->product);
} }
} }