aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2020-08-17 16:31:16 +0200
committerFabian Groffen <grobian@gentoo.org>2020-08-17 16:31:16 +0200
commite55f582c4c129ece9037575135a95f98a91a210f (patch)
tree00fe0512dace278c81d62791cb380cc37cff52ee
parentqlop: recognise logfile naming when PORTAGE_LOGDIR is set, bug #711896 (diff)
downloadportage-utils-e55f582c.tar.gz
portage-utils-e55f582c.tar.bz2
portage-utils-e55f582c.zip
qlop: work around Coverity complaintsv0.89
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@gentoo.org>
-rw-r--r--qlop.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/qlop.c b/qlop.c
index 47ef83dc..385613ab 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);
}