From nobody Sat Feb 7 08:43:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1545059638263645.1108862534311; Mon, 17 Dec 2018 07:13:58 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7149E1E2D4; Mon, 17 Dec 2018 14:56:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2A1F2B8AA; Mon, 17 Dec 2018 14:56:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5E428181BA17; Mon, 17 Dec 2018 14:56:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wBHEtsjt009326 for ; Mon, 17 Dec 2018 09:55:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7ACF12A2F0; Mon, 17 Dec 2018 14:55:54 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-170.phx2.redhat.com [10.3.116.170]) by smtp.corp.redhat.com (Postfix) with ESMTP id 359445DA2A for ; Mon, 17 Dec 2018 14:55:54 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 17 Dec 2018 09:55:46 -0500 Message-Id: <20181217145548.15125-2-jferlan@redhat.com> In-Reply-To: <20181217145548.15125-1-jferlan@redhat.com> References: <20181217145548.15125-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] tests: Return failures immediately in virErrorTestMsgs X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 17 Dec 2018 14:56:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rather than chancing calling strchr when @err_noinfo =3D=3D NULL or calling virErrorTestMsgFormatInfoOne when @err_info =3D=3D NULL, both of which would fail, let's just return -1 immediately when we encounter an error. Signed-off-by: John Ferlan --- tests/virerrortest.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/virerrortest.c b/tests/virerrortest.c index eebf259343..48b4848b44 100644 --- a/tests/virerrortest.c +++ b/tests/virerrortest.c @@ -58,7 +58,6 @@ virErrorTestMsgs(const void *opaque ATTRIBUTE_UNUSED) const char *err_noinfo; const char *err_info; size_t i; - int ret =3D 0; =20 for (i =3D 1; i < VIR_ERR_NUMBER_LAST; i++) { err_noinfo =3D virErrorMsg(i, NULL); @@ -66,25 +65,25 @@ virErrorTestMsgs(const void *opaque ATTRIBUTE_UNUSED) =20 if (!err_noinfo) { VIR_TEST_VERBOSE("\nmissing string without info for error id %= zu\n", i); - ret =3D -1; + return -1; } =20 if (!err_info) { VIR_TEST_VERBOSE("\nmissing string with info for error id %zu\= n", i); - ret =3D -1; + return -1; } =20 if (strchr(err_noinfo, '%')) { VIR_TEST_VERBOSE("\nerror message id %zu contains formatting c= haracters: '%s'\n", i, err_noinfo); - ret =3D -1; + return -1; } =20 if (virErrorTestMsgFormatInfoOne(err_info) < 0) - ret =3D -1; + return -1; } =20 - return ret; + return 0; } =20 =20 --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list