From d2ff9482073294632d936e89c0eca59591bf872d Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 1 Dec 2018 10:33:08 +0000 Subject: [PATCH] Mark a few functions as __attribute__((noreturn)). This is mostly to make static analysers and compiler warnings a bit happier - now they know that a call to, say, modalfatalbox() means they don't have to worry about what the rest of the function will do. --- defs.h | 6 ++++++ pscp.c | 2 +- putty.h | 7 ++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/defs.h b/defs.h index f97d56fc..19d501a5 100644 --- a/defs.h +++ b/defs.h @@ -113,4 +113,10 @@ typedef struct PacketProtocolLayer PacketProtocolLayer; TYPECHECK(object == &((type *)0)->field, \ ((type *)(((char *)(object)) - offsetof(type, field)))) +#if defined __GNUC__ || defined __clang__ +#define NORETURN __attribute__((__noreturn__)) +#else +#define NORETURN +#endif + #endif /* PUTTY_DEFS_H */ diff --git a/pscp.c b/pscp.c index 053b0999..de7ae64b 100644 --- a/pscp.c +++ b/pscp.c @@ -226,7 +226,7 @@ static void ssh_scp_init(void) /* * Print an error message and exit after closing the SSH link. */ -static void bump(const char *fmt, ...) +static NORETURN void bump(const char *fmt, ...) { char *str, *str2; va_list ap; diff --git a/putty.h b/putty.h index 0f4ab6db..04091afe 100644 --- a/putty.h +++ b/putty.h @@ -1141,11 +1141,8 @@ struct TermWinVtable { * Global functions not specific to a connection instance. */ void nonfatal(const char *, ...); -void modalfatalbox(const char *, ...); -#ifdef macintosh -#pragma noreturn(modalfatalbox) -#endif -void cleanup_exit(int); +NORETURN void modalfatalbox(const char *, ...); +NORETURN void cleanup_exit(int); /* * Exports from conf.c, and a big enum (via parametric macro) of