diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-05-13 10:57:30 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-05-13 15:39:02 -0400 |
commit | 33bbbed9dde90b68d3bf88dca1f21b557425db4b (patch) | |
tree | 4b12ad76a67bbe71077ad3051c143a3f1061844d /log-internal.h | |
parent | dfb75ab207f105c780a9819414c78f235548773d (diff) | |
download | libevent-33bbbed9dde90b68d3bf88dca1f21b557425db4b.tar.gz |
Mark the event_err() functions as __attribute__((noreturn))
This attribute tells gcc (and anything else that understands gcc
attributes) that the functions will never return control, and helps
the optimizer a little. With luck, it will also tell
less-than-full-program dataflow analysis tools that they don't need to
worry about any code path that involves calling one of these functions
and then returning.
This patch also forces event_exit() to always exit, no matter what the
user-supplied fatal_callback does. This means that the old unit tests
for the event_err* functions don't work any more, since they assume it
is safe to call event_err* if you've given it a bogus fatal_callback
that doesn't exit. Instead, we have to make the unit tests fork
before calling event_err(), and have the main unit test process wait
for the event_err() test to exit with a sane exit code. On unix,
that's trivial. On windows, let's not bother and just assume that
event_err* works.
Diffstat (limited to 'log-internal.h')
-rw-r--r-- | log-internal.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/log-internal.h b/log-internal.h index 786a92c7..3545da9d 100644 --- a/log-internal.h +++ b/log-internal.h @@ -31,17 +31,19 @@ #ifdef __GNUC__ #define EV_CHECK_FMT(a,b) __attribute__((format(printf, a, b))) +#define EV_NORETURN __attribute__((noreturn)) #else #define EV_CHECK_FMT(a,b) +#define EV_NORETURN #endif #define _EVENT_ERR_ABORT 0xdeaddead -void event_err(int eval, const char *fmt, ...) EV_CHECK_FMT(2,3); +void event_err(int eval, const char *fmt, ...) EV_CHECK_FMT(2,3) EV_NORETURN; void event_warn(const char *fmt, ...) EV_CHECK_FMT(1,2); -void event_sock_err(int eval, evutil_socket_t sock, const char *fmt, ...) EV_CHECK_FMT(3,4); +void event_sock_err(int eval, evutil_socket_t sock, const char *fmt, ...) EV_CHECK_FMT(3,4) EV_NORETURN; void event_sock_warn(evutil_socket_t sock, const char *fmt, ...) EV_CHECK_FMT(2,3); -void event_errx(int eval, const char *fmt, ...) EV_CHECK_FMT(2,3); +void event_errx(int eval, const char *fmt, ...) EV_CHECK_FMT(2,3) EV_NORETURN; void event_warnx(const char *fmt, ...) EV_CHECK_FMT(1,2); void event_msgx(const char *fmt, ...) EV_CHECK_FMT(1,2); void _event_debugx(const char *fmt, ...) EV_CHECK_FMT(1,2); |