From bd76057e8c5ac7f97455f1708a8bb4d0dbb1841b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 22 Mar 2019 20:57:50 +0100 Subject: Fix errors shown by scan-build. --- src/parse.c | 11 +++++------ src/strbuf.c | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/parse.c b/src/parse.c index 0e37350d..565e1d6c 100644 --- a/src/parse.c +++ b/src/parse.c @@ -309,7 +309,6 @@ FREE_F(parse_ctx) { int handle_escape (parse_ctx* ctx) { char esc = fgetc(ctx->f); - char target; /* * Escape character '\' and escaped token sepparated by a newline @@ -330,19 +329,19 @@ int handle_escape (parse_ctx* ctx) { /* Escaped new_line */ if (esc == 'n' || esc == 'N') { - target = '\n'; + esc = '\n'; - /* "Standard" escaped character */ + /* "Standard" escaped character */ } else if (esc == ';' || esc == ',' || esc == '\\') { - target = esc; + /* esc already contains character, do nothing */ - /* Invalid escaped character */ + /* Invalid escaped character */ } else { ERR_P(ctx, "Non escapable character '%c' (%i)", esc, esc); } /* save escapade character as a normal character */ - strbuf_append(&ctx->str, target); + strbuf_append(&ctx->str, esc); ++ctx->column; ++ctx->pcolumn; diff --git a/src/strbuf.c b/src/strbuf.c index 0e56468b..c7e3f2b5 100644 --- a/src/strbuf.c +++ b/src/strbuf.c @@ -86,10 +86,10 @@ int strbuf_cmp(strbuf* a, strbuf* b) { b == NULL || b->alloc == 0) { ERR("a or b not alloced"); - // return -1; + return -1; + } else { + return strncmp(a->mem, b->mem, a->len); } - - return strncmp(a->mem, b->mem, a->len); } int strbuf_c(strbuf* a, const char* b) { -- cgit v1.2.3