From 30622eefa888d83552c01361709e5fdcb274f447 Mon Sep 17 00:00:00 2001 From: Ryan Drake Date: Thu, 6 Oct 2016 15:19:00 -0700 Subject: [PATCH 1/5] Fix control may reach end of non-void function error --- cli/x52_cli.c | 2 ++ test/x52_test_led.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/cli/x52_cli.c b/cli/x52_cli.c index 8103e7e..6231c0e 100644 --- a/cli/x52_cli.c +++ b/cli/x52_cli.c @@ -326,6 +326,8 @@ static int do_help(const struct command_handler *cmd) printf("\nWARNING: raw command may damage your device\n\n"); } + + return 0; } int main(int argc, char **argv) diff --git a/test/x52_test_led.c b/test/x52_test_led.c index 6781293..8202242 100644 --- a/test/x52_test_led.c +++ b/test/x52_test_led.c @@ -75,4 +75,6 @@ int test_blink_n_shift(void) TEST_BLINK_OR_SHIFT(blink); TEST_BLINK_OR_SHIFT(shift); + + return 0; } From 15b8abf3c632737dd20aa6acd1cb31a001911630 Mon Sep 17 00:00:00 2001 From: Ryan Drake Date: Thu, 6 Oct 2016 15:28:18 -0700 Subject: [PATCH 2/5] Fix warnings about unused variables --- cli/x52_cli.c | 1 - test/x52_test_mfd.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/cli/x52_cli.c b/cli/x52_cli.c index 6231c0e..bfdf5b3 100644 --- a/cli/x52_cli.c +++ b/cli/x52_cli.c @@ -333,7 +333,6 @@ static int do_help(const struct command_handler *cmd) int main(int argc, char **argv) { libx52_device *x52; - int command; struct string_map result; const struct command_handler *cmd; int i; diff --git a/test/x52_test_mfd.c b/test/x52_test_mfd.c index 1cc7f6f..ace2bed 100644 --- a/test/x52_test_mfd.c +++ b/test/x52_test_mfd.c @@ -78,8 +78,6 @@ int test_mfd_text(void) int test_mfd_display(void) { int i; - int j; - int rc; char str[16]; print_banner("MFD display"); From 95e933e27cd4627d7ff042b89b730314e068e3ed Mon Sep 17 00:00:00 2001 From: Ryan Drake Date: Thu, 6 Oct 2016 15:43:32 -0700 Subject: [PATCH 3/5] Fix warnings about uninitialized variables --- libx52/x52_control.c | 6 +++--- libx52/x52_date_time.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libx52/x52_control.c b/libx52/x52_control.c index d6f0773..6e735b0 100644 --- a/libx52/x52_control.c +++ b/libx52/x52_control.c @@ -22,7 +22,7 @@ int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value) { int j; - int rc; + int rc = LIBUSB_ERROR_OTHER; /* Allow retry in case of failure */ for (j = 0; j < 3; j++) { @@ -110,7 +110,7 @@ static int libx52_write_date(libx52_device *x52) static int libx52_write_time(libx52_device *x52, libx52_clock_id clock) { - uint16_t value; + uint16_t value = 0; uint16_t index; int offset; int negative; @@ -168,7 +168,7 @@ int libx52_update(libx52_device *x52) unsigned int i; uint32_t update_mask; uint16_t value; - int rc; + int rc = LIBUSB_ERROR_OTHER; /* Save the update mask */ update_mask = x52->update_mask; diff --git a/libx52/x52_date_time.c b/libx52/x52_date_time.c index b90cb2b..a8fc690 100644 --- a/libx52/x52_date_time.c +++ b/libx52/x52_date_time.c @@ -39,7 +39,7 @@ int libx52_set_clock(libx52_device *x52, time_t time, int local) /* timezone from time.h presents the offset in seconds west of GMT. * Negate and divide by 60 to get the offset in minutes east of GMT. */ - local_tz = -timezone / 60; + local_tz = (int)(-timezone / 60); } else { timeval = *gmtime(&time); /* No offset from GMT */ From aaab4c6b1dab6876e1ea6118b8156e68bc773d1d Mon Sep 17 00:00:00 2001 From: Ryan Drake Date: Fri, 7 Oct 2016 19:18:55 -0700 Subject: [PATCH 4/5] Conditionalize use of ELIBACC on __linux__ as it is linux-specific --- libx52/x52_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libx52/x52_core.c b/libx52/x52_core.c index 2b334fe..42d3d3e 100644 --- a/libx52/x52_core.c +++ b/libx52/x52_core.c @@ -55,7 +55,11 @@ libx52_device* libx52_init(void) rc = libusb_init(&(x52_dev->ctx)); if (rc) { +#if defined(__linux__) errno = ELIBACC; +#else + errno = ENOENT; +#endif goto err_recovery; } libusb_set_debug(x52_dev->ctx, 3); From ae97d58bd5039f7b15cceae7ba2567d5b5728549 Mon Sep 17 00:00:00 2001 From: Ryan Drake Date: Sat, 8 Oct 2016 09:22:17 -0700 Subject: [PATCH 5/5] Use zero instead of LIBUSB_ERROR_OTHER as default value for rc --- libx52/x52_control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libx52/x52_control.c b/libx52/x52_control.c index 6e735b0..e1f4578 100644 --- a/libx52/x52_control.c +++ b/libx52/x52_control.c @@ -22,7 +22,7 @@ int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value) { int j; - int rc = LIBUSB_ERROR_OTHER; + int rc = 0; /* Allow retry in case of failure */ for (j = 0; j < 3; j++) { @@ -168,7 +168,7 @@ int libx52_update(libx52_device *x52) unsigned int i; uint32_t update_mask; uint16_t value; - int rc = LIBUSB_ERROR_OTHER; + int rc = 0; /* Save the update mask */ update_mask = x52->update_mask;