From 9947012c89a2e965d2871b8b5417d9cd8adff2fd Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 15 May 2011 23:54:50 +0000 Subject: Remove dead code found by clang static analyser. git-svn-id: http://svn.drobilla.net/serd/trunk@180 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- src/serdi.c | 2 +- src/uri.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/serdi.c b/src/serdi.c index 1d6a8663..91cffe46 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -133,7 +133,7 @@ main(int argc, char** argv) const uint8_t* base_uri_str = NULL; SerdURI base_uri; if (a < argc) { // Base URI given on command line - const uint8_t* const in_base_uri = (const uint8_t*)argv[a++]; + const uint8_t* const in_base_uri = (const uint8_t*)argv[a]; if (serd_uri_parse((const uint8_t*)in_base_uri, &base_uri)) { fprintf(stderr, "Invalid base URI <%s>\n", argv[2]); return 1; diff --git a/src/uri.c b/src/uri.c index 958ba7da..4f1ef3a5 100644 --- a/src/uri.c +++ b/src/uri.c @@ -32,7 +32,7 @@ serd_uri_string_has_scheme(const uint8_t* utf8) if (!is_alpha(utf8[0])) { return false; // Invalid scheme initial character, URI is relative } - for (uint8_t c = *++utf8; (c = *utf8) != '\0'; ++utf8) { + for (uint8_t c; (c = *++utf8) != '\0';) { switch (c) { case ':': return true; // End of scheme @@ -113,7 +113,7 @@ maybe_authority: ptr += 2; uri->authority.buf = ptr; assert(uri->authority.len == 0); - for (uint8_t c = *ptr; (c = *ptr) != '\0'; ++ptr) { + for (uint8_t c; (c = *ptr) != '\0'; ++ptr) { switch (c) { case '/': goto path; case '?': goto query; @@ -136,7 +136,7 @@ path: } uri->path.buf = ptr; uri->path.len = 0; - for (uint8_t c = *ptr; (c = *ptr) != '\0'; ++ptr) { + for (uint8_t c; (c = *ptr) != '\0'; ++ptr) { switch (c) { case '?': goto query; case '#': goto fragment; @@ -152,7 +152,7 @@ path: query: if (*ptr == '?') { uri->query.buf = ++ptr; - for (uint8_t c = *ptr; (c = *ptr) != '\0'; ++ptr) { + for (uint8_t c; (c = *ptr) != '\0'; ++ptr) { switch (c) { case '#': goto fragment; @@ -268,11 +268,11 @@ serd_uri_serialise(const SerdURI* uri, SerdSink sink, void* stream) See http://tools.ietf.org/html/rfc3986#section-5.2.3 */ const uint8_t* begin = uri->path.buf; - const uint8_t* end = begin; - size_t up = 1; + size_t up = 1; + if (begin) { // Count and skip leading dot components - end = uri->path.buf + uri->path.len; + const uint8_t* end = uri->path.buf + uri->path.len; for (bool done = false; !done && (begin < end);) { switch (begin[0]) { case '.': -- cgit v1.2.1