diff options
author | Fabian Groffen <grobian@gentoo.org> | 2020-08-17 16:31:16 +0200 |
---|---|---|
committer | Fabian Groffen <grobian@gentoo.org> | 2020-08-17 16:31:16 +0200 |
commit | e55f582c4c129ece9037575135a95f98a91a210f (patch) | |
tree | 00fe0512dace278c81d62791cb380cc37cff52ee /qlop.c | |
parent | qlop: recognise logfile naming when PORTAGE_LOGDIR is set, bug #711896 (diff) | |
download | portage-utils-e55f582c4c129ece9037575135a95f98a91a210f.tar.gz portage-utils-e55f582c4c129ece9037575135a95f98a91a210f.tar.bz2 portage-utils-e55f582c4c129ece9037575135a95f98a91a210f.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>
Diffstat (limited to 'qlop.c')
-rw-r--r-- | qlop.c | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -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); } |