diff options
author | David Robillard <d@drobilla.net> | 2024-09-27 13:06:20 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-09-27 18:16:57 -0400 |
commit | 287e07ebaa5fbcf9be0ce0cb1981798fc04bc9f1 (patch) | |
tree | 727a8a5e95e37f5c679d6391254913f3d9303b7b /test | |
parent | 771215229522e203eba802bc041a1d8105de9283 (diff) | |
download | serd-287e07ebaa5fbcf9be0ce0cb1981798fc04bc9f1.tar.gz serd-287e07ebaa5fbcf9be0ce0cb1981798fc04bc9f1.tar.bz2 serd-287e07ebaa5fbcf9be0ce0cb1981798fc04bc9f1.zip |
Make function parameters const wherever possible
The early history of this code didn't tend to make parameters const, but the
"const density" is high enough now that I often find myself wondering if
something is mutable for some reason, or just old and sloppier. So, eliminate
this confusion by making (hopefully) all function parameters const if possible.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_env.c | 4 | ||||
-rw-r--r-- | test/test_node.c | 2 | ||||
-rw-r--r-- | test/test_reader.c | 7 | ||||
-rw-r--r-- | test/test_reader_writer.c | 18 | ||||
-rw-r--r-- | test/test_uri.c | 2 |
5 files changed, 19 insertions, 14 deletions
diff --git a/test/test_env.c b/test/test_env.c index d51e0595..903ae3f2 100644 --- a/test/test_env.c +++ b/test/test_env.c @@ -13,7 +13,9 @@ #define USTR(s) ((const uint8_t*)(s)) static SerdStatus -count_prefixes(void* handle, const SerdNode* name, const SerdNode* uri) +count_prefixes(void* const handle, + const SerdNode* const name, + const SerdNode* const uri) { (void)name; (void)uri; diff --git a/test/test_node.c b/test/test_node.c index 574c10d3..28db00ea 100644 --- a/test/test_node.c +++ b/test/test_node.c @@ -24,7 +24,7 @@ #endif static void -check_strtod(double dbl, double max_delta) +check_strtod(const double dbl, const double max_delta) { char buf[1024]; snprintf(buf, sizeof(buf), "%f", dbl); diff --git a/test/test_reader.c b/test/test_reader.c index 9e2edd17..e185b915 100644 --- a/test/test_reader.c +++ b/test/test_reader.c @@ -108,7 +108,10 @@ test_read_string(void) /// Reads a null byte after a statement, then succeeds again (like a socket) static size_t -eof_test_read(void* buf, size_t size, size_t nmemb, void* stream) +eof_test_read(void* const buf, + const size_t size, + const size_t nmemb, + void* const stream) { assert(size == 1); assert(nmemb == 1); @@ -144,7 +147,7 @@ eof_test_read(void* buf, size_t size, size_t nmemb, void* stream) } static int -eof_test_error(void* stream) +eof_test_error(void* const stream) { (void)stream; return 0; diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c index 0ed26794..6b84b1e6 100644 --- a/test/test_reader_writer.c +++ b/test/test_reader_writer.c @@ -54,14 +54,14 @@ static const char* const doc_string = "( eg:o ) eg:t eg:u .\n"; static SerdStatus -test_statement_sink(void* handle, - SerdStatementFlags flags, - const SerdNode* graph, - const SerdNode* subject, - const SerdNode* predicate, - const SerdNode* object, - const SerdNode* object_datatype, - const SerdNode* object_lang) +test_statement_sink(void* const handle, + const SerdStatementFlags flags, + const SerdNode* const graph, + const SerdNode* const subject, + const SerdNode* const predicate, + const SerdNode* const object, + const SerdNode* const object_datatype, + const SerdNode* const object_lang) { (void)flags; (void)subject; @@ -264,7 +264,7 @@ test_writer(const char* const path) } static void -test_reader(const char* path) +test_reader(const char* const path) { ReaderTest* rt = (ReaderTest*)calloc(1, sizeof(ReaderTest)); SerdReader* reader = serd_reader_new( diff --git a/test/test_uri.c b/test/test_uri.c index 1c440a30..7315a0fc 100644 --- a/test/test_uri.c +++ b/test/test_uri.c @@ -207,7 +207,7 @@ test_uri_from_string(void) } static inline bool -chunk_equals(const SerdChunk* a, const SerdChunk* b) +chunk_equals(const SerdChunk* const a, const SerdChunk* const b) { return (!a->len && !b->len && !a->buf && !b->buf) || (a->len && b->len && a->buf && b->buf && |