Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more _noreturn_ attributes as suggested my -Wsuggest-attribute=noreturn #223

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ task:
pkginstall_script:
- pkg install -y groff pkgconf check
configure_script:
- echo "clang -O2 -Wall -Wshadow -Werror=implicit-function-declaration -Werror=deprecated-declarations" > conf-cc
- echo "clang -O2 -Wall -Wshadow -Werror=implicit-function-declaration -Werror=deprecated-declarations" -Wsuggest-attribute=noreturn > conf-cc
compile_script:
- make ${MAKE_FLAGS} it man
test_script:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
OS: ${{ matrix.host }}

- name: configure
run: echo "${CC} -O2 -fPIC -Wall -Wshadow -Werror=implicit-function-declaration -Wimplicit-fallthrough ${CFLAGS}" > conf-cc
run: echo "${CC} -O2 -fPIC -Wall -Wshadow -Werror=implicit-function-declaration -Wimplicit-fallthrough -Wsuggest-attribute=noreturn ${CFLAGS}" > conf-cc
env:
CC: ${{ matrix.config.cc }}
CFLAGS: ${{ matrix.config.cflags }}
Expand Down
2 changes: 1 addition & 1 deletion forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define FATAL "forward: fatal: "

void die_nomem() { strerr_die2x(111,FATAL,"out of memory"); }
void _noreturn_ die_nomem(void) { strerr_die2x(111,FATAL,"out of memory"); }

struct qmail qqt;

Expand Down
2 changes: 1 addition & 1 deletion maildir2mbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ char outbuf[SUBSTDIO_OUTSIZE];
#define FATAL "maildir2mbox: fatal: "
#define WARNING "maildir2mbox: warning: "

void die_nomem() { strerr_die2x(111,FATAL,"out of memory"); }
void _noreturn_ die_nomem(void) { strerr_die2x(111,FATAL,"out of memory"); }

int main(void)
{
Expand Down
2 changes: 1 addition & 1 deletion preline.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#define FATAL "preline: fatal: "

void die_usage()
void _noreturn_ die_usage(void)
{
strerr_die1x(100,"preline: usage: preline cmd [ arg ... ]");
}
Expand Down
6 changes: 3 additions & 3 deletions qmail-local.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "datetime.h"
#include "exit.h"
#include "fork.h"
#include "noreturn.h"
#include "open.h"
#include "wait.h"
#include "lock.h"
Expand Down Expand Up @@ -74,10 +75,9 @@ char outbuf[1024];
char fntmptph[80 + FMT_ULONG * 2];
char fnnewtph[80 + FMT_ULONG * 2];
void tryunlinktmp() { unlink(fntmptph); }
void sigalrm() { tryunlinktmp(); _exit(3); }
void _noreturn_ sigalrm() { tryunlinktmp(); _exit(3); }

void maildir_child(dir)
char *dir;
void _noreturn_ maildir_child(const char *dir)
{
unsigned long pid;
unsigned long time;
Expand Down
4 changes: 2 additions & 2 deletions qmail-newmrh.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

extern int rename(const char *, const char *);

void die_read()
void _noreturn_ die_read(void)
{
strerr_die2sys(111,FATAL,"unable to read control/morercpthosts: ");
}
void die_write()
void _noreturn_ die_write(void)
{
strerr_die2sys(111,FATAL,"unable to write to control/morercpthosts.tmp: ");
}
Expand Down
19 changes: 10 additions & 9 deletions qmail-newu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "stralloc.h"
#include "subfd.h"
#include "getln.h"
#include "noreturn.h"
#include "substdio.h"
#include "byte.h"
#include "cdbmss.h"
Expand All @@ -14,44 +15,44 @@

extern int rename(const char *, const char *);

void die_temp() { _exit(111); }
void _noreturn_ die_temp(void) { _exit(111); }

void die_chdir()
void _noreturn_ die_chdir(void)
{
substdio_putsflush(subfderr,"qmail-newu: fatal: unable to chdir\n");
die_temp();
}
void die_nomem()
void _noreturn_ die_nomem(void)
{
substdio_putsflush(subfderr,"qmail-newu: fatal: out of memory\n");
die_temp();
}
void die_opena()
void _noreturn_ die_opena(void)
{
substdio_putsflush(subfderr,"qmail-newu: fatal: unable to open users/assign\n");
die_temp();
}
void die_reada()
void _noreturn_ die_reada(void)
{
substdio_putsflush(subfderr,"qmail-newu: fatal: unable to read users/assign\n");
die_temp();
}
void die_format()
void _noreturn_ die_format(void)
{
substdio_putsflush(subfderr,"qmail-newu: fatal: bad format in users/assign\n");
die_temp();
}
void die_opent()
void _noreturn_ die_opent(void)
{
substdio_putsflush(subfderr,"qmail-newu: fatal: unable to open users/cdb.tmp\n");
die_temp();
}
void die_writet()
void _noreturn_ die_writet(void)
{
substdio_putsflush(subfderr,"qmail-newu: fatal: unable to write users/cdb.tmp\n");
die_temp();
}
void die_rename()
void _noreturn_ die_rename(void)
{
substdio_putsflush(subfderr,"qmail-newu: fatal: unable to move users/cdb.tmp to users/cdb\n");
die_temp();
Expand Down
13 changes: 7 additions & 6 deletions qmail-pop3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "commands.h"
#include "sig.h"
#include "getln.h"
#include "noreturn.h"
#include "stralloc.h"
#include "substdio.h"
#include "alloc.h"
Expand All @@ -20,7 +21,7 @@
#include "timeoutread.h"
#include "timeoutwrite.h"

void die() { _exit(0); }
void _noreturn_ die(void) { _exit(0); }

extern int rename(const char *, const char *);

Expand Down Expand Up @@ -56,13 +57,13 @@ void err(s) char *s;
flush();
}

void die_nomem() { err("out of memory"); die(); }
void die_nomaildir() { err("this user has no $HOME/Maildir"); die(); }
void die_root() {
void _noreturn_ die_nomem(void) { err("out of memory"); die(); }
void _noreturn_ die_nomaildir(void) { err("this user has no $HOME/Maildir"); die(); }
void _noreturn_ die_root(void) {
substdio_putsflush(&sserr,"qmail-pop3d invoked as uid 0, terminating\n");
_exit(1);
}
void die_scan() { err("unable to scan $HOME/Maildir"); die(); }
void _noreturn_ die_scan(void) { err("unable to scan $HOME/Maildir"); die(); }

void err_syntax() { err("syntax error"); }
void err_unimpl(arg) char *arg; { err("unimplemented"); }
Expand Down Expand Up @@ -176,7 +177,7 @@ void pop3_last(arg) char *arg;
flush();
}

void pop3_quit(arg) char *arg;
void _noreturn_ pop3_quit(const char *arg)
{
unsigned int i;
for (i = 0;i < numm;++i)
Expand Down
17 changes: 9 additions & 8 deletions qmail-pw2u.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "sgetopt.h"
#include "control.h"
#include "constmap.h"
#include "noreturn.h"
#include "stralloc.h"
#include "fmt.h"
#include "str.h"
Expand All @@ -19,48 +20,48 @@
#include "auto_qmail.h"
#include "auto_users.h"

void die_chdir()
void _noreturn_ die_chdir(void)
{
substdio_putsflush(subfderr,"qmail-pw2u: fatal: unable to chdir\n");
_exit(111);
}
void die_nomem()
void _noreturn_ die_nomem(void)
{
substdio_putsflush(subfderr,"qmail-pw2u: fatal: out of memory\n");
_exit(111);
}
void die_read()
void _noreturn_ die_read(void)
{
substdio_putsflush(subfderr,"qmail-pw2u: fatal: unable to read input\n");
_exit(111);
}
void die_write()
void _noreturn_ die_write(void)
{
substdio_putsflush(subfderr,"qmail-pw2u: fatal: unable to write output\n");
_exit(111);
}
void die_control()
void _noreturn_ die_control(void)
{
substdio_putsflush(subfderr,"qmail-pw2u: fatal: unable to read controls\n");
_exit(111);
}
void die_alias()
void _noreturn_ die_alias(void)
{
substdio_puts(subfderr,"qmail-pw2u: fatal: unable to find ");
substdio_puts(subfderr,auto_usera);
substdio_puts(subfderr," user\n");
substdio_flush(subfderr);
_exit(111);
}
void die_home(fn) char *fn;
void _noreturn_ die_home(char *fn)
{
substdio_puts(subfderr,"qmail-pw2u: fatal: unable to stat ");
substdio_puts(subfderr,fn);
substdio_puts(subfderr,"\n");
substdio_flush(subfderr);
_exit(111);
}
void die_user(s,len) char *s; unsigned int len;
void _noreturn_ die_user(char *s, unsigned int len)
{
substdio_puts(subfderr,"qmail-pw2u: fatal: unable to find ");
substdio_put(subfderr,s,len);
Expand Down
21 changes: 11 additions & 10 deletions qmail-qmqpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "getln.h"
#include "readwrite.h"
#include "exit.h"
#include "noreturn.h"
#include "stralloc.h"
#include "slurpclose.h"
#include "error.h"
Expand All @@ -20,16 +21,16 @@

#define PORT_QMQP 628

void die_success() { _exit(0); }
void die_perm() { _exit(31); }
void nomem() { _exit(51); }
void die_read() { if (errno == error_nomem) nomem(); _exit(54); }
void die_control() { _exit(55); }
void die_socket() { _exit(56); }
void die_home() { _exit(61); }
void die_temp() { _exit(71); }
void die_conn() { _exit(74); }
void die_format() { _exit(91); }
void _noreturn_ die_success(void) { _exit(0); }
void _noreturn_ die_perm(void) { _exit(31); }
void _noreturn_ nomem(void) { _exit(51); }
void _noreturn_ die_read(void) { if (errno == error_nomem) nomem(); _exit(54); }
void _noreturn_ die_control(void) { _exit(55); }
void _noreturn_ die_socket(void) { _exit(56); }
void _noreturn_ die_home(void) { _exit(61); }
void _noreturn_ die_temp(void) { _exit(71); }
void _noreturn_ die_conn(void) { _exit(74); }
void _noreturn_ die_format(void) { _exit(91); }

int lasterror = 55;
int qmqpfd;
Expand Down
3 changes: 2 additions & 1 deletion qmail-qmqpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
#include "substdio.h"
#include "readwrite.h"
#include "exit.h"
#include "noreturn.h"
#include "now.h"
#include "fmt.h"
#include "byte.h"
#include "env.h"
#include "str.h"

void resources() { _exit(111); }
void _noreturn_ resources(void) { _exit(111); }

ssize_t safewrite(int fd, const void *buf, size_t len)
{
Expand Down
6 changes: 2 additions & 4 deletions qmail-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ void outsmtptext()
}
}

void quit(prepend,append)
char *prepend;
char *append;
void _noreturn_ quit(char *prepend, char *append)
{
substdio_putsflush(&smtpto,"QUIT\r\n");
/* waiting for remote side is just too ridiculous */
Expand Down Expand Up @@ -214,7 +212,7 @@ void blast()

stralloc recip = {0};

void smtp()
void _noreturn_ smtp(void)
{
unsigned long code;
int flagbother;
Expand Down
15 changes: 8 additions & 7 deletions qmail-smtpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "error.h"
#include "ipme.h"
#include "ip.h"
#include "noreturn.h"
#include "qmail.h"
#include "str.h"
#include "fmt.h"
Expand All @@ -37,12 +38,12 @@ substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof(ssoutbuf));
void flush() { substdio_flush(&ssout); }
void out(s) char *s; { substdio_puts(&ssout,s); }

void die_read() { _exit(1); }
void die_alarm() { out("451 timeout (#4.4.2)\r\n"); flush(); _exit(1); }
void die_nomem() { out("421 out of memory (#4.3.0)\r\n"); flush(); _exit(1); }
void die_control() { out("421 unable to read controls (#4.3.0)\r\n"); flush(); _exit(1); }
void die_ipme() { out("421 unable to figure out my IP addresses (#4.3.0)\r\n"); flush(); _exit(1); }
void straynewline() { out("451 See https://cr.yp.to/docs/smtplf.html.\r\n"); flush(); _exit(1); }
void _noreturn_ die_read(void) { _exit(1); }
void _noreturn_ die_alarm(void) { out("451 timeout (#4.4.2)\r\n"); flush(); _exit(1); }
void _noreturn_ die_nomem(void) { out("421 out of memory (#4.3.0)\r\n"); flush(); _exit(1); }
void _noreturn_ die_control(void) { out("421 unable to read controls (#4.3.0)\r\n"); flush(); _exit(1); }
void _noreturn_ die_ipme(void) { out("421 unable to figure out my IP addresses (#4.3.0)\r\n"); flush(); _exit(1); }
void _noreturn_ straynewline(void) { out("451 See https://cr.yp.to/docs/smtplf.html.\r\n"); flush(); _exit(1); }

void err_bmf() { out("553 sorry, your envelope sender is in my badmailfrom list (#5.7.1)\r\n"); }
void err_nogateway() { out("553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)\r\n"); }
Expand All @@ -66,7 +67,7 @@ void smtp_help(arg) char *arg;
{
out("214 notqmail home page: https://notqmail.org\r\n");
}
void smtp_quit(arg) char *arg;
void _noreturn_ smtp_quit(const char *arg)
{
smtp_greet("221 "); out("\r\n"); flush(); _exit(0);
}
Expand Down
11 changes: 6 additions & 5 deletions qmail-tcpto.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
#include "fmt.h"
#include "ip.h"
#include "lock.h"
#include "noreturn.h"
#include "open.h"
#include "error.h"
#include "exit.h"
#include "datetime.h"
#include "now.h"

void die(n) int n; { substdio_flush(subfdout); _exit(n); }
void _noreturn_ die(int n) { substdio_flush(subfdout); _exit(n); }

void warn(s) char *s;
{
Expand All @@ -25,10 +26,10 @@ void warn(s) char *s;
substdio_puts(subfdout,"\n");
}

void die_chdir() { warn("fatal: unable to chdir"); die(111); }
void die_open() { warn("fatal: unable to open tcpto"); die(111); }
void die_lock() { warn("fatal: unable to lock tcpto"); die(111); }
void die_read() { warn("fatal: unable to read tcpto"); die(111); }
void _noreturn_ die_chdir(void) { warn("fatal: unable to chdir"); die(111); }
void _noreturn_ die_open(void) { warn("fatal: unable to open tcpto"); die(111); }
void _noreturn_ die_lock(void) { warn("fatal: unable to lock tcpto"); die(111); }
void _noreturn_ die_read(void) { warn("fatal: unable to read tcpto"); die(111); }

char tcpto_buf[1024];

Expand Down
Loading