From 698468f691af9b0441896fd461f7e68570859b6a Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 4 Nov 2020 22:09:14 +0100 Subject: [PATCH 01/22] common/snprintf.c: quiesce -Wimplicit-fallthrough=3 warnings about fall-through in switch --- common/snprintf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/snprintf.c b/common/snprintf.c index f7dd982951..a3f151535a 100644 --- a/common/snprintf.c +++ b/common/snprintf.c @@ -338,6 +338,8 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args) break; case 'X': flags |= DP_F_UP; + /* Falls through to 'x' for rest of processing */ + /* FALLTHRU */ case 'x': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) @@ -364,6 +366,8 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args) break; case 'E': flags |= DP_F_UP; + /* Falls through to 'e' for rest of processing */ + /* FALLTHRU */ case 'e': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); @@ -372,6 +376,8 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args) break; case 'G': flags |= DP_F_UP; + /* Falls through to 'g' for rest of processing */ + /* FALLTHRU */ case 'g': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); From d33b1da29b495b4ccb925075b3085642d2b7fd31 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 6 Nov 2020 05:38:24 +0100 Subject: [PATCH 02/22] common/snprintf.c: replace FALLTHRU comments with more portable and reliable goto jumps --- common/snprintf.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/snprintf.c b/common/snprintf.c index a3f151535a..0caa04ed25 100644 --- a/common/snprintf.c +++ b/common/snprintf.c @@ -338,9 +338,9 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args) break; case 'X': flags |= DP_F_UP; - /* Falls through to 'x' for rest of processing */ - /* FALLTHRU */ + goto fallthrough_case_x; case 'x': + fallthrough_case_x: flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) #ifdef C89PLUS @@ -366,9 +366,9 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args) break; case 'E': flags |= DP_F_UP; - /* Falls through to 'e' for rest of processing */ - /* FALLTHRU */ + goto fallthrough_case_e; case 'e': + fallthrough_case_e: if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else @@ -376,9 +376,9 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args) break; case 'G': flags |= DP_F_UP; - /* Falls through to 'g' for rest of processing */ - /* FALLTHRU */ + goto fallthrough_case_g; case 'g': + fallthrough_case_g: if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else From 17be6d07b37ac9ff9be3a133e6c2ab5ccc9dad93 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 4 Nov 2020 22:10:28 +0100 Subject: [PATCH 03/22] clients/upsc.c: quiesce -Wimplicit-fallthrough=3 warnings about fall-through in switch --- clients/upsc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/clients/upsc.c b/clients/upsc.c index a3e605d7ef..b7fe11c828 100644 --- a/clients/upsc.c +++ b/clients/upsc.c @@ -218,6 +218,7 @@ int main(int argc, char **argv) { case 'L': verbose = 1; + /* FALLTHRU */ case 'l': varlist = 1; break; From 08f51c4957fa09998e41e6ed442be91e736a7438 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 6 Nov 2020 05:38:04 +0100 Subject: [PATCH 04/22] clients/upsc.c: replace FALLTHRU comments with more portable and reliable goto jumps --- clients/upsc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clients/upsc.c b/clients/upsc.c index b7fe11c828..f71ab888b2 100644 --- a/clients/upsc.c +++ b/clients/upsc.c @@ -218,8 +218,9 @@ int main(int argc, char **argv) { case 'L': verbose = 1; - /* FALLTHRU */ + goto fallthrough_case_l; case 'l': + fallthrough_case_l: varlist = 1; break; case 'c': From d5dca88f24b5efc215294f98501746d0bb02acb7 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 5 Nov 2020 18:26:17 +0100 Subject: [PATCH 05/22] drivers/usbhid-ups.c: quiesce -Wimplicit-fallthrough=3 warnings about fall-through in switch --- drivers/usbhid-ups.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index ea198c4db9..fd74d39bf2 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -764,6 +764,7 @@ void upsdrv_updateinfo(void) { case -EBUSY: /* Device or resource busy */ upslog_with_errno(LOG_CRIT, "Got disconnected by another driver"); + /* FALLTHRU */ case -EPERM: /* Operation not permitted */ case -ENODEV: /* No such device */ case -EACCES: /* Permission denied */ @@ -1273,6 +1274,7 @@ static bool_t hid_ups_walk(walkmode_t mode) { case -EBUSY: /* Device or resource busy */ upslog_with_errno(LOG_CRIT, "Got disconnected by another driver"); + /* FALLTHRU */ case -EPERM: /* Operation not permitted */ case -ENODEV: /* No such device */ case -EACCES: /* Permission denied */ From d135d62214f636241193042179c59f40c9b2eab1 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 6 Nov 2020 05:39:50 +0100 Subject: [PATCH 06/22] drivers/usbhid-ups.c: replace FALLTHRU comments with more portable and reliable goto jumps --- drivers/usbhid-ups.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index fd74d39bf2..ecb773ff09 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -764,13 +764,14 @@ void upsdrv_updateinfo(void) { case -EBUSY: /* Device or resource busy */ upslog_with_errno(LOG_CRIT, "Got disconnected by another driver"); - /* FALLTHRU */ + goto fallthrough_reconnect; case -EPERM: /* Operation not permitted */ case -ENODEV: /* No such device */ case -EACCES: /* Permission denied */ case -EIO: /* I/O error */ case -ENXIO: /* No such device or address */ case -ENOENT: /* No such file or directory */ + fallthrough_reconnect: /* Uh oh, got to reconnect! */ hd = NULL; return; @@ -1274,13 +1275,14 @@ static bool_t hid_ups_walk(walkmode_t mode) { case -EBUSY: /* Device or resource busy */ upslog_with_errno(LOG_CRIT, "Got disconnected by another driver"); - /* FALLTHRU */ + goto fallthrough_reconnect; case -EPERM: /* Operation not permitted */ case -ENODEV: /* No such device */ case -EACCES: /* Permission denied */ case -EIO: /* I/O error */ case -ENXIO: /* No such device or address */ case -ENOENT: /* No such file or directory */ + fallthrough_reconnect: /* Uh oh, got to reconnect! */ hd = NULL; return FALSE; From fe6737497d258f858ab1cfb4e17bdbec008a1693 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 5 Nov 2020 18:39:18 +0100 Subject: [PATCH 07/22] drivers/mge-hid.c: quiesce -Wimplicit-fallthrough=3 warnings about fall-through in switch --- drivers/mge-hid.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index e0d26eb706..ed39b6f862 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -576,6 +576,7 @@ static const char *eaton_check_pegasus_fun(double value) /* Only consider non European models */ if (country_code != COUNTRY_EUROPE) break; + /* FALLTHRU */ default: return NULL; } @@ -604,6 +605,7 @@ static const char *pegasus_yes_no_info_fun(double value) /* Only consider non European models */ if (country_code != COUNTRY_EUROPE) break; + /* FALLTHRU */ default: return NULL; } @@ -622,6 +624,7 @@ static double pegasus_yes_no_info_nuf(const char *value) /* Only consider non European models */ if (country_code != COUNTRY_EUROPE) break; + /* FALLTHRU */ default: return 0; } @@ -731,6 +734,7 @@ static const char *nominal_output_voltage_fun(double value) case 240: if ((mge_type & 0xFF00) >= MGE_DEFAULT) break; + /* FALLTHRU */ default: return NULL; } From 9f1366191db581d5c1ba8cbba316a6226299a116 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 6 Nov 2020 05:39:30 +0100 Subject: [PATCH 08/22] drivers/mge-hid.c: replace FALLTHRU comments with same returns as the next default case --- drivers/mge-hid.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index ed39b6f862..b55f674d21 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -576,7 +576,7 @@ static const char *eaton_check_pegasus_fun(double value) /* Only consider non European models */ if (country_code != COUNTRY_EUROPE) break; - /* FALLTHRU */ + return NULL; default: return NULL; } @@ -605,7 +605,7 @@ static const char *pegasus_yes_no_info_fun(double value) /* Only consider non European models */ if (country_code != COUNTRY_EUROPE) break; - /* FALLTHRU */ + return NULL; default: return NULL; } @@ -624,7 +624,7 @@ static double pegasus_yes_no_info_nuf(const char *value) /* Only consider non European models */ if (country_code != COUNTRY_EUROPE) break; - /* FALLTHRU */ + return 0; default: return 0; } @@ -734,7 +734,7 @@ static const char *nominal_output_voltage_fun(double value) case 240: if ((mge_type & 0xFF00) >= MGE_DEFAULT) break; - /* FALLTHRU */ + return NULL; default: return NULL; } From 7d4e9aaa8460575e9ac45b190f4b905d5ae82eb5 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 6 Nov 2020 20:36:08 +0100 Subject: [PATCH 09/22] drivers/nutdrv_qx.c: qx_command(): explicit fall through the switch --- drivers/nutdrv_qx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/nutdrv_qx.c b/drivers/nutdrv_qx.c index bb526608c7..702a2e7a06 100644 --- a/drivers/nutdrv_qx.c +++ b/drivers/nutdrv_qx.c @@ -2136,16 +2136,20 @@ static int qx_command(const char *cmd, char *buf, size_t buflen) break; } #ifdef ETIME + goto fallthrough_case_ETIME; case -ETIME: /* Timer expired */ + fallthrough_case_ETIME: #endif /* ETIME */ if (usb_reset(udev) == 0) { upsdebugx(1, "Device reset handled"); } + goto fallthrough_case_reconnect; case -ENODEV: /* No such device */ case -EACCES: /* Permission denied */ - case -EIO: /* I/O error */ + case -EIO: /* I/O error */ case -ENXIO: /* No such device or address */ case -ENOENT: /* No such file or directory */ + fallthrough_case_reconnect: /* Uh oh, got to reconnect! */ usb->close(udev); udev = NULL; From fef152484df6bd7ce169cc42009bf1de0141e844 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 6 Nov 2020 18:32:39 +0100 Subject: [PATCH 10/22] tools/nut-scanner/nut-scanner.c: explicit fall through to displaying help --- tools/nut-scanner/nut-scanner.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/nut-scanner/nut-scanner.c b/tools/nut-scanner/nut-scanner.c index eace2be063..711cb58062 100644 --- a/tools/nut-scanner/nut-scanner.c +++ b/tools/nut-scanner/nut-scanner.c @@ -446,6 +446,7 @@ int main(int argc, char *argv[]) exit(EXIT_SUCCESS); case '?': ret_code = ERR_BAD_OPTION; + goto display_help; /* Fall through to usage and error exit */ case 'h': default: From 25ff6c21b697c530fab8c6d2c02a6f6e8ffb6bd9 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 8 Nov 2020 03:11:24 +0100 Subject: [PATCH 11/22] drivers/tripplite_usb.c: avoid implicit switch fall-through --- drivers/tripplite_usb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tripplite_usb.c b/drivers/tripplite_usb.c index 7d205583ac..10ac74e576 100644 --- a/drivers/tripplite_usb.c +++ b/drivers/tripplite_usb.c @@ -174,6 +174,8 @@ static int subdriver_match_func(USBDevice_t *hd, void *privdata) if (getval("productid")) { return 1; } + return 0; + case NOT_SUPPORTED: default: return 0; @@ -1227,7 +1229,9 @@ void upsdrv_updateinfo(void) status_set("RB"); break; } /* else fall through: */ + goto fallthrough_case_default; default: + fallthrough_case_default: upslogx(LOG_ERR, "Unknown value for s[1]: 0x%02x", s_value[1]); dstate_datastale(); break; From a1eac30bfdb24c545d98072a7740ae8c0cd6f33e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 8 Nov 2020 03:23:00 +0100 Subject: [PATCH 12/22] drivers/riello_usb.c: avoid implicit switch fall-through --- drivers/riello_usb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index cb343a3a4a..d8ff166ddf 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -358,16 +358,20 @@ int riello_command(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) break; } #ifdef ETIME + goto fallthrough_case_etime; case -ETIME: /* Timer expired */ + fallthrough_case_etime: #endif if (usb_reset(udev) == 0) { upsdebugx(1, "Device reset handled"); } + goto fallthrough_case_reconnect; case -ENODEV: /* No such device */ case -EACCES: /* Permission denied */ case -EIO: /* I/O error */ case -ENXIO: /* No such device or address */ case -ENOENT: /* No such file or directory */ + fallthrough_case_reconnect: /* Uh oh, got to reconnect! */ usb->close(udev); udev = NULL; From 42342b10c2439b440fbac69710a8a49cb6fb30bc Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 8 Nov 2020 03:23:17 +0100 Subject: [PATCH 13/22] drivers/blazer_usb.c: avoid implicit switch fall-through --- drivers/blazer_usb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/blazer_usb.c b/drivers/blazer_usb.c index 68d7b8674d..02c8c1e99c 100644 --- a/drivers/blazer_usb.c +++ b/drivers/blazer_usb.c @@ -435,16 +435,20 @@ int blazer_command(const char *cmd, char *buf, size_t buflen) break; } #ifdef ETIME + goto fallthrough_case_etime; case -ETIME: /* Timer expired */ + fallthrough_case_etime: #endif if (usb_reset(udev) == 0) { upsdebugx(1, "Device reset handled"); } + goto fallthrough_case_reconnect; case -ENODEV: /* No such device */ case -EACCES: /* Permission denied */ case -EIO: /* I/O error */ case -ENXIO: /* No such device or address */ case -ENOENT: /* No such file or directory */ + fallthrough_case_reconnect: /* Uh oh, got to reconnect! */ usb->close(udev); udev = NULL; From 51aca19d2d61c712fe8feaf038e8ca1881de3063 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 8 Nov 2020 17:54:30 +0100 Subject: [PATCH 14/22] drivers/nutdrv_atcl_usb.c: avoid implicit switch fall-through --- drivers/nutdrv_atcl_usb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/nutdrv_atcl_usb.c b/drivers/nutdrv_atcl_usb.c index 94bf8beced..b2796560d7 100644 --- a/drivers/nutdrv_atcl_usb.c +++ b/drivers/nutdrv_atcl_usb.c @@ -446,8 +446,12 @@ void upsdrv_updateinfo(void) case 2: upsdebugx(2, "reply[0] = 0x%02x -> LB", reply[0]); status_set("LB"); + goto fallthrough_LB_means_OB; + /* Note: the comment below existed for years, so wondering + * if this device CAN set independently LB and OB? */ /* fall through */ case 1: + fallthrough_LB_means_OB: upsdebugx(2, "reply[0] = 0x%02x -> OB", reply[0]); status_set("OB"); break; From 4dc1d07b8c08d3859d8808fb4f1c4fe0625c1b9c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 10 Nov 2020 17:36:57 +0100 Subject: [PATCH 15/22] server/upsd.c: avoid implicit switch fall-through --- server/upsd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/server/upsd.c b/server/upsd.c index 2d47461b9c..d8662b38e3 100644 --- a/server/upsd.c +++ b/server/upsd.c @@ -1173,6 +1173,7 @@ int main(int argc, char **argv) fatalx(EXIT_FAILURE, "Specifying a listening addresses with '-i
' and '-p '\n" "is deprecated. Use 'LISTEN
[]' in 'upsd.conf' instead.\n" "See 'man 8 upsd.conf' for more information."); + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ case 'q': nut_log_level++; break; From a610d85d331a29cb88ee43e195cd4901305f3430 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 10 Nov 2020 17:37:38 +0100 Subject: [PATCH 16/22] server/upsd.c: add blank lines for readability of opts processing switch --- server/upsd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/upsd.c b/server/upsd.c index d8662b38e3..9317ad3586 100644 --- a/server/upsd.c +++ b/server/upsd.c @@ -1168,21 +1168,26 @@ int main(int argc, char **argv) case 'h': help(progname); break; + case 'p': case 'i': fatalx(EXIT_FAILURE, "Specifying a listening addresses with '-i
' and '-p '\n" "is deprecated. Use 'LISTEN
[]' in 'upsd.conf' instead.\n" "See 'man 8 upsd.conf' for more information."); exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ + case 'q': nut_log_level++; break; + case 'r': chroot_path = optarg; break; + case 'u': user = optarg; break; + case 'V': /* do nothing - we already printed the banner */ exit(EXIT_SUCCESS); From 5cb501adb860c136a99ca0edc7e62f4ca116e674 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 10 Nov 2020 17:35:36 +0100 Subject: [PATCH 17/22] drivers/blazer_usb.c: avoid implicit switch fall-through --- drivers/blazer_usb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/blazer_usb.c b/drivers/blazer_usb.c index 02c8c1e99c..450be0eae5 100644 --- a/drivers/blazer_usb.c +++ b/drivers/blazer_usb.c @@ -425,9 +425,11 @@ int blazer_command(const char *cmd, char *buf, size_t buflen) { case -EBUSY: /* Device or resource busy */ fatal_with_errno(EXIT_FAILURE, "Got disconnected by another driver"); + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ case -EPERM: /* Operation not permitted */ fatal_with_errno(EXIT_FAILURE, "Permissions problem"); + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ case -EPIPE: /* Broken pipe */ if (usb_clear_halt(udev, 0x81) == 0) { From 68200e405ce4a7889dc63052f0909e87b431a881 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 10 Nov 2020 17:34:54 +0100 Subject: [PATCH 18/22] drivers/usbhid-ups.c: avoid implicit switch fall-through --- drivers/usbhid-ups.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index ecb773ff09..309ec4e7b5 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -929,8 +929,10 @@ void upsdrv_initups(void) break; case -1: fatal_with_errno(EXIT_FAILURE, "HIDNewRegexMatcher()"); + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ default: fatalx(EXIT_FAILURE, "invalid regular expression: %s", regex_array[ret]); + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ } /* link the matchers */ From 29fe0f429acfdf640f759b2a679f8cb58c73780c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 10 Nov 2020 17:32:59 +0100 Subject: [PATCH 19/22] drivers/nutdrv_qx.c: avoid implicit switch fall-through --- drivers/nutdrv_qx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nutdrv_qx.c b/drivers/nutdrv_qx.c index 702a2e7a06..ac64e849aa 100644 --- a/drivers/nutdrv_qx.c +++ b/drivers/nutdrv_qx.c @@ -2126,9 +2126,11 @@ static int qx_command(const char *cmd, char *buf, size_t buflen) { case -EBUSY: /* Device or resource busy */ fatal_with_errno(EXIT_FAILURE, "Got disconnected by another driver"); + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ case -EPERM: /* Operation not permitted */ fatal_with_errno(EXIT_FAILURE, "Permissions problem"); + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ case -EPIPE: /* Broken pipe */ if (usb_clear_halt(udev, 0x81) == 0) { From 2f7db8f2da8044a9844179bee3dc2444978b6bd5 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 10 Nov 2020 17:31:40 +0100 Subject: [PATCH 20/22] clients/upscmd.c: avoid implicit switch fall-through --- clients/upscmd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/clients/upscmd.c b/clients/upscmd.c index f8e237d429..2ceff13273 100644 --- a/clients/upscmd.c +++ b/clients/upscmd.c @@ -257,6 +257,7 @@ int main(int argc, char **argv) case 'V': fatalx(EXIT_SUCCESS, "Network UPS Tools upscmd %s", UPS_VERSION); + exit(EXIT_SUCCESS); /* Should not get here in practice, but compiler is afraid we can fall through */ case 'h': default: From 3440806a05f47aae159d6a167d8bf434b13783be Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 10 Nov 2020 17:29:57 +0100 Subject: [PATCH 21/22] clients/upsc.c: avoid implicit switch fall-through --- clients/upsc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/clients/upsc.c b/clients/upsc.c index f71ab888b2..beb49bdd54 100644 --- a/clients/upsc.c +++ b/clients/upsc.c @@ -229,6 +229,7 @@ int main(int argc, char **argv) case 'V': fatalx(EXIT_SUCCESS, "Network UPS Tools upscmd %s", UPS_VERSION); + exit(EXIT_SUCCESS); /* Should not get here in practice, but compiler is afraid we can fall through */ case 'h': default: From bed499ece12edc4f4c32f987f1f0e5ea5328e808 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 10 Nov 2020 17:27:24 +0100 Subject: [PATCH 22/22] drivers/riello_usb.c: avoid implicit switch fall-through --- drivers/riello_usb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index d8ff166ddf..5634809a83 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -348,9 +348,11 @@ int riello_command(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) { case -EBUSY: /* Device or resource busy */ fatal_with_errno(EXIT_FAILURE, "Got disconnected by another driver"); + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ case -EPERM: /* Operation not permitted */ fatal_with_errno(EXIT_FAILURE, "Permissions problem"); + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ case -EPIPE: /* Broken pipe */ if (usb_clear_halt(udev, 0x81) == 0) { @@ -379,7 +381,7 @@ int riello_command(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) case -ETIMEDOUT: /* Connection timed out */ upsdebugx (3, "riello_command err: Resource temporarily unavailable"); - + break; case -EOVERFLOW: /* Value too large for defined data type */ #ifdef EPROTO @@ -390,7 +392,6 @@ int riello_command(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) break; } - return ret; }