From 155fceabe7070b6610d577734734d038d097b088 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 2 Jan 2022 14:12:54 -0500 Subject: Add assertions for all non-null pointers in the public API Clang issues warnings at build time based on the SERD_NONNULL annotations, which is a much better approach in general. However, it does not cover cases where the API is being used with another compiler, or without a compiler that can statically check things at all (such as Python or other dynamic language bindings). In those situations, getting a clear assertion message is a lot less confusing than a random crash somewhere in serd, and it makes it clear that the bug is in the caller, so I think it's worth the tedious verbosity. --- src/canon.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/canon.c') diff --git a/src/canon.c b/src/canon.c index 84d20d0c..67cf30bf 100644 --- a/src/canon.c +++ b/src/canon.c @@ -23,6 +23,7 @@ #include "exess/exess.h" #include "serd/serd.h" +#include #include #include #include @@ -182,6 +183,8 @@ serd_canon_new(const SerdWorld* const world, const SerdSink* const target, const SerdCanonFlags flags) { + assert(target); + SerdCanonData* const data = (SerdCanonData*)calloc(1, sizeof(SerdCanonData)); data->world = world; -- cgit v1.2.1