diff options
author | David Robillard <d@drobilla.net> | 2021-03-01 19:15:24 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-08 23:23:06 -0500 |
commit | 15485f61df8cbd922907db39fcc864abb002eea3 (patch) | |
tree | 3ea4979ab93405925589d18414a5004e8b46286f | |
parent | 468f7dc4294905d19f55c58c47ba91cd23bf357b (diff) | |
download | serd-15485f61df8cbd922907db39fcc864abb002eea3.tar.gz serd-15485f61df8cbd922907db39fcc864abb002eea3.tar.bz2 serd-15485f61df8cbd922907db39fcc864abb002eea3.zip |
Fix various warnings and conversion issues
-rw-r--r-- | meson.build | 6 | ||||
-rw-r--r-- | src/n3.c | 10 | ||||
-rw-r--r-- | src/node.c | 11 | ||||
-rw-r--r-- | src/stack.h | 2 | ||||
-rw-r--r-- | src/string_utils.h | 8 | ||||
-rw-r--r-- | src/uri.c | 7 |
6 files changed, 18 insertions, 26 deletions
diff --git a/meson.build b/meson.build index 0a6efce2..fba0cfcb 100644 --- a/meson.build +++ b/meson.build @@ -28,8 +28,6 @@ if get_option('strict') c_warnings += [ '-Wno-bad-function-cast', '-Wno-cast-align', - '-Wno-cast-qual', - '-Wno-conversion', '-Wno-covered-switch-default', '-Wno-disabled-macro-expansion', '-Wno-double-promotion', @@ -40,18 +38,14 @@ if get_option('strict') '-Wno-nullable-to-nonnull-conversion', '-Wno-padded', '-Wno-reserved-id-macro', - '-Wno-sign-conversion', ] elif cc.get_id() == 'gcc' c_warnings += [ '-Wno-bad-function-cast', '-Wno-cast-align', - '-Wno-cast-qual', - '-Wno-float-conversion', '-Wno-format-nonliteral', '-Wno-inline', '-Wno-padded', - '-Wno-sign-conversion', '-Wno-switch-default', '-Wno-unsuffixed-float-constants', '-Wno-unused-const-variable', @@ -65,7 +65,7 @@ read_HEX(SerdReader* reader) } // Read UCHAR escape, initial \ is already eaten by caller -static inline SerdStatus +static SerdStatus read_UCHAR(SerdReader* reader, SerdNode* dest, uint32_t* char_code) { const int b = peek_byte(reader); @@ -143,7 +143,7 @@ read_UCHAR(SerdReader* reader, SerdNode* dest, uint32_t* char_code) } // Read ECHAR escape, initial \ is already eaten by caller -static inline SerdStatus +static SerdStatus read_ECHAR(SerdReader* reader, SerdNode* dest) { const int c = peek_byte(reader); @@ -279,7 +279,7 @@ read_comment(SerdReader* reader) } // [24] ws ::= #x9 | #xA | #xD | #x20 | comment -static inline bool +static bool read_ws(SerdReader* reader) { const int c = peek_byte(reader); @@ -308,14 +308,14 @@ read_ws_star(SerdReader* reader) } static inline bool -peek_delim(SerdReader* reader, const char delim) +peek_delim(SerdReader* reader, const uint8_t delim) { read_ws_star(reader); return peek_byte(reader) == delim; } static inline bool -eat_delim(SerdReader* reader, const char delim) +eat_delim(SerdReader* reader, const uint8_t delim) { if (peek_delim(reader, delim)) { eat_byte_safe(reader, delim); @@ -530,17 +530,14 @@ is_uri_path_char(const char c) } switch (c) { - // unreserved: case '-': case '.': case '_': - case '~': - // pchar: + case '~': // unreserved case ':': - case '@': - // separator: - case '/': - // sub-delimeters: + case '@': // pchar + case '/': // separator + // sub-delims case '!': case '$': case '&': diff --git a/src/stack.h b/src/stack.h index 0eae1b75..273bf2a5 100644 --- a/src/stack.h +++ b/src/stack.h @@ -57,7 +57,7 @@ serd_stack_clear(SerdStack* stack) } static inline bool -serd_stack_is_empty(SerdStack* stack) +serd_stack_is_empty(const SerdStack* stack) { return stack->size <= SERD_STACK_BOTTOM; } diff --git a/src/string_utils.h b/src/string_utils.h index 08ba530c..0e9eee43 100644 --- a/src/string_utils.h +++ b/src/string_utils.h @@ -84,7 +84,7 @@ is_print(const int c) } static inline bool -is_base64(const char c) +is_base64(const int c) { return is_alpha(c) || is_digit(c) || c == '+' || c == '/' || c == '='; } @@ -143,9 +143,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] & ((1u << (8 - size)) - 1); + uint32_t c = utf8[0] & ((1u << (8u - 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; @@ -163,7 +163,7 @@ parse_utf8_char(const uint8_t* utf8, size_t* size) return parse_counted_utf8_char(utf8, *size); default: *size = 0; - return 0; + return 0u; } } @@ -43,8 +43,9 @@ serd_parse_file_uri(const char* uri, char** hostname) } if (hostname) { - *hostname = (char*)calloc((size_t)(path - auth + 1), 1); - memcpy(*hostname, auth, (size_t)(path - auth)); + const size_t len = (size_t)(path - auth); + *hostname = (char*)calloc(len + 1, 1); + memcpy(*hostname, auth, len); } } } @@ -61,7 +62,7 @@ serd_parse_file_uri(const char* uri, char** hostname) ++s; } else if (is_hexdig(*(s + 1)) && is_hexdig(*(s + 2))) { const char code[3] = {*(s + 1), *(s + 2), 0}; - const char c = (char)strtoul((const char*)code, NULL, 16); + const char c = (char)strtoul(code, NULL, 16); serd_buffer_sink(&c, 1, 1, &buffer); s += 2; } else { |