aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/base64.c4
-rw-r--r--src/string_utils.h7
-rw-r--r--tests/serd_test.c6
3 files changed, 9 insertions, 8 deletions
diff --git a/src/base64.c b/src/base64.c
index ff1184b8..a83e2f06 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -95,7 +95,7 @@ serd_base64_encode(char* const str,
static inline uint8_t
unmap(const uint8_t in)
{
- return b64_unmap[in] - 47;
+ return b64_unmap[in] - 47U;
}
/** Decode 4 base64 characters to 3 raw bytes. */
@@ -105,7 +105,7 @@ decode_chunk(const uint8_t in[4], uint8_t out[3])
out[0] = (uint8_t)(((unmap(in[0]) << 2)) | unmap(in[1]) >> 4);
out[1] = (uint8_t)(((unmap(in[1]) << 4) & 0xF0) | unmap(in[2]) >> 2);
out[2] = (uint8_t)(((unmap(in[2]) << 6) & 0xC0) | unmap(in[3]));
- return 1 + (in[2] != '=') + ((in[2] != '=') && (in[3] != '='));
+ return 1U + (in[2] != '=') + ((in[2] != '=') && (in[3] != '='));
}
SerdStatus
diff --git a/src/string_utils.h b/src/string_utils.h
index 717cfda5..ff55a1d0 100644
--- a/src/string_utils.h
+++ b/src/string_utils.h
@@ -132,9 +132,9 @@ utf8_num_bytes(const uint8_t c)
static inline uint32_t
parse_counted_utf8_char(const uint8_t* utf8, size_t size)
{
- uint32_t c = utf8[0] & ((1 << (8 - size)) - 1);
+ uint32_t c = utf8[0] & ((1U << (8 - size)) - 1U);
for (size_t i = 1; i < size; ++i) {
- const uint8_t in = utf8[i] & 0x3F;
+ const uint8_t in = utf8[i] & 0x3FU;
c = (c << 6) | in;
}
return c;
@@ -148,7 +148,8 @@ parse_utf8_char(const uint8_t* utf8, size_t* size)
case 1: case 2: case 3: case 4:
return parse_counted_utf8_char(utf8, *size);
default:
- return *size = 0;
+ *size = 0;
+ return 0U;
}
}
diff --git a/tests/serd_test.c b/tests/serd_test.c
index 797a489a..92d23aae 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -566,9 +566,9 @@ main(void)
}
// Write statements with bad UTF-8 (should be replaced)
- const char bad_str[] = { (char)0xFF, (char)0x90, 'h', 'i', 0 };
- SerdNode* bad_lit = serd_new_string(bad_str);
- SerdNode* bad_uri = serd_new_uri(bad_str);
+ const uint8_t bad_str[] = { 0xFF, 0x90, 'h', 'i', 0 };
+ SerdNode* bad_lit = serd_new_string((const char*)bad_str);
+ SerdNode* bad_uri = serd_new_uri((const char*)bad_str);
assert(!serd_sink_write(iface, 0, s, p, bad_lit, 0));
assert(!serd_sink_write(iface, 0, s, p, bad_uri, 0));
serd_node_free(bad_uri);