Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
698468f
common/snprintf.c: quiesce -Wimplicit-fallthrough=3 warnings about fa…
jimklimov Nov 4, 2020
d33b1da
common/snprintf.c: replace FALLTHRU comments with more portable and r…
jimklimov Nov 6, 2020
17be6d0
clients/upsc.c: quiesce -Wimplicit-fallthrough=3 warnings about fall-…
jimklimov Nov 4, 2020
08f51c4
clients/upsc.c: replace FALLTHRU comments with more portable and reli…
jimklimov Nov 6, 2020
d5dca88
drivers/usbhid-ups.c: quiesce -Wimplicit-fallthrough=3 warnings about…
jimklimov Nov 5, 2020
d135d62
drivers/usbhid-ups.c: replace FALLTHRU comments with more portable an…
jimklimov Nov 6, 2020
fe67374
drivers/mge-hid.c: quiesce -Wimplicit-fallthrough=3 warnings about fa…
jimklimov Nov 5, 2020
9f13661
drivers/mge-hid.c: replace FALLTHRU comments with same returns as the…
jimklimov Nov 6, 2020
7d4e9aa
drivers/nutdrv_qx.c: qx_command(): explicit fall through the switch
jimklimov Nov 6, 2020
fef1524
tools/nut-scanner/nut-scanner.c: explicit fall through to displaying …
jimklimov Nov 6, 2020
25ff6c2
drivers/tripplite_usb.c: avoid implicit switch fall-through
jimklimov Nov 8, 2020
a1eac30
drivers/riello_usb.c: avoid implicit switch fall-through
jimklimov Nov 8, 2020
42342b1
drivers/blazer_usb.c: avoid implicit switch fall-through
jimklimov Nov 8, 2020
51aca19
drivers/nutdrv_atcl_usb.c: avoid implicit switch fall-through
jimklimov Nov 8, 2020
4dc1d07
server/upsd.c: avoid implicit switch fall-through
jimklimov Nov 10, 2020
a610d85
server/upsd.c: add blank lines for readability of opts processing switch
jimklimov Nov 10, 2020
5cb501a
drivers/blazer_usb.c: avoid implicit switch fall-through
jimklimov Nov 10, 2020
68200e4
drivers/usbhid-ups.c: avoid implicit switch fall-through
jimklimov Nov 10, 2020
29fe0f4
drivers/nutdrv_qx.c: avoid implicit switch fall-through
jimklimov Nov 10, 2020
2f7db8f
clients/upscmd.c: avoid implicit switch fall-through
jimklimov Nov 10, 2020
3440806
clients/upsc.c: avoid implicit switch fall-through
jimklimov Nov 10, 2020
bed499e
drivers/riello_usb.c: avoid implicit switch fall-through
jimklimov Nov 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clients/upsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions clients/upscmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions common/snprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -364,15 +366,19 @@ 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
fvalue = va_arg (args, double);
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
Expand Down
6 changes: 6 additions & 0 deletions drivers/blazer_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,26 +425,32 @@ 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) {
upsdebugx(1, "Stall condition cleared");
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;
Expand Down
4 changes: 4 additions & 0 deletions drivers/mge-hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions drivers/nutdrv_atcl_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion drivers/nutdrv_qx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2126,26 +2126,32 @@ 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) {
upsdebugx(1, "Stall condition cleared");
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;
Expand Down
9 changes: 7 additions & 2 deletions drivers/riello_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,34 +348,40 @@ 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) {
upsdebugx(1, "Stall condition cleared");
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;
break;

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
Expand All @@ -386,7 +392,6 @@ int riello_command(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen)
break;
}


return ret;
}

Expand Down
4 changes: 4 additions & 0 deletions drivers/tripplite_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions drivers/usbhid-ups.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions server/upsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <address>' and '-p <port>'\n"
"is deprecated. Use 'LISTEN <address> [<port>]' 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);
Expand Down
1 change: 1 addition & 0 deletions tools/nut-scanner/nut-scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down