From a4acf0c7414451d22b6264f2fabfa5eb348fbb62 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 27 Sep 2024 13:06:07 -0400 Subject: Use tighter types for UTF-8 --- src/n3.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/n3.c') diff --git a/src/n3.c b/src/n3.c index e5a06c77..b3cfbb8a 100644 --- a/src/n3.c +++ b/src/n3.c @@ -172,7 +172,7 @@ bad_char(SerdReader* const reader, const char* const fmt, const uint8_t c) static SerdStatus read_utf8_bytes(SerdReader* const reader, uint8_t bytes[4], - uint32_t* const size, + uint8_t* const size, const uint8_t c) { *size = utf8_num_bytes(c); @@ -181,9 +181,9 @@ read_utf8_bytes(SerdReader* const reader, } bytes[0] = c; - for (unsigned i = 1; i < *size; ++i) { + for (uint8_t i = 1U; i < *size; ++i) { const int b = peek_byte(reader); - if (b == EOF || ((uint8_t)b & 0x80) == 0) { + if (b == EOF || ((uint8_t)b & 0x80U) == 0U) { return bad_char(reader, "invalid UTF-8 continuation 0x%X\n", (uint8_t)b); } @@ -196,7 +196,7 @@ read_utf8_bytes(SerdReader* const reader, static SerdStatus read_utf8_character(SerdReader* const reader, const Ref dest, const uint8_t c) { - uint32_t size = 0; + uint8_t size = 0U; uint8_t bytes[4] = {0, 0, 0, 0}; SerdStatus st = read_utf8_bytes(reader, bytes, &size, c); if (st) { @@ -214,7 +214,7 @@ read_utf8_code(SerdReader* const reader, uint32_t* const code, const uint8_t c) { - uint32_t size = 0; + uint8_t size = 0U; uint8_t bytes[4] = {0, 0, 0, 0}; SerdStatus st = read_utf8_bytes(reader, bytes, &size, c); if (st) { -- cgit v1.2.1