From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1197318-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 33EE4138359
	for <garchives@archives.gentoo.org>; Mon, 17 Aug 2020 14:34:08 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 6C019E083B;
	Mon, 17 Aug 2020 14:34:07 +0000 (UTC)
Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 56E02E083B
	for <gentoo-commits@lists.gentoo.org>; Mon, 17 Aug 2020 14:34:07 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 66A5334F356
	for <gentoo-commits@lists.gentoo.org>; Mon, 17 Aug 2020 14:34:06 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id E4760286
	for <gentoo-commits@lists.gentoo.org>; Mon, 17 Aug 2020 14:34:04 +0000 (UTC)
From: "Fabian Groffen" <grobian@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" <grobian@gentoo.org>
Message-ID: <1597674676.e55f582c4c129ece9037575135a95f98a91a210f.grobian@gentoo>
Subject: [gentoo-commits] proj/portage-utils:master commit in: /
X-VCS-Repository: proj/portage-utils
X-VCS-Files: qlop.c
X-VCS-Directories: /
X-VCS-Committer: grobian
X-VCS-Committer-Name: Fabian Groffen
X-VCS-Revision: e55f582c4c129ece9037575135a95f98a91a210f
X-VCS-Branch: master
Date: Mon, 17 Aug 2020 14:34:04 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: c3bbdf6c-2b80-4875-ba79-ebc3cc08742a
X-Archives-Hash: d1aa9a9ff4d4641b1434732802a5ec83

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);
 				}