Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
b62bb16
common/parseconf.c: annotate pconf_fatal() with noreturn attr
jimklimov Nov 17, 2020
82a0bd7
drivers/main.c: annotate forceshutdown() with noreturn attr
jimklimov Nov 17, 2020
dfd4e5a
drivers/dstate.c: annotate sock_fail() with noreturn attr
jimklimov Nov 17, 2020
51793a8
drivers/serial.c: annotate ser_open_error() with noreturn attr
jimklimov Nov 17, 2020
f2cf292
drivers/liebert.c: annotate upsdrv_shutdown() with noreturn attr
jimklimov Nov 17, 2020
626fd10
drivers/skel.c: annotate upsdrv_shutdown() with noreturn attr
jimklimov Nov 17, 2020
5189f3e
drivers/clone.c: annotate upsdrv_shutdown() with noreturn attr
jimklimov Nov 17, 2020
8ceb6f3
drivers/ivtscd.c: annotate upsdrv_shutdown() with noreturn attr
jimklimov Nov 17, 2020
8101881
drivers/apcupsd-ups.c: annotate upsdrv_shutdown() with noreturn attr
jimklimov Nov 17, 2020
dfe756b
drivers/nutdrv_qx.c: annotate upsdrv_shutdown() with noreturn attr
jimklimov Nov 17, 2020
836b8b7
drivers/macosx-ups.c: annotate upsdrv_shutdown() with noreturn attr
jimklimov Nov 17, 2020
89cccde
drivers/upsdrvctl.c: annotate help() with noreturn attr
jimklimov Nov 17, 2020
7d22fa8
clients/upslog.c: annotate help() with noreturn attr
jimklimov Nov 20, 2020
9e7c274
clients/upsimage.c: annotate drawimage() with noreturn attr
jimklimov Nov 20, 2020
f82d661
clients/upsset.c: annotate several routines with noreturn attrs
jimklimov Nov 20, 2020
53af05e
clients/upsmon.c: help(): do not shadow global varname "progname" wit…
jimklimov Nov 20, 2020
aa95630
clients/upsmon.c: annotate several routines with noreturn attrs
jimklimov Nov 20, 2020
9318c37
drivers/dummy-ups.c: annotate upsdrv_shutdown() with noreturn attr
jimklimov Nov 20, 2020
7768913
drivers/blazer.c: annotate upsdrv_shutdown() with noreturn attr
jimklimov Nov 20, 2020
9bcad3f
drivers/riello_ser.c: annotate upsdrv_shutdown() with noreturn attr
jimklimov Nov 20, 2020
1f7a63e
drivers/bcmxcp_usb.c: fix indenting whitespace
jimklimov Nov 20, 2020
ba1fd29
drivers/bcmxcp_usb.c: annotate nutusb_open_error() with noreturn attr
jimklimov Nov 20, 2020
0ff3265
drivers/nut-ipmipsu.c: annotate upsdrv_shutdown() with noreturn attr
jimklimov Nov 20, 2020
618fa4c
server/upsd.c: help(): do not shadow global varnames "progname" (from…
jimklimov Nov 17, 2020
f2aa96c
server/upsd.c: annotate help() with noreturn attr
jimklimov Nov 20, 2020
2b9880f
configure.ac: introduce AX_C___ATTRIBUTE__ from gnu.org
jimklimov Nov 20, 2020
b24e3a8
m4/ax_c___attribute__.m4: extend to declare support for certain __att…
jimklimov Nov 20, 2020
2ca8f0a
include/attribute.h: align with AX_C___ATTRIBUTE__ autoconf macro
jimklimov Nov 20, 2020
f38768c
server/upsd.c: wrap unreachable exit() added due to earlier compiler …
jimklimov Nov 20, 2020
0a7bcf7
clients/upsc.c: wrap unreachable exit() added due to earlier compiler…
jimklimov Nov 20, 2020
1ee2274
clients/upscmd.c: wrap unreachable exit() added due to earlier compil…
jimklimov Nov 20, 2020
1669b95
clients/upslog.c: wrap unreachable switch()-break after help() with "…
jimklimov Nov 20, 2020
a9c4caa
clients/upsmon.c: wrap unreachable switch()-break after help() with "…
jimklimov Nov 20, 2020
b66e175
clients/upsmon.c: wrap unreachable exit() added due to earlier compil…
jimklimov Nov 20, 2020
14465d8
GitIgnore temporary dirs made by configure script (remain around if i…
jimklimov Nov 20, 2020
f2815a8
drivers/dummy-ups.c: a switch() default needs no break, especially no…
jimklimov Nov 20, 2020
de38573
drivers/metasys.c: a switch() default needs no break, especially not …
jimklimov Nov 20, 2020
14d3b25
drivers/usbhid-ups.c: wrap unreachable exit() added due to earlier co…
jimklimov Nov 20, 2020
1003f8b
drivers/tripplite_usb.c: control_outlet(): do not warn about syntacti…
jimklimov Nov 20, 2020
3f3957f
drivers/tripplite_usb.c: wrap unreachable exit() added due to earlier…
jimklimov Nov 20, 2020
5b835cc
drivers/blazer_usb.c: wrap unreachable exit() added due to earlier co…
jimklimov Nov 20, 2020
d2ab8e1
drivers/riello_usb.c: wrap unreachable exit() added due to earlier co…
jimklimov Nov 20, 2020
2ac8d6a
drivers/upsdrvctl.c: a switch() default needs no break
jimklimov Nov 20, 2020
5a69161
server/upsd.c: a switch() default needs no break
jimklimov Nov 20, 2020
73045a5
server/upsd.c: a move "help" switch() handling to default case
jimklimov Nov 20, 2020
b4ab135
drivers/libusb.c: do not warn about unreachable code where we handle …
jimklimov Nov 20, 2020
441b7d1
drivers/richcomm_usb.c: do not warn about unreachable code where we h…
jimklimov Nov 20, 2020
7ce0e11
drivers/nutdrv_atcl_usb.c: do not warn about unreachable code where w…
jimklimov Nov 20, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Makefile.in
/configure
/conf_nut_report_feature
/conf??????/
/dir.??????/
/cscope.*
/depcomp
/INSTALL
Expand Down
2 changes: 2 additions & 0 deletions clients/upsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ int main(int argc, char **argv)

case 'V':
fatalx(EXIT_SUCCESS, "Network UPS Tools upscmd %s", UPS_VERSION);
#ifndef HAVE___ATTRIBUTE__NORETURN
exit(EXIT_SUCCESS); /* Should not get here in practice, but compiler is afraid we can fall through */
#endif

case 'h':
default:
Expand Down
2 changes: 2 additions & 0 deletions clients/upscmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ int main(int argc, char **argv)

case 'V':
fatalx(EXIT_SUCCESS, "Network UPS Tools upscmd %s", UPS_VERSION);
#ifndef HAVE___ATTRIBUTE__NORETURN
exit(EXIT_SUCCESS); /* Should not get here in practice, but compiler is afraid we can fall through */
#endif

case 'h':
default:
Expand Down
3 changes: 3 additions & 0 deletions clients/upsimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ static int get_imgarg(const char *name)
}

/* write the HTML header then have gd dump the image */
static void drawimage(gdImagePtr im)
__attribute__((noreturn));

static void drawimage(gdImagePtr im)
{
printf("Pragma: no-cache\n");
Expand Down
5 changes: 5 additions & 0 deletions clients/upslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ static void setup_signals(void)
fatal_with_errno(EXIT_FAILURE, "Can't install SIGUSR1 handler");
}

static void help(const char *prog)
__attribute__((noreturn));

static void help(const char *prog)
{
printf("UPS status logger.\n");
Expand Down Expand Up @@ -403,7 +406,9 @@ int main(int argc, char **argv)
switch(i) {
case 'h':
help(prog);
#ifndef HAVE___ATTRIBUTE__NORETURN
break;
#endif

case 's':
monhost = optarg;
Expand Down
19 changes: 17 additions & 2 deletions clients/upsmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ static void set_pdflag(void)
}

/* the actual shutdown procedure */
static void doshutdown(void)
__attribute__((noreturn));

static void doshutdown(void)
{
int ret;
Expand Down Expand Up @@ -1671,11 +1674,14 @@ static int check_pdflag(void)
return EXIT_SUCCESS;
}

static void help(const char *progname)
static void help(const char *arg_progname)
__attribute__((noreturn));

static void help(const char *arg_progname)
{
printf("Monitors UPS servers and may initiate shutdown if necessary.\n\n");

printf("usage: %s [OPTIONS]\n\n", progname);
printf("usage: %s [OPTIONS]\n\n", arg_progname);
printf(" -c <cmd> send command to running process\n");
printf(" commands:\n");
printf(" - fsd: shutdown all master UPSes (use with caution)\n");
Expand All @@ -1692,6 +1698,9 @@ static void help(const char *progname)
exit(EXIT_SUCCESS);
}

static void runparent(int fd)
__attribute__((noreturn));

static void runparent(int fd)
{
int ret;
Expand Down Expand Up @@ -1747,7 +1756,9 @@ static void start_pipe(void)
close(pipefd[1]);
runparent(pipefd[0]);

#ifndef HAVE___ATTRIBUTE__NORETURN
exit(EXIT_FAILURE); /* NOTREACHED */
#endif
}

close(pipefd[0]);
Expand Down Expand Up @@ -1933,7 +1944,9 @@ int main(int argc, char *argv[])
break;
case 'h':
help(argv[0]);
#ifndef HAVE___ATTRIBUTE__NORETURN
break;
#endif
case 'K':
checking_flag = 1;
break;
Expand All @@ -1955,7 +1968,9 @@ int main(int argc, char *argv[])
break;
default:
help(argv[0]);
#ifndef HAVE___ATTRIBUTE__NORETURN
break;
#endif
}
}

Expand Down
19 changes: 19 additions & 0 deletions clients/upsset.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ static void do_pickups(const char *currfunc)
printf("</FORM>\n");
}

static void error_page(const char *next, const char *title,
const char *fmt, ...)
__attribute__((noreturn));

static void error_page(const char *next, const char *title,
const char *fmt, ...)
{
Expand Down Expand Up @@ -282,6 +286,9 @@ static void error_page(const char *next, const char *title,
exit(EXIT_SUCCESS);
}

static void loginscreen(void)
__attribute__((noreturn));

static void loginscreen(void)
{
do_header("Login");
Expand Down Expand Up @@ -506,6 +513,9 @@ static void send_auth(const char *next)
"Password set failed: %s", upscli_strerror(&ups));
}

static void docmd(void)
__attribute__((noreturn));

static void docmd(void)
{
char buf[SMALLBUF], *desc;
Expand Down Expand Up @@ -768,6 +778,9 @@ static void print_rw(const char *upsname, const char *varname)
printf("</TR>\n");
}

static void showsettings(void)
__attribute__((noreturn));

static void showsettings(void)
{
int ret;
Expand Down Expand Up @@ -910,6 +923,9 @@ static int setvar(const char *var, const char *val)
}

/* turn a form submission of settings into SET commands for upsd */
static void savesettings(void)
__attribute__((noreturn));

static void savesettings(void)
{
int changed = 0;
Expand Down Expand Up @@ -956,6 +972,9 @@ static void savesettings(void)
exit(EXIT_SUCCESS);
}

static void initial_pickups(void)
__attribute__((noreturn));

static void initial_pickups(void)
{
do_header("Select a UPS");
Expand Down
6 changes: 6 additions & 0 deletions common/parseconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
*
*/

#include "common.h"

#include <ctype.h>
#include <errno.h>
#include <stdio.h>
Expand All @@ -86,6 +88,7 @@
#include <fcntl.h>

#include "parseconf.h"
#include "attribute.h"

/* possible states */

Expand All @@ -98,6 +101,9 @@
#define STATE_ENDOFLINE 7
#define STATE_PARSEERR 8

static void pconf_fatal(PCONF_CTX_t *ctx, const char *errtxt)
__attribute__((noreturn));

static void pconf_fatal(PCONF_CTX_t *ctx, const char *errtxt)
{
if (ctx->errhandler)
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ AC_C_BIGENDIAN
AC_C_INLINE
AC_C_FLEXIBLE_ARRAY_MEMBER
AC_C_VARARRAYS
AX_C___ATTRIBUTE__
AC_CHECK_FUNCS(flock lockf fcvt fcvtl pow10 round abs_val abs)
AC_CHECK_FUNCS(fabs, [], [], [#include <math.h>])
AC_CHECK_FUNCS(cfsetispeed tcsendbreak)
Expand Down
6 changes: 6 additions & 0 deletions drivers/apcupsd-ups.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

*/

#include "config.h"

#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
Expand All @@ -24,6 +26,7 @@

#include "main.h"
#include "apcupsd-ups.h"
#include "attribute.h"

#define DRIVER_NAME "apcupsd network client UPS driver"
#define DRIVER_VERSION "0.5"
Expand Down Expand Up @@ -257,6 +260,9 @@ void upsdrv_updateinfo(void)
poll_interval = (poll_interval > POLL_INTERVAL_MIN) ? POLL_INTERVAL_MIN : poll_interval;
}

void upsdrv_shutdown(void)
__attribute__((noreturn));

void upsdrv_shutdown(void)
{
fatalx(EXIT_FAILURE, "shutdown not supported");
Expand Down
13 changes: 8 additions & 5 deletions drivers/bcmxcp_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ int get_answer(unsigned char *data, unsigned char command)
}

if (need_data > 0) /* We need more data */
continue;
continue;

/* Now validate XCP frame */
/* Check header */
Expand All @@ -204,7 +204,7 @@ int get_answer(unsigned char *data, unsigned char command)
/* Sometime we read something wrong. bad cables? bad ports? */
my_buf = memchr(my_buf, PW_COMMAND_START_BYTE, bytes_read);
if (!my_buf)
return -1;
return -1;
}

/* Read block number byte */
Expand Down Expand Up @@ -263,9 +263,9 @@ int get_answer(unsigned char *data, unsigned char command)
end_length += length;
tail = bytes_read - (length + PW_HEADER_SIZE);
if (tail > 0)
my_buf = memmove(&buf[0], my_buf + length + PW_HEADER_SIZE, tail);
my_buf = memmove(&buf[0], my_buf + length + PW_HEADER_SIZE, tail);
else if (tail == 0)
my_buf = &buf[0];
my_buf = &buf[0];
bytes_read = tail;
}

Expand Down Expand Up @@ -345,6 +345,9 @@ void upsdrv_reconnect(void)
}

/* USB functions */
static void nutusb_open_error(const char *port)
__attribute__((noreturn));

static void nutusb_open_error(const char *port)
{
printf("Unable to find POWERWARE UPS device on USB bus (%s)\n\n", port);
Expand Down Expand Up @@ -432,7 +435,7 @@ usb_dev_handle *nutusb_open(const char *port)
{
upsdebugx(1, "Can't reset POWERWARE USB endpoint: %s", usb_strerror());
if (dev_claimed)
usb_release_interface(dev_h, 0);
usb_release_interface(dev_h, 0);
usb_reset(dev_h);
sleep(5); /* Wait reconnect */
errout = 1;
Expand Down
2 changes: 2 additions & 0 deletions drivers/blazer.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,8 @@ void upsdrv_updateinfo(void)
dstate_dataok();
}

void upsdrv_shutdown(void)
__attribute__((noreturn));

void upsdrv_shutdown(void)
{
Expand Down
4 changes: 4 additions & 0 deletions drivers/blazer_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,15 @@ 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");
#ifndef HAVE___ATTRIBUTE__NORETURN
exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */
#endif

case -EPERM: /* Operation not permitted */
fatal_with_errno(EXIT_FAILURE, "Permissions problem");
#ifndef HAVE___ATTRIBUTE__NORETURN
exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */
#endif

case -EPIPE: /* Broken pipe */
if (usb_clear_halt(udev, 0x81) == 0) {
Expand Down
5 changes: 5 additions & 0 deletions drivers/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include "config.h"
#include "main.h"
#include "parseconf.h"
#include "attribute.h"

#include <sys/types.h>
#include <sys/socket.h>
Expand Down Expand Up @@ -520,6 +522,9 @@ void upsdrv_updateinfo(void)
}


void upsdrv_shutdown(void)
__attribute__((noreturn));

void upsdrv_shutdown(void)
{
fatalx(EXIT_FAILURE, "shutdown not supported");
Expand Down
4 changes: 4 additions & 0 deletions drivers/dstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "dstate.h"
#include "state.h"
#include "parseconf.h"
#include "attribute.h"

static int sockfd = -1, stale = 1, alarm_active = 0, ignorelb = 0;
static char *sockfn = NULL;
Expand All @@ -43,6 +44,9 @@
struct ups_handler upsh;

/* this may be a frequent stumbling point for new users, so be verbose here */
static void sock_fail(const char *fn)
__attribute__((noreturn));

static void sock_fail(const char *fn)
{
int sockerr;
Expand Down
6 changes: 4 additions & 2 deletions drivers/dummy-ups.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ void upsdrv_initinfo(void)
}
/* FIXME: commands and settable variable! */
break;
default:
case MODE_NONE:
default:
fatalx(EXIT_FAILURE, "no suitable definition found!");
break;
}
upsh.instcmd = instcmd;

Expand Down Expand Up @@ -188,6 +187,9 @@ void upsdrv_updateinfo(void)
}
}

void upsdrv_shutdown(void)
__attribute__((noreturn));

void upsdrv_shutdown(void)
{
fatalx(EXIT_FAILURE, "shutdown not supported");
Expand Down
Loading