aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-06-24 08:04:39 -0400
committerDavid Robillard <d@drobilla.net>2024-06-24 08:22:43 -0400
commit570b40e58eed90c5ec747c44e791c5321c2ea604 (patch)
tree92117aa4c2cf318d9c6e63d8630de732b4df8c03
parentd2663582ca9305a36f9107cf95b951393a1563dc (diff)
downloadserd-570b40e58eed90c5ec747c44e791c5321c2ea604.tar.gz
serd-570b40e58eed90c5ec747c44e791c5321c2ea604.tar.bz2
serd-570b40e58eed90c5ec747c44e791c5321c2ea604.zip
Clean up nonnull parameter assertions
-rw-r--r--src/env.c16
-rw-r--r--src/reader.c5
-rw-r--r--src/string.c2
-rw-r--r--src/uri.c3
-rw-r--r--src/writer.c9
5 files changed, 32 insertions, 3 deletions
diff --git a/src/env.c b/src/env.c
index ffbccd3e..33077c0c 100644
--- a/src/env.c
+++ b/src/env.c
@@ -140,6 +140,8 @@ serd_env_set_prefix(SerdEnv* const env,
const SerdNode* const uri)
{
assert(env);
+ assert(name);
+ assert(uri);
if (!name->buf || uri->type != SERD_URI) {
return SERD_ERR_BAD_ARG;
@@ -167,6 +169,10 @@ serd_env_set_prefix_from_strings(SerdEnv* const env,
const uint8_t* const name,
const uint8_t* const uri)
{
+ assert(env);
+ assert(name);
+ assert(uri);
+
const SerdNode name_node = serd_node_from_string(SERD_LITERAL, name);
const SerdNode uri_node = serd_node_from_string(SERD_URI, uri);
@@ -179,6 +185,10 @@ serd_env_qualify(const SerdEnv* const env,
SerdNode* const prefix,
SerdChunk* const suffix)
{
+ assert(uri);
+ assert(prefix);
+ assert(suffix);
+
if (!env) {
return false;
}
@@ -205,6 +215,10 @@ serd_env_expand(const SerdEnv* const env,
SerdChunk* const uri_prefix,
SerdChunk* const uri_suffix)
{
+ assert(curie);
+ assert(uri_prefix);
+ assert(uri_suffix);
+
if (!env) {
return SERD_ERR_BAD_CURIE;
}
@@ -230,6 +244,8 @@ serd_env_expand(const SerdEnv* const env,
SerdNode
serd_env_expand_node(const SerdEnv* const env, const SerdNode* const node)
{
+ assert(node);
+
if (!env) {
return SERD_NODE_NULL;
}
diff --git a/src/reader.c b/src/reader.c
index 1936808a..aa24a9ca 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -200,6 +200,7 @@ serd_reader_new(const SerdSyntax syntax,
void
serd_reader_set_strict(SerdReader* const reader, const bool strict)
{
+ assert(reader);
reader->strict = strict;
}
@@ -208,6 +209,7 @@ serd_reader_set_error_sink(SerdReader* const reader,
const SerdErrorSink error_sink,
void* const error_handle)
{
+ assert(reader);
reader->error_sink = error_sink;
reader->error_handle = error_handle;
}
@@ -392,6 +394,9 @@ serd_reader_read_file_handle(SerdReader* const reader,
FILE* const file,
const uint8_t* const name)
{
+ assert(reader);
+ assert(file);
+
return serd_reader_read_source(reader,
(SerdSource)fread,
(SerdStreamErrorFunc)ferror,
diff --git a/src/string.c b/src/string.c
index 52fb4a91..b2946aac 100644
--- a/src/string.c
+++ b/src/string.c
@@ -91,6 +91,8 @@ serd_strlen(const uint8_t* const str,
size_t* const n_bytes,
SerdNodeFlags* const flags)
{
+ assert(str);
+
size_t n_chars = 0;
size_t i = 0;
SerdNodeFlags f = 0;
diff --git a/src/uri.c b/src/uri.c
index 443069ec..9856ce45 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -430,7 +430,6 @@ serd_uri_serialise_relative(const SerdURI* const uri,
{
assert(uri);
assert(sink);
- assert(stream);
size_t len = 0;
const bool relative =
@@ -484,7 +483,7 @@ serd_uri_serialise_relative(const SerdURI* const uri,
size_t
serd_uri_serialise(const SerdURI* const uri, SerdSink sink, void* const stream)
{
+ assert(uri);
assert(sink);
- assert(stream);
return serd_uri_serialise_relative(uri, NULL, NULL, sink, stream);
}
diff --git a/src/writer.c b/src/writer.c
index 58d7e64f..2b127d04 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -946,6 +946,9 @@ serd_writer_write_statement(SerdWriter* writer,
const SerdNode* lang)
{
assert(writer);
+ assert(subject);
+ assert(predicate);
+ assert(object);
SerdStatus st = SERD_SUCCESS;
@@ -1145,7 +1148,7 @@ serd_writer_new(SerdSyntax syntax,
void* stream)
{
assert(env);
- assert(sink);
+ assert(ssink);
const WriteContext context = WRITE_CONTEXT_NULL;
SerdWriter* writer = (SerdWriter*)calloc(1, sizeof(SerdWriter));
@@ -1239,6 +1242,10 @@ serd_writer_set_prefix(SerdWriter* writer,
const SerdNode* name,
const SerdNode* uri)
{
+ assert(writer);
+ assert(name);
+ assert(uri);
+
SerdStatus st = SERD_SUCCESS;
TRY(st, serd_env_set_prefix(writer->env, name, uri));