summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2014-01-08 14:29:44 +0100
committerMichael Schroeder <mls@suse.de>2014-01-08 14:29:44 +0100
commit84957715aacbe8405e3cb367fe763220d5ba6b42 (patch)
tree039102e6e383fdb5f9e4c0974d9e5f9de7835e31 /ext
parentc8beaece09040926fb9ea9d6c42b24bda463392e (diff)
downloadlibsolv-84957715aacbe8405e3cb367fe763220d5ba6b42.tar.gz
libsolv-84957715aacbe8405e3cb367fe763220d5ba6b42.tar.bz2
libsolv-84957715aacbe8405e3cb367fe763220d5ba6b42.zip
fix a couple of minor problems found with cppcheck
Diffstat (limited to 'ext')
-rw-r--r--ext/repo_cudf.c3
-rw-r--r--ext/repo_mdk.c6
-rw-r--r--ext/testcase.c4
3 files changed, 9 insertions, 4 deletions
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))