From: Michael Schroeder Date: Wed, 8 Jan 2014 13:29:44 +0000 (+0100) Subject: fix a couple of minor problems found with cppcheck X-Git-Tag: upstream/0.6.4~129 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=84957715aacbe8405e3cb367fe763220d5ba6b42;p=platform%2Fupstream%2Flibsolv.git fix a couple of minor problems found with cppcheck --- diff --git a/ext/repo_cudf.c b/ext/repo_cudf.c index 316887b..00a4f87 100644 --- a/ext/repo_cudf.c +++ b/ext/repo_cudf.c @@ -177,7 +177,7 @@ finishpackage(Pool *pool, Solvable *s, int keep, Queue *job) int repo_add_cudf(Repo *repo, Repo *installedrepo, FILE *fp, Queue *job, int flags) { - Pool *pool = repo->pool; + Pool *pool; char *buf, *p; int bufa, bufl, c; Solvable *s; @@ -190,6 +190,7 @@ repo_add_cudf(Repo *repo, Repo *installedrepo, FILE *fp, Queue *job, int flags) xrepo = repo ? repo : installedrepo; if (!xrepo) return -1; + pool = xrepo->pool; buf = solv_malloc(4096); bufa = 4096; diff --git a/ext/repo_mdk.c b/ext/repo_mdk.c index bdd7f40..1bf6f17 100644 --- a/ext/repo_mdk.c +++ b/ext/repo_mdk.c @@ -95,7 +95,9 @@ repo_add_mdk(Repo *repo, FILE *fp, int flags) while (fgets(buf + bufl, bufa - bufl, fp) > 0) { bufl += strlen(buf + bufl); - if (bufl && buf[bufl - 1] != '\n') + if (!bufl) + continue; + if (buf[bufl - 1] != '\n') { if (bufa - bufl < 256) { @@ -104,7 +106,7 @@ repo_add_mdk(Repo *repo, FILE *fp, int flags) } continue; } - buf[--bufl] = 0; + buf[bufl - 1] = 0; bufl = 0; if (buf[0] != '@') { diff --git a/ext/testcase.c b/ext/testcase.c index 08868b6..13f52df 100644 --- a/ext/testcase.c +++ b/ext/testcase.c @@ -1099,7 +1099,7 @@ testcase_add_testtags(Repo *repo, FILE *fp, int flags) linep += strlen(linep); if (linep == line || linep[-1] != '\n') continue; - *--linep = 0; + linep[-1] = 0; linep = line + intag; if (intag) { @@ -1739,6 +1739,7 @@ testcase_write(Solver *solv, char *dir, int resultflags, const char *testcasenam pool_debug(solv->pool, SOLV_ERROR, "testcase_write: write error\n"); solv_free(result); strqueue_free(&sq); + fclose(fp); return 0; } if (fclose(fp)) @@ -1763,6 +1764,7 @@ testcase_write(Solver *solv, char *dir, int resultflags, const char *testcasenam { pool_debug(solv->pool, SOLV_ERROR, "testcase_write: write error\n"); strqueue_free(&sq); + fclose(fp); return 0; } if (fclose(fp)) diff --git a/src/pool.c b/src/pool.c index 57e9814..981c767 100644 --- a/src/pool.c +++ b/src/pool.c @@ -2117,7 +2117,7 @@ static inline Id dep2name(Pool *pool, Id dep) { while (ISRELDEP(dep)) { - Reldep *rd = rd = GETRELDEP(pool, dep); + Reldep *rd = GETRELDEP(pool, dep); dep = rd->name; } return dep; diff --git a/src/solvable.c b/src/solvable.c index eeb7b35..5afb481 100644 --- a/src/solvable.c +++ b/src/solvable.c @@ -404,7 +404,7 @@ static inline Id dep2name(Pool *pool, Id dep) { while (ISRELDEP(dep)) { - Reldep *rd = rd = GETRELDEP(pool, dep); + Reldep *rd = GETRELDEP(pool, dep); dep = rd->name; } return dep; diff --git a/tools/dumpsolv.c b/tools/dumpsolv.c index 617d512..aebcf4b 100644 --- a/tools/dumpsolv.c +++ b/tools/dumpsolv.c @@ -297,7 +297,7 @@ dump_repodata_cb(void *vcbdata, Solvable *s, Repodata *data, Repokey *key, KeyVa static void dump_repodata(Repo *repo) { - unsigned int i; + int i; Repodata *data; if (repo->nrepodata == 0) return; @@ -321,7 +321,7 @@ dump_repodata(Repo *repo) static void dump_repodata_json(Repo *repo, struct cbdata *cbdata) { - unsigned int i; + int i; Repodata *data; if (repo->nrepodata == 0) return;