From eaefd95106faf32f923979afa6badb18c59f246e Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 5 Sep 2024 10:18:47 +0200 Subject: [PATCH] clar: stop using `assert()` We have a single callsite of `assert()` remaining in our codebase that checks for unknown command line arguments. This is somewhat broken though as asserts may not be compiled depending on how the code is compiled. Consequently, we may not abort properly on invalid arguments in some scenarios. Fix this issue by using `clar_abort()` instead. --- clar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clar.c b/clar.c index 2f92100..f463ee8 100644 --- a/clar.c +++ b/clar.c @@ -4,7 +4,7 @@ * This file is part of clar, distributed under the ISC license. * For full terms see the included COPYING file. */ -#include + #include #include #include @@ -546,7 +546,8 @@ clar_parse_args(int argc, char **argv) break; default: - assert(!"Unexpected commandline argument!"); + clar_abort("Unexpected commandline argument '%s'.\n", + argument[1]); } } }