From eece8c85564b9c5ae0cb3edfe7edb684242e9227 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 18 Jan 2021 10:30:17 -0800 Subject: More static analyzer cleanup, including switching to use bools where appropriate and EXIT_SUCESS/EXIT_FAILURE --- utils.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'utils.h') diff --git a/utils.h b/utils.h index 8080ee5..f3f81f0 100644 --- a/utils.h +++ b/utils.h @@ -4,14 +4,16 @@ #ifndef UTILS__H #define UTILS__H +#include #include +#include #include #include #include "match.h" #define streq(a, b) (strcmp(a, b) == 0) -#define check(cond, ...) do { if (!(cond)) { (void)fprintf(stderr, __VA_ARGS__); (void)fwrite("\n", 1, 1, stderr); exit(1); } } while(0) +#define check(cond, ...) do { if (!(cond)) { (void)fprintf(stderr, __VA_ARGS__); (void)fwrite("\n", 1, 1, stderr); exit(EXIT_FAILURE); } } while(0) #define new(t) memcheck(calloc(1, sizeof(t))) #define xcalloc(a,b) memcheck(calloc(a,b)) #define xrealloc(a,b) memcheck(realloc(a,b)) @@ -23,9 +25,9 @@ const char *after_name(const char *str); __attribute__((pure, nonnull, returns_nonnull)) const char *after_spaces(const char *str); __attribute__((nonnull)) -int matchchar(const char **str, char c); +bool matchchar(const char **str, char c); __attribute__((nonnull)) -int matchstr(const char **str, const char *target); +bool matchstr(const char **str, const char *target); __attribute__((nonnull)) size_t unescape_string(char *dest, const char *src, size_t bufsize); __attribute__((returns_nonnull)) -- cgit v1.2.3