From a3fd8b05a7b062256dd298d929fb99f8f3757f73 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 27 Sep 2024 18:38:19 -0400 Subject: Make more pointer variables const --- src/n3.c | 10 +++++----- src/reader.c | 4 ++-- src/writer.c | 4 ++-- test/test_reader_writer.c | 5 +++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/n3.c b/src/n3.c index b3cfbb8a..460e0e9d 100644 --- a/src/n3.c +++ b/src/n3.c @@ -925,10 +925,10 @@ read_verb(SerdReader* const reader, Ref* const dest) */ *dest = push_node(reader, SERD_CURIE, "", 0); - SerdStatus st = read_PN_PREFIX(reader, *dest); - bool ate_dot = false; - SerdNode* node = deref(reader, *dest); - const int next = peek_byte(reader); + SerdStatus st = read_PN_PREFIX(reader, *dest); + bool ate_dot = false; + const SerdNode* const node = deref(reader, *dest); + const int next = peek_byte(reader); if (!st && node->n_bytes == 1 && node->buf[0] == 'a' && next != ':' && !is_PN_CHARS_BASE((uint32_t)next)) { pop_node(reader, *dest); @@ -1540,7 +1540,7 @@ token_equals(SerdReader* const reader, const char* const tok, const size_t n) { - SerdNode* const node = deref(reader, ref); + const SerdNode* const node = deref(reader, ref); if (!node || node->n_bytes != n) { return false; } diff --git a/src/reader.c b/src/reader.c index aa24a9ca..5cd978bf 100644 --- a/src/reader.c +++ b/src/reader.c @@ -127,8 +127,8 @@ pop_node(SerdReader* const reader, const Ref ref) SERD_STACK_ASSERT_TOP(reader, ref); --reader->n_allocs; #endif - SerdNode* const node = deref(reader, ref); - uint8_t* const top = reader->stack.buf + reader->stack.size; + SerdNode* const node = deref(reader, ref); + const uint8_t* const top = reader->stack.buf + reader->stack.size; serd_stack_pop_aligned(&reader->stack, (size_t)(top - (uint8_t*)node)); } return 0; diff --git a/src/writer.c b/src/writer.c index 0df44797..3905cb9c 100644 --- a/src/writer.c +++ b/src/writer.c @@ -745,8 +745,8 @@ write_uri_node(SerdWriter* const writer, serd_uri_parse(node->buf, &uri); SERD_RESTORE_WARNINGS serd_uri_resolve(&uri, &in_base_uri, &abs_uri); - bool rooted = uri_is_under(&writer->base_uri, &writer->root_uri); - SerdURI* root = rooted ? &writer->root_uri : &writer->base_uri; + const bool rooted = uri_is_under(&writer->base_uri, &writer->root_uri); + const SerdURI* root = rooted ? &writer->root_uri : &writer->base_uri; UriSinkContext ctx = {writer, SERD_SUCCESS}; if (!uri_is_under(&abs_uri, root) || writer->syntax == SERD_NTRIPLES || writer->syntax == SERD_NQUADS) { diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c index 6b84b1e6..515d5e5b 100644 --- a/test/test_reader_writer.c +++ b/test/test_reader_writer.c @@ -164,8 +164,9 @@ test_writer(const char* const path) assert(serd_writer_end_anon(writer, NULL)); assert(serd_writer_get_env(writer) == env); - uint8_t buf[] = {0x80, 0, 0, 0, 0}; - SerdNode s = serd_node_from_string(SERD_URI, USTR("")); + const uint8_t buf[] = {0x80, 0, 0, 0, 0}; + + SerdNode s = serd_node_from_string(SERD_URI, USTR("")); SerdNode p = serd_node_from_string(SERD_URI, USTR("http://example.org/pred")); SerdNode o = serd_node_from_string(SERD_LITERAL, buf); -- cgit v1.2.1