From b0731f05fb3ddcbea19c88d628e1b539966c21fd Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Sat, 7 Nov 2015 22:33:03 +0100 Subject: [PATCH] Fix some format string warnings from clang Building with clang gives some format string warnings as below, fix them by using the correct format string when printing out the values. .../libam7xxx/src/am7xxx.c:804:38: warning: format specifies type 'unsigned char' but the argument has type 'int' [-Wformat] (*dev)->desc->configuration, current_configuration); ^~~~~~~~~~~~~~~~~~~~~ .../libam7xxx/src/am7xxx.c:65:85: note: expanded from macro 'debug' #define debug(ctx, ...) log_message(ctx, AM7XXX_LOG_DEBUG, __func__, 0, __VA_ARGS__) ^ 1 warning generated. [...] .../libam7xxx/examples/am7xxx-modeswitch.c:75:5: warning: format specifies type 'unsigned char' but the argument has type 'int' [-Wformat] AM7XXX_STORAGE_CONFIGURATION); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ .../libam7xxx/examples/am7xxx-modeswitch.c:26:38: note: expanded from macro 'AM7XXX_STORAGE_CONFIGURATION' #define AM7XXX_STORAGE_CONFIGURATION 1 ^ .../libam7xxx/examples/am7xxx-modeswitch.c:87:4: warning: format specifies type 'unsigned char' but the argument has type 'int' [-Wformat] AM7XXX_STORAGE_INTERFACE); ^~~~~~~~~~~~~~~~~~~~~~~~ .../libam7xxx/examples/am7xxx-modeswitch.c:27:38: note: expanded from macro 'AM7XXX_STORAGE_INTERFACE' #define AM7XXX_STORAGE_INTERFACE 0 ^ .../libam7xxx/examples/am7xxx-modeswitch.c:104:4: warning: format specifies type 'unsigned char' but the argument has type 'int' [-Wformat] AM7XXX_STORAGE_CONFIGURATION, current_configuration); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ .../libam7xxx/examples/am7xxx-modeswitch.c:26:38: note: expanded from macro 'AM7XXX_STORAGE_CONFIGURATION' #define AM7XXX_STORAGE_CONFIGURATION 1 ^ .../libam7xxx/examples/am7xxx-modeswitch.c:104:34: warning: format specifies type 'unsigned char' but the argument has type 'int' [-Wformat] AM7XXX_STORAGE_CONFIGURATION, current_configuration); ^~~~~~~~~~~~~~~~~~~~~ 4 warnings generated. --- examples/am7xxx-modeswitch.c | 6 +++--- src/am7xxx.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/am7xxx-modeswitch.c b/examples/am7xxx-modeswitch.c index 62db796..793130e 100644 --- a/examples/am7xxx-modeswitch.c +++ b/examples/am7xxx-modeswitch.c @@ -71,7 +71,7 @@ int main(void) if (ret < 0) { fprintf(stderr, "libusb_set_configuration failed: %s\n", libusb_error_name(ret)); - fprintf(stderr, "Cannot set configuration %hhu\n", + fprintf(stderr, "Cannot set configuration %d\n", AM7XXX_STORAGE_CONFIGURATION); goto out_libusb_close; } @@ -83,7 +83,7 @@ int main(void) if (ret < 0) { fprintf(stderr, "libusb_claim_interface failed: %s\n", libusb_error_name(ret)); - fprintf(stderr, "Cannot claim interface %hhu\n", + fprintf(stderr, "Cannot claim interface %d\n", AM7XXX_STORAGE_INTERFACE); goto out_libusb_close; } @@ -100,7 +100,7 @@ int main(void) } if (current_configuration != AM7XXX_STORAGE_CONFIGURATION) { - fprintf(stderr, "libusb configuration changed (expected: %hhu, current: %hhu\n", + fprintf(stderr, "libusb configuration changed (expected: %d, current: %d\n", AM7XXX_STORAGE_CONFIGURATION, current_configuration); ret = -EINVAL; goto out_libusb_release_interface; diff --git a/src/am7xxx.c b/src/am7xxx.c index b988267..76df87d 100644 --- a/src/am7xxx.c +++ b/src/am7xxx.c @@ -800,7 +800,7 @@ static int open_device(am7xxx_context *ctx, } if (current_configuration != (*dev)->desc->configuration) { - debug(ctx, "libusb configuration changed (expected: %hhu, current: %hhu\n", + debug(ctx, "libusb configuration changed (expected: %hhu, current: %d\n", (*dev)->desc->configuration, current_configuration); ret = -EINVAL; goto out_libusb_release_interface; -- 2.1.4