diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/n3.c | 38 | ||||
-rw-r--r-- | src/serd_internal.h | 2 | ||||
-rw-r--r-- | src/uri.c | 10 | ||||
-rw-r--r-- | src/writer.c | 7 |
4 files changed, 29 insertions, 28 deletions
@@ -203,9 +203,9 @@ read_utf8_bytes(SerdReader* reader, uint8_t bytes[4], uint32_t* size, uint8_t c) static SerdStatus read_utf8_character(SerdReader* reader, Ref dest, uint8_t c) { - uint32_t size; - uint8_t bytes[4]; - SerdStatus st = read_utf8_bytes(reader, bytes, &size, c); + uint32_t size = 0; + uint8_t bytes[4] = {0, 0, 0, 0}; + SerdStatus st = read_utf8_bytes(reader, bytes, &size, c); if (st) { push_bytes(reader, dest, replacement_char, 3); } else { @@ -217,9 +217,9 @@ read_utf8_character(SerdReader* reader, Ref dest, uint8_t c) static SerdStatus read_utf8_code(SerdReader* reader, Ref dest, uint32_t* code, uint8_t c) { - uint32_t size; - uint8_t bytes[4] = { 0, 0, 0, 0 }; - SerdStatus st = read_utf8_bytes(reader, bytes, &size, c); + uint32_t size = 0; + uint8_t bytes[4] = {0, 0, 0, 0}; + SerdStatus st = read_utf8_bytes(reader, bytes, &size, c); if (st) { push_bytes(reader, dest, replacement_char, 3); return st; @@ -255,7 +255,7 @@ static void read_comment(SerdReader* reader) { eat_byte_safe(reader, '#'); - int c; + int c = 0; while (((c = peek_byte(reader)) != 0xA) && c != 0xD && c != EOF && c) { eat_byte_safe(reader, c); } @@ -313,7 +313,7 @@ read_STRING_LITERAL_LONG(SerdReader* reader, SerdNodeFlags* flags, uint8_t q) const int c = peek_byte(reader); if (c == '\\') { eat_byte_safe(reader, c); - uint32_t code; + uint32_t code = 0; if (!read_ECHAR(reader, ref, flags) && !read_UCHAR(reader, ref, &code)) { r_err(reader, SERD_ERR_BAD_SYNTAX, @@ -426,9 +426,9 @@ is_PN_CHARS_BASE(const uint32_t c) static SerdStatus read_PN_CHARS_BASE(SerdReader* reader, Ref dest) { - uint32_t code; - const int c = peek_byte(reader); - SerdStatus st = SERD_SUCCESS; + uint32_t code = 0; + const int c = peek_byte(reader); + SerdStatus st = SERD_SUCCESS; if (is_alpha(c)) { push_byte(reader, dest, eat_byte_safe(reader, c)); } else if (c == EOF || !(c & 0x80)) { @@ -456,9 +456,9 @@ is_PN_CHARS(const uint32_t c) static SerdStatus read_PN_CHARS(SerdReader* reader, Ref dest) { - uint32_t code; - const int c = peek_byte(reader); - SerdStatus st = SERD_SUCCESS; + uint32_t code = 0; + const int c = peek_byte(reader); + SerdStatus st = SERD_SUCCESS; if (is_alpha(c) || is_digit(c) || c == '_' || c == '-') { push_byte(reader, dest, eat_byte_safe(reader, c)); } else if (c == EOF || !(c & 0x80)) { @@ -556,7 +556,7 @@ read_PN_LOCAL(SerdReader* reader, Ref dest, bool* ate_dot) static SerdStatus read_PN_PREFIX_tail(SerdReader* reader, Ref dest) { - int c; + int c = 0; while ((c = peek_byte(reader))) { // Middle: (PN_CHARS | '.')* if (c == '.') { push_byte(reader, dest, eat_byte_safe(reader, c)); @@ -709,7 +709,7 @@ static bool read_0_9(SerdReader* reader, Ref str, bool at_least_one) { unsigned count = 0; - for (int c; is_digit((c = peek_byte(reader))); ++count) { + for (int c = 0; is_digit((c = peek_byte(reader))); ++count) { push_byte(reader, str, eat_byte_safe(reader, c)); } if (at_least_one && count == 0) { @@ -922,7 +922,7 @@ static bool read_anon(SerdReader* reader, ReadContext ctx, bool subject, Ref* dest) { const SerdStatementFlags old_flags = *ctx.flags; - bool empty; + bool empty = false; eat_byte_safe(reader, '['); if ((empty = peek_delim(reader, ']'))) { *ctx.flags |= (subject) ? SERD_EMPTY_S : SERD_EMPTY_O; @@ -1088,7 +1088,7 @@ read_predicateObjectList(SerdReader* reader, ReadContext ctx, bool* ate_dot) } bool ate_semi = false; - int c; + int c = 0; do { read_ws_star(reader); switch (c = peek_byte(reader)) { @@ -1244,7 +1244,7 @@ read_base(SerdReader* reader, bool sparql, bool token) TRY_RET(eat_string(reader, "base", 4)); } - Ref uri; + Ref uri = 0; read_ws_star(reader); TRY_RET(uri = read_IRIREF(reader)); if (reader->base_sink) { diff --git a/src/serd_internal.h b/src/serd_internal.h index dea98000..7449c514 100644 --- a/src/serd_internal.h +++ b/src/serd_internal.h @@ -72,7 +72,7 @@ static inline void* serd_bufalloc(size_t size) { #ifdef HAVE_POSIX_MEMALIGN - void* ptr; + void* ptr = NULL; const int ret = posix_memalign(&ptr, SERD_PAGE_SIZE, size); return ret ? NULL : ptr; #else @@ -102,7 +102,7 @@ serd_uri_string_has_scheme(const uint8_t* utf8) return false; // Invalid scheme initial character, URI is relative } - for (uint8_t c; (c = *++utf8) != '\0';) { + for (uint8_t c = 0; (c = *++utf8) != '\0';) { if (!is_uri_scheme_char(c)) { return false; } else if (c == ':') { @@ -153,7 +153,7 @@ maybe_authority: if (*ptr == '/' && *(ptr + 1) == '/') { ptr += 2; out->authority.buf = ptr; - for (uint8_t c; (c = *ptr) != '\0'; ++ptr) { + for (uint8_t c = 0; (c = *ptr) != '\0'; ++ptr) { switch (c) { case '/': goto path; case '?': goto query; @@ -176,7 +176,7 @@ path: } out->path.buf = ptr; out->path.len = 0; - for (uint8_t c; (c = *ptr) != '\0'; ++ptr) { + for (uint8_t c = 0; (c = *ptr) != '\0'; ++ptr) { switch (c) { case '?': goto query; case '#': goto fragment; @@ -192,7 +192,7 @@ path: query: if (*ptr == '?') { out->query.buf = ++ptr; - for (uint8_t c; (c = *ptr) != '\0'; ++ptr) { + for (uint8_t c = 0; (c = *ptr) != '\0'; ++ptr) { if (c == '#') { goto fragment; } @@ -287,7 +287,7 @@ remove_dot_segments(const uint8_t* path, size_t len, size_t* up) static void merge(SerdChunk* base, SerdChunk* path) { - size_t up; + size_t up = 0; const uint8_t* begin = remove_dot_segments(path->buf, path->len, &up); const uint8_t* end = path->buf + path->len; diff --git a/src/writer.c b/src/writer.c index 15ccd21c..aeac9b36 100644 --- a/src/writer.c +++ b/src/writer.c @@ -545,9 +545,10 @@ write_curie(SerdWriter* const writer, const Field field, const SerdStatementFlags flags) { - SerdChunk prefix; - SerdChunk suffix; - SerdStatus st; + SerdChunk prefix = {NULL, 0}; + SerdChunk suffix = {NULL, 0}; + SerdStatus st = SERD_SUCCESS; + switch (writer->syntax) { case SERD_NTRIPLES: case SERD_NQUADS: |