From nobody Fri May 3 22:44:00 2024 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 1550668828112598.7307763242043; Wed, 20 Feb 2019 05:20:28 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4F496CD17C; Wed, 20 Feb 2019 13:20:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CEFB418786; Wed, 20 Feb 2019 13:20:24 +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 816A0EEE2; Wed, 20 Feb 2019 13:20:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1KDKMlO005185 for ; Wed, 20 Feb 2019 08:20:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 972CF5D6B3; Wed, 20 Feb 2019 13:20:22 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 298FD5D71A; Wed, 20 Feb 2019 13:20:16 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 20 Feb 2019 14:20:08 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: abologna@redhat.com Subject: [libvirt] [PATCH v2 1/3] virTestCompareToULL: Use VIR_AUTOFREE() 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: , 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 20 Feb 2019 13:20:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In order to save a few lines of code, and also since it's hype let's use VIR_AUTOFREE() for the two strings we allocate there. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- tests/testutils.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index d2219ad21e..ac86418653 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -822,23 +822,16 @@ int virTestCompareToULL(unsigned long long content, unsigned long long src) { - char *strcontent =3D NULL; - char *strsrc =3D NULL; - int ret =3D -1; + VIR_AUTOFREE(char *) strcontent =3D NULL; + VIR_AUTOFREE(char *) strsrc =3D NULL; =20 if (virAsprintf(&strcontent, "%llu", content) < 0) - goto cleanup; + return -1; =20 if (virAsprintf(&strsrc, "%llu", src) < 0) - goto cleanup; + return -1; =20 - ret =3D virTestCompareToString(strcontent, strsrc); - - cleanup: - VIR_FREE(strcontent); - VIR_FREE(strsrc); - - return ret; + return virTestCompareToString(strcontent, strsrc); } =20 /* --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 22:44:00 2024 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 1550668836815248.46733579674094; Wed, 20 Feb 2019 05:20:36 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D6284C00732A; Wed, 20 Feb 2019 13:20:33 +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 5C3A25D6AA; Wed, 20 Feb 2019 13:20:33 +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 E77C9181A00A; Wed, 20 Feb 2019 13:20:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1KDKN2V005190 for ; Wed, 20 Feb 2019 08:20:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 916605D6AA; Wed, 20 Feb 2019 13:20:23 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id E49C15D719; Wed, 20 Feb 2019 13:20:22 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 20 Feb 2019 14:20:09 +0100 Message-Id: <4bb049a37316967a89140c884f73cc28f14b3746.1550668692.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: abologna@redhat.com Subject: [libvirt] [PATCH v2 2/3] virTestCompareToULL: Rename local variables 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: , 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 20 Feb 2019 13:20:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The current naming makes it hard for me to see which holds the expected value and which holds the actual value. Rename them to make it obvious. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- tests/testutils.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index ac86418653..01f3e8bb93 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -822,16 +822,16 @@ int virTestCompareToULL(unsigned long long content, unsigned long long src) { - VIR_AUTOFREE(char *) strcontent =3D NULL; - VIR_AUTOFREE(char *) strsrc =3D NULL; + VIR_AUTOFREE(char *) expectStr =3D NULL; + VIR_AUTOFREE(char *) actualStr =3D NULL; =20 - if (virAsprintf(&strcontent, "%llu", content) < 0) + if (virAsprintf(&expectStr, "%llu", content) < 0) return -1; =20 - if (virAsprintf(&strsrc, "%llu", src) < 0) + if (virAsprintf(&actualStr, "%llu", src) < 0) return -1; =20 - return virTestCompareToString(strcontent, strsrc); + return virTestCompareToString(expectStr, actualStr); } =20 /* --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 22:44:00 2024 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 1550668834883133.50622978920683; Wed, 20 Feb 2019 05:20:34 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A049FC0BFBC4; Wed, 20 Feb 2019 13:20:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5851B272BC; Wed, 20 Feb 2019 13:20:31 +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 1288C3FB15; Wed, 20 Feb 2019 13:20:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1KDKOfU005198 for ; Wed, 20 Feb 2019 08:20:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8AFB85D70E; Wed, 20 Feb 2019 13:20:24 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE4BB5D706; Wed, 20 Feb 2019 13:20:23 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 20 Feb 2019 14:20:10 +0100 Message-Id: <68320eb3d517e4c18d9c7d5eaed03687026bfdb0.1550668692.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: abologna@redhat.com Subject: [libvirt] [PATCH v2 3/3] testutils: Explicitly name virTestCompare*() arguments 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 20 Feb 2019 13:20:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Currently, some arguments are called strcontent and strsrc, or content and src or some other combination. This makes it impossible to see at the first glance what argument is supposed to represent 'expected' value and which one represents 'actual' value. Rename the arguments to make it obvious. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan Reviewed-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- tests/testutils.c | 34 +++++++++++++--------------------- tests/testutils.h | 10 +++++----- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index 01f3e8bb93..13bb9630df 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -767,19 +767,19 @@ int virTestDifferenceBin(FILE *stream, } =20 /* - * @param strcontent: String input content - * @param filename: File to compare strcontent against + * @param actual: String input content + * @param filename: File to compare @actual against * - * If @strcontent is NULL, it's treated as an empty string. + * If @actual is NULL, it's treated as an empty string. */ int -virTestCompareToFile(const char *strcontent, +virTestCompareToFile(const char *actual, const char *filename) { int ret =3D -1; char *filecontent =3D NULL; char *fixedcontent =3D NULL; - const char *cmpcontent =3D strcontent; + const char *cmpcontent =3D actual; =20 if (!cmpcontent) cmpcontent =3D ""; @@ -814,36 +814,28 @@ virTestCompareToFile(const char *strcontent, return ret; } =20 -/* - * @param content: Input content - * @param src: Source to compare @content against - */ int -virTestCompareToULL(unsigned long long content, - unsigned long long src) +virTestCompareToULL(unsigned long long expect, + unsigned long long actual) { VIR_AUTOFREE(char *) expectStr =3D NULL; VIR_AUTOFREE(char *) actualStr =3D NULL; =20 - if (virAsprintf(&expectStr, "%llu", content) < 0) + if (virAsprintf(&expectStr, "%llu", expect) < 0) return -1; =20 - if (virAsprintf(&actualStr, "%llu", src) < 0) + if (virAsprintf(&actualStr, "%llu", actual) < 0) return -1; =20 return virTestCompareToString(expectStr, actualStr); } =20 -/* - * @param strcontent: String input content - * @param strsrc: String source to compare strcontent against - */ int -virTestCompareToString(const char *strcontent, - const char *strsrc) +virTestCompareToString(const char *expect, + const char *actual) { - if (STRNEQ_NULLABLE(strcontent, strsrc)) { - virTestDifference(stderr, strcontent, strsrc); + if (STRNEQ_NULLABLE(expect, actual)) { + virTestDifference(stderr, expect, actual); return -1; } =20 diff --git a/tests/testutils.h b/tests/testutils.h index 658f9053ad..d0a259e2d4 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -76,12 +76,12 @@ int virTestDifferenceBin(FILE *stream, const char *expect, const char *actual, size_t length); -int virTestCompareToFile(const char *strcontent, +int virTestCompareToFile(const char *actual, const char *filename); -int virTestCompareToString(const char *strcontent, - const char *strsrc); -int virTestCompareToULL(unsigned long long content, - unsigned long long src); +int virTestCompareToString(const char *expect, + const char *actual); +int virTestCompareToULL(unsigned long long expect, + unsigned long long actual); =20 unsigned int virTestGetDebug(void); unsigned int virTestGetVerbose(void); --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list