From 5920a1b5e19e529ab3a3972348a6d53bcd90acfc Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 2 Dec 2020 10:26:09 -0500 Subject: Give messages to unconditional assertion failures --- color.c | 2 +- ctx.c | 2 +- dstring.c | 2 +- parse.c | 2 +- stat.c | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/color.c b/color.c index b6b0e80..1d06e51 100644 --- a/color.c +++ b/color.c @@ -1081,7 +1081,7 @@ static int cvbuff(CFILE *cfile, const char *format, va_list args) { return 0; invalid: - assert(false); + assert(!"Invalid format string"); errno = EINVAL; return -1; } diff --git a/ctx.c b/ctx.c index 8f623e5..72ed969 100644 --- a/ctx.c +++ b/ctx.c @@ -50,7 +50,7 @@ const char *debug_flag_name(enum debug_flags flag) { break; } - assert(false); + assert(!"Unrecognized debug flag"); return "???"; } diff --git a/dstring.c b/dstring.c index 475bf65..58e74fe 100644 --- a/dstring.c +++ b/dstring.c @@ -192,7 +192,7 @@ int dstrvcatf(char **str, const char *format, va_list args) { tail = *str + len; ret = vsnprintf(tail, tail_len + 1, format, copy); if (ret < 0 || (size_t)ret != tail_len) { - assert(false); + assert(!"Length of formatted string changed"); goto fail; } } diff --git a/parse.c b/parse.c index 571b652..4e326ec 100644 --- a/parse.c +++ b/parse.c @@ -497,7 +497,7 @@ static const char *parse_int(const struct parser_state *state, const char *str, break; default: - assert(false); + assert(!"Invalid int size"); goto bad; } diff --git a/stat.c b/stat.c index fbbb002..7fb6b50 100644 --- a/stat.c +++ b/stat.c @@ -75,7 +75,7 @@ const char *bfs_stat_field_name(enum bfs_stat_field field) { return "modification time"; } - assert(false); + assert(!"Unrecognized stat field"); return "???"; } @@ -349,7 +349,7 @@ const struct timespec *bfs_stat_time(const struct bfs_stat *buf, enum bfs_stat_f case BFS_STAT_MTIME: return &buf->mtime; default: - assert(false); + assert(!"Invalid stat field for time"); errno = EINVAL; return NULL; } -- cgit v1.2.3