aboutsummaryrefslogtreecommitdiff
path: root/utils.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-18 10:30:17 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-18 10:30:17 -0800
commiteece8c85564b9c5ae0cb3edfe7edb684242e9227 (patch)
treea3de972d08072bd4e7d5b626693ae174542cc58e /utils.h
parent7f0c3804dce7591332bbf6bd0922597ea675df44 (diff)
More static analyzer cleanup, including switching to use bools where
appropriate and EXIT_SUCESS/EXIT_FAILURE
Diffstat (limited to 'utils.h')
-rw-r--r--utils.h8
1 files changed, 5 insertions, 3 deletions
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 <stdbool.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#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))