diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-06-17 23:02:36 +0200 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-06-17 23:03:35 +0200 |
commit | c3c2cb8d011f1c3e28b22584ea11fa544402c89b (patch) | |
tree | acd5ec6970bfd02e0cb56a5806a0911fe0684dea /die.h | |
parent | 36a07514e979d4cb2c677331ddc10c9c6080de26 (diff) |
die: minor: simplify code a bit
Make the code a bit simpler. Also use bool for the syslog_maybe
condition.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'die.h')
-rw-r--r-- | die.h | 28 |
1 files changed, 17 insertions, 11 deletions
@@ -1,15 +1,10 @@ -/* - * netsniff-ng - the packet sniffing beast - * Copyright 2009, 2010 Daniel Borkmann. - * Subject to the GPL, version 2. - */ - #ifndef DIE_H #define DIE_H #include <stdio.h> #include <stdlib.h> #include <stdarg.h> +#include <stdbool.h> #include <string.h> #include <errno.h> #include <unistd.h> @@ -20,19 +15,29 @@ static inline void panic(const char *format, ...) __check_format_printf(1, 2); static inline void syslog_panic(const char *format, ...) __check_format_printf(1, 2); -static inline void syslog_maybe(int may, int priority, +static inline void syslog_maybe(bool cond, int priority, const char *format, ...) __check_format_printf(3, 4); -static inline void __noreturn die(void) +static inline void __noreturn __die_hard(void) { exit(EXIT_FAILURE); } -static inline void __noreturn _die(void) +static inline void __noreturn __die_harder(void) { _exit(EXIT_FAILURE); } +static inline void __noreturn die(void) +{ + __die_hard(); +} + +static inline void __noreturn _die(void) +{ + __die_harder(); +} + static inline void __noreturn panic(const char *format, ...) { va_list vl; @@ -55,9 +60,10 @@ static inline void __noreturn syslog_panic(const char *format, ...) die(); } -static inline void syslog_maybe(int maybe, int priority, const char *format, ...) +static inline void syslog_maybe(bool cond, int priority, + const char *format, ...) { - if (!!maybe) { + if (cond) { va_list vl; va_start(vl, format); |