From 40f8fab17e2cb24ada3ef396248df644ca34d671 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Fri, 28 Jun 2024 21:51:22 +0200 Subject: fix Coverity issues Signed-off-by: Fabian Groffen --- qdepends.c | 1 + qmanifest.c | 8 ++++---- qpkg.c | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/qdepends.c b/qdepends.c index 1ecfab5..6afcb1c 100644 --- a/qdepends.c +++ b/qdepends.c @@ -416,6 +416,7 @@ int qdepends_main(int argc, char **argv) array_for_each(overlays, n, overlay) { t = tree_open(portroot, overlay); if (t != NULL) { + state.rtree = NULL; if (state.resolve) state.rtree = tree_open(portroot, overlay); if (!(state.qmode & QMODE_REVERSE) && array_cnt(atoms) > 0) { diff --git a/qmanifest.c b/qmanifest.c index 5246fc4..555e3c7 100644 --- a/qmanifest.c +++ b/qmanifest.c @@ -1357,8 +1357,8 @@ verify_dir( } } - while (dentrieslen-- > 0) - free(dentries[dentrieslen]); + for (curdentry = 0; curdentry < dentrieslen; curdentry++) + free(dentries[curdentry]); free(dentries); #pragma omp parallel for shared(ret) private(entry, etpe, slash) @@ -1497,8 +1497,8 @@ verify_manifest( ret = verify_dir(dir, elems, elemslen, 0, buf + 2, msgs); checked_manifests++; - while (elemslen-- > 0) - free(elems[elemslen]); + for (elemssize = 0; elemssize < elemslen; elemssize++) + free(elems[elemssize]); free(elems); return ret; diff --git a/qpkg.c b/qpkg.c index c165989..85dbbcf 100644 --- a/qpkg.c +++ b/qpkg.c @@ -101,9 +101,9 @@ qpkg_clean(char *dirp) if (known_pkgs != NULL) { /* check which binpkgs exist in the known_pkgs (vdb or trees), such * that the remainder is what we would clean */ - array_for_each(bins, n, binatomstr) { + array_for_each_rev(bins, n, binatomstr) { if (contains_set(binatomstr, known_pkgs)) - xarraydelete_ptr(bins, n--); + xarraydelete_ptr(bins, n); } free_set(known_pkgs); -- cgit v1.2.3-65-gdbad