From 117ae267046ed564684793270b82767c585c724b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 9 Jan 2024 21:09:56 -0500 Subject: Avoid regressions in clang nullability checks Clang 15 (and still as of 16) lost the ability to understand null checks in conditionals, which is supposed to suppress these warnings. For now, work around some, and suppress others. The suppression boilerplate here is noisy and ugly, and hopefully temporary. It should be removed once the issue is fixed in clang. See https://github.com/llvm/llvm-project/issues/63018 --- test/test_node.c | 8 +++++--- test/test_uri.c | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/test_node.c b/test/test_node.c index 67958cc5..f08363cb 100644 --- a/test/test_node.c +++ b/test/test_node.c @@ -121,14 +121,16 @@ test_blob_to_node(void) data[i] = (uint8_t)((size + i) % 256); } - SerdNode blob = serd_node_new_blob(data, size, size % 5); + SerdNode blob = serd_node_new_blob(data, size, size % 5); + const uint8_t* const blob_str = blob.buf; + assert(blob_str); assert(blob.n_bytes == blob.n_chars); - assert(blob.n_bytes == strlen((const char*)blob.buf)); + assert(blob.n_bytes == strlen((const char*)blob_str)); size_t out_size = 0; uint8_t* out = - (uint8_t*)serd_base64_decode(blob.buf, blob.n_bytes, &out_size); + (uint8_t*)serd_base64_decode(blob_str, blob.n_bytes, &out_size); assert(out_size == size); for (size_t i = 0; i < size; ++i) { diff --git a/test/test_uri.c b/test/test_uri.c index ac24a2be..cc81b40e 100644 --- a/test/test_uri.c +++ b/test/test_uri.c @@ -48,7 +48,9 @@ test_file_uri(const char* const hostname, SerdNode node = serd_node_new_file_uri(USTR(path), USTR(hostname), 0, escape); uint8_t* out_hostname = NULL; - uint8_t* out_path = serd_file_uri_parse(node.buf, &out_hostname); + uint8_t* out_path = + serd_file_uri_parse((const uint8_t*)node.buf, &out_hostname); + assert(!strcmp((const char*)node.buf, expected_uri)); assert((hostname && out_hostname) || (!hostname && !out_hostname)); assert(!hostname || !strcmp(hostname, (const char*)out_hostname)); -- cgit v1.2.1