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 | |
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.
-rw-r--r-- | src/byte_sink.h | 8 | ||||
-rw-r--r-- | src/byte_source.h | 4 | ||||
-rw-r--r-- | src/node.h | 4 | ||||
-rw-r--r-- | src/reader.h | 17 | ||||
-rw-r--r-- | src/serd_internal.h | 4 | ||||
-rw-r--r-- | src/stack.h | 16 | ||||
-rw-r--r-- | src/uri.c | 14 | ||||
-rw-r--r-- | src/uri_utils.h | 12 | ||||
-rw-r--r-- | src/writer.c | 169 | ||||
-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 |
14 files changed, 151 insertions, 130 deletions
diff --git a/src/byte_sink.h b/src/byte_sink.h index 65b5eb12..b99b5551 100644 --- a/src/byte_sink.h +++ b/src/byte_sink.h @@ -22,7 +22,7 @@ typedef struct SerdByteSinkImpl { } SerdByteSink; static inline SerdByteSink -serd_byte_sink_new(SerdSink sink, void* stream, size_t block_size) +serd_byte_sink_new(SerdSink sink, void* const stream, const size_t block_size) { SerdByteSink bsink = {sink, stream, NULL, 0, block_size}; @@ -34,7 +34,7 @@ serd_byte_sink_new(SerdSink sink, void* stream, size_t block_size) } static inline SerdStatus -serd_byte_sink_flush(SerdByteSink* bsink) +serd_byte_sink_flush(SerdByteSink* const bsink) { if (bsink->block_size > 1 && bsink->size > 0) { const size_t size = bsink->size; @@ -48,7 +48,7 @@ serd_byte_sink_flush(SerdByteSink* bsink) } static inline void -serd_byte_sink_free(SerdByteSink* bsink) +serd_byte_sink_free(SerdByteSink* const bsink) { serd_byte_sink_flush(bsink); serd_free_aligned(bsink->buf); @@ -56,7 +56,7 @@ serd_byte_sink_free(SerdByteSink* bsink) } static inline size_t -serd_byte_sink_write(const void* buf, size_t len, SerdByteSink* bsink) +serd_byte_sink_write(const void* buf, size_t len, SerdByteSink* const bsink) { if (len == 0) { return 0; diff --git a/src/byte_source.h b/src/byte_source.h index afd9ccb9..961fae72 100644 --- a/src/byte_source.h +++ b/src/byte_source.h @@ -58,14 +58,14 @@ SerdStatus serd_byte_source_page(SerdByteSource* source); static inline SERD_PURE_FUNC uint8_t -serd_byte_source_peek(SerdByteSource* source) +serd_byte_source_peek(SerdByteSource* const source) { assert(source->prepared); return source->read_buf[source->read_head]; } static inline SerdStatus -serd_byte_source_advance(SerdByteSource* source) +serd_byte_source_advance(SerdByteSource* const source) { SerdStatus st = SERD_SUCCESS; @@ -15,13 +15,13 @@ struct SerdNodeImpl { }; static inline char* SERD_NONNULL -serd_node_buffer(SerdNode* SERD_NONNULL node) +serd_node_buffer(SerdNode* const SERD_NONNULL node) { return (char*)(node + 1); } static inline const char* SERD_NONNULL -serd_node_buffer_c(const SerdNode* SERD_NONNULL node) +serd_node_buffer_c(const SerdNode* const SERD_NONNULL node) { return (const char*)(node + 1); } diff --git a/src/reader.h b/src/reader.h index 7768f3b6..a867ffc0 100644 --- a/src/reader.h +++ b/src/reader.h @@ -110,7 +110,7 @@ SerdStatus read_turtleTrigDoc(SerdReader* reader); static inline int -peek_byte(SerdReader* reader) +peek_byte(SerdReader* const reader) { SerdByteSource* source = &reader->source; @@ -118,7 +118,7 @@ peek_byte(SerdReader* reader) } static inline SerdStatus -skip_byte(SerdReader* reader, const int byte) +skip_byte(SerdReader* const reader, const int byte) { (void)byte; @@ -128,7 +128,7 @@ skip_byte(SerdReader* reader, const int byte) } static inline int SERD_NODISCARD -eat_byte_safe(SerdReader* reader, const int byte) +eat_byte_safe(SerdReader* const reader, const int byte) { (void)byte; @@ -139,7 +139,7 @@ eat_byte_safe(SerdReader* reader, const int byte) } static inline int SERD_NODISCARD -eat_byte_check(SerdReader* reader, const int byte) +eat_byte_check(SerdReader* const reader, const int byte) { const int c = peek_byte(reader); if (c != byte) { @@ -150,7 +150,7 @@ eat_byte_check(SerdReader* reader, const int byte) } static inline SerdStatus -eat_string(SerdReader* reader, const char* str, unsigned n) +eat_string(SerdReader* const reader, const char* const str, const unsigned n) { for (unsigned i = 0; i < n; ++i) { if (!eat_byte_check(reader, ((const uint8_t*)str)[i])) { @@ -161,7 +161,7 @@ eat_string(SerdReader* reader, const char* str, unsigned n) } static inline SerdStatus -push_byte(SerdReader* reader, Ref ref, const int c) +push_byte(SerdReader* const reader, const Ref ref, const int c) { assert(c >= 0); SERD_STACK_ASSERT_TOP(reader, ref); @@ -180,7 +180,10 @@ push_byte(SerdReader* reader, Ref ref, const int c) } static inline void -push_bytes(SerdReader* reader, Ref ref, const uint8_t* bytes, unsigned len) +push_bytes(SerdReader* const reader, + const Ref ref, + const uint8_t* const bytes, + const unsigned len) { for (unsigned i = 0; i < len; ++i) { push_byte(reader, ref, bytes[i]); diff --git a/src/serd_internal.h b/src/serd_internal.h index 388c12ec..5508c111 100644 --- a/src/serd_internal.h +++ b/src/serd_internal.h @@ -20,7 +20,9 @@ /* Error reporting */ static inline void -serd_error(SerdErrorSink error_sink, void* handle, const SerdError* e) +serd_error(const SerdErrorSink error_sink, + void* const handle, + const SerdError* const e) { if (error_sink) { error_sink(handle, e); diff --git a/src/stack.h b/src/stack.h index 388dd054..f82de9d2 100644 --- a/src/stack.h +++ b/src/stack.h @@ -24,7 +24,7 @@ typedef struct { #define SERD_STACK_BOTTOM sizeof(void*) static inline SerdStack -serd_stack_new(size_t size) +serd_stack_new(const size_t size) { SerdStack stack; stack.buf = (uint8_t*)calloc(size, 1); @@ -34,13 +34,13 @@ serd_stack_new(size_t size) } static inline bool -serd_stack_is_empty(const SerdStack* stack) +serd_stack_is_empty(const SerdStack* const stack) { return stack->size <= SERD_STACK_BOTTOM; } static inline void -serd_stack_free(SerdStack* stack) +serd_stack_free(SerdStack* const stack) { free(stack->buf); stack->buf = NULL; @@ -49,7 +49,7 @@ serd_stack_free(SerdStack* stack) } static inline void* -serd_stack_push(SerdStack* stack, size_t n_bytes) +serd_stack_push(SerdStack* const stack, const size_t n_bytes) { const size_t new_size = stack->size + n_bytes; if (stack->buf_size < new_size) { @@ -64,14 +64,16 @@ serd_stack_push(SerdStack* stack, size_t n_bytes) } static inline void -serd_stack_pop(SerdStack* stack, size_t n_bytes) +serd_stack_pop(SerdStack* const stack, const size_t n_bytes) { assert(stack->size >= n_bytes); stack->size -= n_bytes; } static inline void* -serd_stack_push_aligned(SerdStack* stack, size_t n_bytes, size_t align) +serd_stack_push_aligned(SerdStack* const stack, + const size_t n_bytes, + const size_t align) { // Push one byte to ensure space for a pad count serd_stack_push(stack, 1); @@ -89,7 +91,7 @@ serd_stack_push_aligned(SerdStack* stack, size_t n_bytes, size_t align) } static inline void -serd_stack_pop_aligned(SerdStack* stack, size_t n_bytes) +serd_stack_pop_aligned(SerdStack* const stack, const size_t n_bytes) { // Pop requested space down to aligned location serd_stack_pop(stack, n_bytes); @@ -15,7 +15,7 @@ #include <string.h> const uint8_t* -serd_uri_to_path(const uint8_t* uri) +serd_uri_to_path(const uint8_t* const uri) { assert(uri); @@ -344,7 +344,7 @@ serd_uri_resolve(const SerdURI* const r, /** Write the path of `uri` starting at index `i` */ static size_t -write_path_tail(SerdSink sink, +write_path_tail(const SerdSink sink, void* const stream, const SerdURI* const uri, const size_t i) @@ -372,7 +372,7 @@ write_path_tail(SerdSink sink, /** Write the path of `uri` relative to the path of `base`. */ static size_t -write_rel_path(SerdSink sink, +write_rel_path(const SerdSink sink, void* const stream, const SerdURI* const uri, const SerdURI* const base) @@ -413,7 +413,7 @@ write_rel_path(SerdSink sink, } static uint8_t -serd_uri_path_starts_without_slash(const SerdURI* uri) +serd_uri_path_starts_without_slash(const SerdURI* const uri) { return ((uri->path_base.len || uri->path.len) && ((!uri->path_base.len || uri->path_base.buf[0] != '/') && @@ -425,7 +425,7 @@ size_t serd_uri_serialise_relative(const SerdURI* const uri, const SerdURI* const base, const SerdURI* const root, - SerdSink sink, + const SerdSink sink, void* const stream) { assert(uri); @@ -481,7 +481,9 @@ serd_uri_serialise_relative(const SerdURI* const uri, /// See http://tools.ietf.org/html/rfc3986#section-5.3 size_t -serd_uri_serialise(const SerdURI* const uri, SerdSink sink, void* const stream) +serd_uri_serialise(const SerdURI* const uri, + const SerdSink sink, + void* const stream) { assert(uri); assert(sink); diff --git a/src/uri_utils.h b/src/uri_utils.h index 0d3bd74e..4005b47d 100644 --- a/src/uri_utils.h +++ b/src/uri_utils.h @@ -18,20 +18,20 @@ typedef struct { } SlashIndexes; 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 && !strncmp((const char*)a->buf, (const char*)b->buf, a->len); } static inline size_t -uri_path_len(const SerdURI* uri) +uri_path_len(const SerdURI* const uri) { return uri->path_base.len + uri->path.len; } static inline uint8_t -uri_path_at(const SerdURI* uri, size_t i) +uri_path_at(const SerdURI* const uri, const size_t i) { return (i < uri->path_base.len) ? uri->path_base.buf[i] : uri->path.buf[i - uri->path_base.len]; @@ -46,7 +46,7 @@ uri_path_at(const SerdURI* uri, size_t i) otherwise it may merely share some leading path components). */ static inline SERD_PURE_FUNC SlashIndexes -uri_rooted_index(const SerdURI* uri, const SerdURI* root) +uri_rooted_index(const SerdURI* const uri, const SerdURI* const root) { SlashIndexes indexes = {SIZE_MAX, SIZE_MAX}; @@ -84,14 +84,14 @@ uri_rooted_index(const SerdURI* uri, const SerdURI* root) /** Return true iff `uri` shares path components with `root` */ static inline SERD_PURE_FUNC bool -uri_is_related(const SerdURI* uri, const SerdURI* root) +uri_is_related(const SerdURI* const uri, const SerdURI* const root) { return uri_rooted_index(uri, root).shared != SIZE_MAX; } /** Return true iff `uri` is within the base of `root` */ static inline SERD_PURE_FUNC bool -uri_is_under(const SerdURI* uri, const SerdURI* root) +uri_is_under(const SerdURI* const uri, const SerdURI* const root) { const SlashIndexes indexes = uri_rooted_index(uri, root); return indexes.shared && indexes.shared != SIZE_MAX && diff --git a/src/writer.c b/src/writer.c index c75d3fb7..0df44797 100644 --- a/src/writer.c +++ b/src/writer.c @@ -143,7 +143,7 @@ write_node(SerdWriter* writer, SerdStatementFlags flags); SERD_NODISCARD static bool -supports_abbrev(const SerdWriter* writer) +supports_abbrev(const SerdWriter* const writer) { return writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG; } @@ -162,7 +162,7 @@ free_context(WriteContext* const ctx) SERD_LOG_FUNC(3, 4) static SerdStatus -w_err(SerdWriter* writer, SerdStatus st, const char* fmt, ...) +w_err(SerdWriter* const writer, const SerdStatus st, const char* const fmt, ...) { /* TODO: This results in errors with no file information, which is not helpful when re-serializing a file (particularly for "undefined @@ -179,7 +179,7 @@ w_err(SerdWriter* writer, SerdStatus st, const char* fmt, ...) } static void -copy_node(SerdNode* dst, const SerdNode* src) +copy_node(SerdNode* const dst, const SerdNode* const src) { const size_t new_size = src->n_bytes + 1U; uint8_t* const new_buf = (uint8_t*)realloc((char*)dst->buf, new_size); @@ -210,7 +210,7 @@ push_context(SerdWriter* const writer, } static void -pop_context(SerdWriter* writer) +pop_context(SerdWriter* const writer) { // Replace the current context with the top of the stack free_context(&writer->context); @@ -223,7 +223,7 @@ pop_context(SerdWriter* writer) } SERD_NODISCARD static size_t -sink(const void* buf, size_t len, SerdWriter* writer) +sink(const void* const buf, const size_t len, SerdWriter* const writer) { const size_t written = serd_byte_sink_write(buf, len, &writer->byte_sink); if (written != len) { @@ -239,7 +239,7 @@ sink(const void* buf, size_t len, SerdWriter* writer) } SERD_NODISCARD static inline SerdStatus -esink(const void* buf, size_t len, SerdWriter* writer) +esink(const void* const buf, const size_t len, SerdWriter* const writer) { return sink(buf, len, writer) == len ? SERD_SUCCESS : SERD_ERR_BAD_WRITE; } @@ -247,10 +247,10 @@ esink(const void* buf, size_t len, SerdWriter* writer) // Write a single character, as an escape for single byte characters // (Caller prints any single byte characters that don't need escaping) static size_t -write_character(SerdWriter* writer, - const uint8_t* utf8, - uint8_t* size, - SerdStatus* st) +write_character(SerdWriter* const writer, + const uint8_t* const utf8, + uint8_t* const size, + SerdStatus* const st) { char escape[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; const uint32_t c = parse_utf8_char(utf8, size); @@ -288,10 +288,10 @@ uri_must_escape(const uint8_t c) } static size_t -write_uri(SerdWriter* writer, - const uint8_t* utf8, - size_t n_bytes, - SerdStatus* st) +write_uri(SerdWriter* const writer, + const uint8_t* const utf8, + const size_t n_bytes, + SerdStatus* const st) { size_t len = 0; for (size_t i = 0; i < n_bytes;) { @@ -336,7 +336,9 @@ write_uri(SerdWriter* writer, } SERD_NODISCARD static SerdStatus -ewrite_uri(SerdWriter* writer, const uint8_t* utf8, size_t n_bytes) +ewrite_uri(SerdWriter* const writer, + const uint8_t* const utf8, + const size_t n_bytes) { SerdStatus st = SERD_SUCCESS; write_uri(writer, utf8, n_bytes, &st); @@ -347,7 +349,7 @@ ewrite_uri(SerdWriter* writer, const uint8_t* utf8, size_t n_bytes) } SERD_NODISCARD static SerdStatus -write_uri_from_node(SerdWriter* writer, const SerdNode* node) +write_uri_from_node(SerdWriter* const writer, const SerdNode* const node) { return ewrite_uri(writer, node->buf, node->n_bytes); } @@ -369,7 +371,9 @@ lname_must_escape(const uint8_t c) } SERD_NODISCARD static SerdStatus -write_lname(SerdWriter* writer, const uint8_t* utf8, size_t n_bytes) +write_lname(SerdWriter* const writer, + const uint8_t* const utf8, + const size_t n_bytes) { SerdStatus st = SERD_SUCCESS; for (size_t i = 0; i < n_bytes; ++i) { @@ -395,10 +399,10 @@ write_lname(SerdWriter* writer, const uint8_t* utf8, size_t n_bytes) } SERD_NODISCARD static SerdStatus -write_text(SerdWriter* writer, - TextContext ctx, - const uint8_t* utf8, - size_t n_bytes) +write_text(SerdWriter* const writer, + const TextContext ctx, + const uint8_t* const utf8, + const size_t n_bytes) { size_t n_consecutive_quotes = 0; SerdStatus st = SERD_SUCCESS; @@ -509,7 +513,7 @@ typedef struct { } UriSinkContext; SERD_NODISCARD static size_t -uri_sink(const void* buf, size_t len, void* stream) +uri_sink(const void* const buf, const size_t len, void* const stream) { UriSinkContext* const context = (UriSinkContext*)stream; SerdWriter* const writer = context->writer; @@ -518,7 +522,7 @@ uri_sink(const void* buf, size_t len, void* stream) } SERD_NODISCARD static SerdStatus -write_newline(SerdWriter* writer) +write_newline(SerdWriter* const writer) { SerdStatus st = SERD_SUCCESS; @@ -531,7 +535,7 @@ write_newline(SerdWriter* writer) } SERD_NODISCARD static SerdStatus -write_sep(SerdWriter* writer, const Sep sep) +write_sep(SerdWriter* const writer, const Sep sep) { SerdStatus st = SERD_SUCCESS; const SepRule* const rule = &rules[sep]; @@ -585,7 +589,7 @@ write_sep(SerdWriter* writer, const Sep sep) } static void -free_anon_stack(SerdWriter* writer) +free_anon_stack(SerdWriter* const writer) { while (!serd_stack_is_empty(&writer->anon_stack)) { pop_context(writer); @@ -593,7 +597,7 @@ free_anon_stack(SerdWriter* writer) } static SerdStatus -reset_context(SerdWriter* writer, const unsigned flags) +reset_context(SerdWriter* const writer, const unsigned flags) { free_anon_stack(writer); @@ -639,11 +643,11 @@ get_xsd_name(const SerdEnv* const env, const SerdNode* const datatype) } SERD_NODISCARD static SerdStatus -write_literal(SerdWriter* writer, - const SerdNode* node, - const SerdNode* datatype, - const SerdNode* lang, - SerdStatementFlags flags) +write_literal(SerdWriter* const writer, + const SerdNode* const node, + const SerdNode* const datatype, + const SerdNode* const lang, + const SerdStatementFlags flags) { SerdStatus st = SERD_SUCCESS; @@ -679,7 +683,7 @@ write_literal(SerdWriter* writer, // Return true iff `buf` is a valid prefixed name prefix or suffix static bool -is_name(const uint8_t* buf, const size_t len) +is_name(const uint8_t* const buf, const size_t len) { // TODO: This is more strict than it should be for (size_t i = 0; i < len; ++i) { @@ -692,9 +696,9 @@ is_name(const uint8_t* buf, const size_t len) } SERD_NODISCARD static SerdStatus -write_uri_node(SerdWriter* const writer, - const SerdNode* node, - const Field field) +write_uri_node(SerdWriter* const writer, + const SerdNode* const node, + const Field field) { SerdStatus st = SERD_SUCCESS; SerdNode prefix = SERD_NODE_NULL; @@ -789,7 +793,7 @@ write_curie(SerdWriter* const writer, const SerdNode* const node) SERD_NODISCARD static SerdStatus write_blank(SerdWriter* const writer, - const SerdNode* node, + const SerdNode* const node, const Field field, const SerdStatementFlags flags) { @@ -828,12 +832,12 @@ write_blank(SerdWriter* const writer, } SERD_NODISCARD static SerdStatus -write_node(SerdWriter* writer, - const SerdNode* node, - const SerdNode* datatype, - const SerdNode* lang, - Field field, - SerdStatementFlags flags) +write_node(SerdWriter* const writer, + const SerdNode* const node, + const SerdNode* const datatype, + const SerdNode* const lang, + const Field field, + const SerdStatementFlags flags) { return (node->type == SERD_LITERAL) ? write_literal(writer, node, datatype, lang, flags) @@ -844,13 +848,15 @@ write_node(SerdWriter* writer, } static bool -is_resource(const SerdNode* node) +is_resource(const SerdNode* const node) { return node->buf && node->type > SERD_LITERAL; } SERD_NODISCARD static SerdStatus -write_pred(SerdWriter* writer, SerdStatementFlags flags, const SerdNode* pred) +write_pred(SerdWriter* const writer, + const SerdStatementFlags flags, + const SerdNode* const pred) { SerdStatus st = SERD_SUCCESS; @@ -864,12 +870,12 @@ write_pred(SerdWriter* writer, SerdStatementFlags flags, const SerdNode* pred) } SERD_NODISCARD static SerdStatus -write_list_next(SerdWriter* writer, - SerdStatementFlags flags, - const SerdNode* predicate, - const SerdNode* object, - const SerdNode* datatype, - const SerdNode* lang) +write_list_next(SerdWriter* const writer, + const SerdStatementFlags flags, + const SerdNode* const predicate, + const SerdNode* const object, + const SerdNode* const datatype, + const SerdNode* const lang) { SerdStatus st = SERD_SUCCESS; @@ -888,7 +894,7 @@ write_list_next(SerdWriter* writer, } SERD_NODISCARD static SerdStatus -terminate_context(SerdWriter* writer) +terminate_context(SerdWriter* const writer) { SerdStatus st = SERD_SUCCESS; @@ -904,14 +910,14 @@ terminate_context(SerdWriter* writer) } SerdStatus -serd_writer_write_statement(SerdWriter* writer, - SerdStatementFlags flags, - const SerdNode* graph, - const SerdNode* subject, - const SerdNode* predicate, - const SerdNode* object, - const SerdNode* datatype, - const SerdNode* lang) +serd_writer_write_statement(SerdWriter* const writer, + SerdStatementFlags flags, + const SerdNode* const graph, + const SerdNode* const subject, + const SerdNode* const predicate, + const SerdNode* const object, + const SerdNode* const datatype, + const SerdNode* const lang) { assert(writer); assert(subject); @@ -1064,7 +1070,7 @@ serd_writer_write_statement(SerdWriter* writer, } SerdStatus -serd_writer_end_anon(SerdWriter* writer, const SerdNode* node) +serd_writer_end_anon(SerdWriter* const writer, const SerdNode* const node) { assert(writer); @@ -1095,7 +1101,7 @@ serd_writer_end_anon(SerdWriter* writer, const SerdNode* node) } SerdStatus -serd_writer_finish(SerdWriter* writer) +serd_writer_finish(SerdWriter* const writer) { assert(writer); @@ -1107,12 +1113,12 @@ serd_writer_finish(SerdWriter* writer) } SerdWriter* -serd_writer_new(SerdSyntax syntax, - SerdStyle style, - SerdEnv* env, - const SerdURI* base_uri, - SerdSink ssink, - void* stream) +serd_writer_new(const SerdSyntax syntax, + const SerdStyle style, + SerdEnv* const env, + const SerdURI* const base_uri, + SerdSink ssink, + void* const stream) { assert(env); assert(ssink); @@ -1135,9 +1141,9 @@ serd_writer_new(SerdSyntax syntax, } void -serd_writer_set_error_sink(SerdWriter* writer, - SerdErrorSink error_sink, - void* error_handle) +serd_writer_set_error_sink(SerdWriter* const writer, + const SerdErrorSink error_sink, + void* const error_handle) { assert(writer); assert(error_sink); @@ -1146,7 +1152,8 @@ serd_writer_set_error_sink(SerdWriter* writer, } void -serd_writer_chop_blank_prefix(SerdWriter* writer, const uint8_t* prefix) +serd_writer_chop_blank_prefix(SerdWriter* const writer, + const uint8_t* const prefix) { assert(writer); @@ -1163,7 +1170,7 @@ serd_writer_chop_blank_prefix(SerdWriter* writer, const uint8_t* prefix) } SerdStatus -serd_writer_set_base_uri(SerdWriter* writer, const SerdNode* uri) +serd_writer_set_base_uri(SerdWriter* const writer, const SerdNode* const uri) { assert(writer); @@ -1185,7 +1192,7 @@ serd_writer_set_base_uri(SerdWriter* writer, const SerdNode* uri) } SerdStatus -serd_writer_set_root_uri(SerdWriter* writer, const SerdNode* uri) +serd_writer_set_root_uri(SerdWriter* const writer, const SerdNode* const uri) { assert(writer); @@ -1205,9 +1212,9 @@ serd_writer_set_root_uri(SerdWriter* writer, const SerdNode* uri) } SerdStatus -serd_writer_set_prefix(SerdWriter* writer, - const SerdNode* name, - const SerdNode* uri) +serd_writer_set_prefix(SerdWriter* const writer, + const SerdNode* const name, + const SerdNode* const uri) { assert(writer); assert(name); @@ -1231,7 +1238,7 @@ serd_writer_set_prefix(SerdWriter* writer, } void -serd_writer_free(SerdWriter* writer) +serd_writer_free(SerdWriter* const writer) { if (!writer) { return; @@ -1250,14 +1257,14 @@ serd_writer_free(SerdWriter* writer) } SerdEnv* -serd_writer_get_env(SerdWriter* writer) +serd_writer_get_env(SerdWriter* const writer) { assert(writer); return writer->env; } size_t -serd_file_sink(const void* buf, size_t len, void* stream) +serd_file_sink(const void* const buf, const size_t len, void* const stream) { assert(buf); assert(stream); @@ -1265,7 +1272,7 @@ serd_file_sink(const void* buf, size_t len, void* stream) } size_t -serd_chunk_sink(const void* buf, size_t len, void* stream) +serd_chunk_sink(const void* const buf, const size_t len, void* const stream) { assert(buf); assert(stream); @@ -1281,7 +1288,7 @@ serd_chunk_sink(const void* buf, size_t len, void* stream) } uint8_t* -serd_chunk_sink_finish(SerdChunk* stream) +serd_chunk_sink_finish(SerdChunk* const stream) { assert(stream); serd_chunk_sink("", 1, stream); 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 && |