aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-03-01 19:15:24 -0500
committerDavid Robillard <d@drobilla.net>2021-03-08 23:23:06 -0500
commit15485f61df8cbd922907db39fcc864abb002eea3 (patch)
tree3ea4979ab93405925589d18414a5004e8b46286f /src
parent468f7dc4294905d19f55c58c47ba91cd23bf357b (diff)
downloadserd-15485f61df8cbd922907db39fcc864abb002eea3.tar.gz
serd-15485f61df8cbd922907db39fcc864abb002eea3.tar.bz2
serd-15485f61df8cbd922907db39fcc864abb002eea3.zip
Fix various warnings and conversion issues
Diffstat (limited to 'src')
-rw-r--r--src/n3.c10
-rw-r--r--src/node.c11
-rw-r--r--src/stack.h2
-rw-r--r--src/string_utils.h8
-rw-r--r--src/uri.c7
5 files changed, 18 insertions, 20 deletions
diff --git a/src/n3.c b/src/n3.c
index 22c24fd7..edc0f52b 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -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);
diff --git a/src/node.c b/src/node.c
index 268b53af..7d1177e4 100644
--- a/src/node.c
+++ b/src/node.c
@@ -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;
}
}
diff --git a/src/uri.c b/src/uri.c
index 5b1ed598..f4d602fb 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -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 {