diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/messages-krb5.c | 2 | ||||
-rw-r--r-- | util/messages.c | 56 | ||||
-rw-r--r-- | util/xmalloc.c | 8 | ||||
-rw-r--r-- | util/xmalloc.h | 22 |
4 files changed, 44 insertions, 44 deletions
diff --git a/util/messages-krb5.c b/util/messages-krb5.c index a33d77a..435369e 100644 --- a/util/messages-krb5.c +++ b/util/messages-krb5.c @@ -37,8 +37,8 @@ #include <portable/krb5.h> #include <portable/system.h> -#include <util/messages.h> #include <util/messages-krb5.h> +#include <util/messages.h> #include <util/xmalloc.h> diff --git a/util/messages.c b/util/messages.c index 941a88f..0e79a43 100644 --- a/util/messages.c +++ b/util/messages.c @@ -54,7 +54,7 @@ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>. * * Written by Russ Allbery <eagle@eyrie.org> - * Copyright 2015-2016 Russ Allbery <eagle@eyrie.org> + * Copyright 2015-2016, 2020 Russ Allbery <eagle@eyrie.org> * Copyright 2008-2010, 2013-2014 * The Board of Trustees of the Leland Stanford Junior University * Copyright 2004-2006 Internet Systems Consortium, Inc. ("ISC") @@ -83,17 +83,17 @@ #include <errno.h> #ifdef HAVE_SYSLOG_H -# include <syslog.h> +# include <syslog.h> #endif #ifdef _WIN32 -# include <windows.h> -# define LOG_DEBUG EVENTLOG_SUCCESS -# define LOG_INFO EVENTLOG_INFORMATION_TYPE -# define LOG_NOTICE EVENTLOG_INFORMATION_TYPE -# define LOG_WARNING EVENTLOG_WARNING_TYPE -# define LOG_ERR EVENTLOG_ERROR_TYPE -# define LOG_CRIT EVENTLOG_ERROR_TYPE +# include <windows.h> +# define LOG_DEBUG EVENTLOG_SUCCESS +# define LOG_INFO EVENTLOG_INFORMATION_TYPE +# define LOG_NOTICE EVENTLOG_INFORMATION_TYPE +# define LOG_WARNING EVENTLOG_WARNING_TYPE +# define LOG_ERR EVENTLOG_ERROR_TYPE +# define LOG_CRIT EVENTLOG_ERROR_TYPE #endif #include <util/macros.h> @@ -101,18 +101,14 @@ #include <util/xmalloc.h> /* The default handler lists. */ -static message_handler_func stdout_handlers[2] = { - message_log_stdout, NULL -}; -static message_handler_func stderr_handlers[2] = { - message_log_stderr, NULL -}; +static message_handler_func stdout_handlers[2] = {message_log_stdout, NULL}; +static message_handler_func stderr_handlers[2] = {message_log_stderr, NULL}; /* The list of logging functions currently in effect. */ -static message_handler_func *debug_handlers = NULL; +static message_handler_func *debug_handlers = NULL; static message_handler_func *notice_handlers = stdout_handlers; -static message_handler_func *warn_handlers = stderr_handlers; -static message_handler_func *die_handlers = stderr_handlers; +static message_handler_func *warn_handlers = stderr_handlers; +static message_handler_func *die_handlers = stderr_handlers; /* If non-NULL, called before exit and its return value passed to exit. */ int (*message_fatal_cleanup)(void) = NULL; @@ -144,16 +140,18 @@ message_handlers(message_handler_func **list, unsigned int count, va_list args) * duplication since we can't assume variadic macros, but I can at least make * it easier to write and keep them consistent. */ -#define HANDLER_FUNCTION(type) \ - void \ - message_handlers_ ## type(unsigned int count, ...) \ - { \ - va_list args; \ - \ - va_start(args, count); \ - message_handlers(& type ## _handlers, count, args); \ - va_end(args); \ +/* clang-format off */ +#define HANDLER_FUNCTION(type) \ + void \ + message_handlers_ ## type(unsigned int count, ...) \ + { \ + va_list args; \ + \ + va_start(args, count); \ + message_handlers(& type ## _handlers, count, args); \ + va_end(args); \ } +/* clang-format on */ HANDLER_FUNCTION(debug) HANDLER_FUNCTION(notice) HANDLER_FUNCTION(warn) @@ -254,7 +252,7 @@ message_log_syslog(int pri, size_t len, const char *fmt, va_list args, int err) CloseEventLog(eventlog); } } -#else /* !_WIN32 */ +#else /* !_WIN32 */ if (err == 0) syslog(pri, "%s", buffer); else @@ -268,6 +266,7 @@ message_log_syslog(int pri, size_t len, const char *fmt, va_list args, int err) * Do the same sort of wrapper to generate all of the separate syslog logging * functions. */ +/* clang-format off */ #define SYSLOG_FUNCTION(name, type) \ void \ message_log_syslog_ ## name(size_t l, const char *f, va_list a, int e) \ @@ -280,6 +279,7 @@ SYSLOG_FUNCTION(notice, NOTICE) SYSLOG_FUNCTION(warning, WARNING) SYSLOG_FUNCTION(err, ERR) SYSLOG_FUNCTION(crit, CRIT) +/* clang-format on */ /* diff --git a/util/xmalloc.c b/util/xmalloc.c index f5cacc3..e8a9a82 100644 --- a/util/xmalloc.c +++ b/util/xmalloc.c @@ -101,8 +101,8 @@ void xmalloc_fail(const char *function, size_t size, const char *file, int line) { if (size == 0) - sysdie("failed to format output with %s at %s line %d", function, - file, line); + sysdie("failed to format output with %s at %s line %d", function, file, + line); else sysdie("failed to %s %lu bytes at %s line %d", function, (unsigned long) size, file, line); @@ -202,7 +202,7 @@ x_strndup(const char *s, size_t size, const char *file, int line) char *copy; /* Don't assume that the source string is nul-terminated. */ - for (p = s; (size_t) (p - s) < size && *p != '\0'; p++) + for (p = s; (size_t)(p - s) < size && *p != '\0'; p++) ; length = p - s; copy = malloc(length + 1); @@ -262,7 +262,7 @@ x_asprintf(char **strp, const char *file, int line, const char *fmt, ...) } va_end(args); } -#else /* !(HAVE_C99_VAMACROS || HAVE_GNU_VAMACROS) */ +#else /* !(HAVE_C99_VAMACROS || HAVE_GNU_VAMACROS) */ void x_asprintf(char **strp, const char *fmt, ...) { diff --git a/util/xmalloc.h b/util/xmalloc.h index 61f5ed1..02c5431 100644 --- a/util/xmalloc.h +++ b/util/xmalloc.h @@ -42,12 +42,12 @@ * number information for debugging error messages without the user having to * pass those in every time. */ -#define xcalloc(n, size) x_calloc((n), (size), __FILE__, __LINE__) -#define xmalloc(size) x_malloc((size), __FILE__, __LINE__) -#define xrealloc(p, size) x_realloc((p), (size), __FILE__, __LINE__) -#define xstrdup(p) x_strdup((p), __FILE__, __LINE__) -#define xstrndup(p, size) x_strndup((p), (size), __FILE__, __LINE__) -#define xvasprintf(p, f, a) x_vasprintf((p), (f), (a), __FILE__, __LINE__) +#define xcalloc(n, size) x_calloc((n), (size), __FILE__, __LINE__) +#define xmalloc(size) x_malloc((size), __FILE__, __LINE__) +#define xrealloc(p, size) x_realloc((p), (size), __FILE__, __LINE__) +#define xstrdup(p) x_strdup((p), __FILE__, __LINE__) +#define xstrndup(p, size) x_strndup((p), (size), __FILE__, __LINE__) +#define xvasprintf(p, f, a) x_vasprintf((p), (f), (a), __FILE__, __LINE__) #define xreallocarray(p, n, size) \ x_reallocarray((p), (n), (size), __FILE__, __LINE__) @@ -60,13 +60,13 @@ * are supported. */ #ifdef HAVE_C99_VAMACROS -# define xasprintf(p, f, ...) \ - x_asprintf((p), __FILE__, __LINE__, (f), __VA_ARGS__) +# define xasprintf(p, f, ...) \ + x_asprintf((p), __FILE__, __LINE__, (f), __VA_ARGS__) #elif HAVE_GNU_VAMACROS -# define xasprintf(p, f, args...) \ - x_asprintf((p), __FILE__, __LINE__, (f), args) +# define xasprintf(p, f, args...) \ + x_asprintf((p), __FILE__, __LINE__, (f), args) #else -# define xasprintf x_asprintf +# define xasprintf x_asprintf #endif BEGIN_DECLS |