diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/base64.c | 4 | ||||
-rw-r--r-- | src/string_utils.h | 7 |
2 files changed, 6 insertions, 5 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; } } |