From nobody Wed May 8 01:09:14 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 1550597097913230.6444987172274; Tue, 19 Feb 2019 09:24:57 -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 259A613984F; Tue, 19 Feb 2019 17:24:52 +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 D6D5066076; Tue, 19 Feb 2019 17:24:50 +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 7FDEC247E2; Tue, 19 Feb 2019 17:24:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1JHOcFo007266 for ; Tue, 19 Feb 2019 12:24:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 290456607C; Tue, 19 Feb 2019 17:24:38 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0EB966071 for ; Tue, 19 Feb 2019 17:24:29 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 19 Feb 2019 18:22:36 +0100 Message-Id: <4a449e6f7cdd96671dc81d743730c98b86addadd.1550596947.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] 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.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.39]); Tue, 19 Feb 2019 17:24:54 +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. At the same time, rework virTestCompareToULL a bit so that local variables are named in the same fashion. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- tests/testutils.c | 51 +++++++++++++++++------------------------------ tests/testutils.h | 10 +++++----- 2 files changed, 23 insertions(+), 38 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index d2219ad21e..59c1d1fd6e 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,43 +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 expected, + unsigned long long actual) { - char *strcontent =3D NULL; - char *strsrc =3D NULL; - int ret =3D -1; + VIR_AUTOFREE(char *) expectedStr =3D NULL; + VIR_AUTOFREE(char *) actualStr =3D NULL; =20 - if (virAsprintf(&strcontent, "%llu", content) < 0) - goto cleanup; + if (virAsprintf(&expectedStr, "%llu", expected) < 0) + return -1; =20 - if (virAsprintf(&strsrc, "%llu", src) < 0) - goto cleanup; + if (virAsprintf(&actualStr, "%llu", actual) < 0) + return -1; =20 - ret =3D virTestCompareToString(strcontent, strsrc); - - cleanup: - VIR_FREE(strcontent); - VIR_FREE(strsrc); - - return ret; + return virTestCompareToString(expectedStr, 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 *expected, + const char *actual) { - if (STRNEQ_NULLABLE(strcontent, strsrc)) { - virTestDifference(stderr, strcontent, strsrc); + if (STRNEQ_NULLABLE(expected, actual)) { + virTestDifference(stderr, expected, actual); return -1; } =20 diff --git a/tests/testutils.h b/tests/testutils.h index 658f9053ad..1ed9f0b6d3 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 *expected, + const char *actual); +int virTestCompareToULL(unsigned long long expected, + 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