commit: e55f582c4c129ece9037575135a95f98a91a210f Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Mon Aug 17 14:31:16 2020 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Mon Aug 17 14:31:16 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e55f582c
qlop: work around Coverity complaints
Check/search once for colons, it is a bit brittle to assume a colon was
found, even though in this case it should have always succeeded.
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
qlop.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/qlop.c b/qlop.c
index 47ef83d..385613a 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1249,27 +1249,26 @@ static array_t *probe_proc(array_t *atoms)
} else if ((size_t)rpathlen >
sizeof(".log") &&
strcmp(rpath + rpathlen
-
(sizeof(".log")
- 1), ".log") == 0 &&
- (p = strchr(rpath,
':')) != NULL &&
- (p = strchr(p + 1,
':')) != NULL &&
(p = strrchr(rpath,
'/')) != NULL)
{
char *q;
p++; /* skip / */
- q = strchr(p, ':'); /* checked
above to exist */
- *q++ = '/';
- q = strchr(q, ':'); /* checked
above to exist */
- *q = '\0';
-
- atom = atom_explode(p);
+ if ((q = strchr(p, ':')) !=
NULL) {
+ *q++ = '/';
+ if ((q = strchr(q,
':')) != NULL) {
+ *q = '\0';
+ atom =
atom_explode(p);
+ }
+ }
}
+ if (atom == NULL)
+ continue;
if (atom->CATEGORY == NULL || atom->P
== NULL) {
atom_implode(atom);
continue;
}
- if (atom == NULL)
- continue;
xarraypush_ptr(ret_atoms, atom);
}
