diff --git a/clients/upsc.c b/clients/upsc.c index a3e605d7ef..beb49bdd54 100644 --- a/clients/upsc.c +++ b/clients/upsc.c @@ -218,7 +218,9 @@ int main(int argc, char **argv) { case 'L': verbose = 1; + goto fallthrough_case_l; case 'l': + fallthrough_case_l: varlist = 1; break; case 'c': @@ -227,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: 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: diff --git a/common/snprintf.c b/common/snprintf.c index f7dd982951..0caa04ed25 100644 --- a/common/snprintf.c +++ b/common/snprintf.c @@ -338,7 +338,9 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args) break; case 'X': flags |= DP_F_UP; + goto fallthrough_case_x; case 'x': + fallthrough_case_x: flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) #ifdef C89PLUS @@ -364,7 +366,9 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args) break; case 'E': flags |= DP_F_UP; + goto fallthrough_case_e; case 'e': + fallthrough_case_e: if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else @@ -372,7 +376,9 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args) break; case 'G': flags |= DP_F_UP; + goto fallthrough_case_g; case 'g': + fallthrough_case_g: if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else diff --git a/drivers/blazer_usb.c b/drivers/blazer_usb.c index 68d7b8674d..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) { @@ -435,16 +437,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; diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index e0d26eb706..b55f674d21 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; + return NULL; 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; + return NULL; 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; + return 0; 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; + return NULL; default: return NULL; } 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; diff --git a/drivers/nutdrv_qx.c b/drivers/nutdrv_qx.c index bb526608c7..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) { @@ -2136,16 +2138,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; diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index cb343a3a4a..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) { @@ -358,16 +360,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; @@ -375,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 @@ -386,7 +392,6 @@ int riello_command(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) break; } - return ret; } 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; diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index ea198c4db9..309ec4e7b5 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -764,12 +764,14 @@ void upsdrv_updateinfo(void) { case -EBUSY: /* Device or resource busy */ upslog_with_errno(LOG_CRIT, "Got disconnected by another driver"); + 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; @@ -927,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 */ @@ -1273,12 +1277,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"); + 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; diff --git a/server/upsd.c b/server/upsd.c index 2d47461b9c..9317ad3586 100644 --- a/server/upsd.c +++ b/server/upsd.c @@ -1168,20 +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