From nobody Sat Apr 20 14:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578987306; cv=none; d=zohomail.com; s=zohoarc; b=JHi3FEGLHOUr0FHbwzttiEH/TfClRduAzNMuXoS39tbBVvF+P7wutvZu9JPro3rgqevmXXrjs5h1KSSja2vT18kMZvR8o28q2UuUlHXyoUs5i3tFOSS1ISOWmRkx1mjXK5+f7/TZFus426Ahpk0hkE4D7PERB4rhajYnD/66zZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578987306; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qY3PeCz5wjB/ojREnZXtoerIX3cZ4uqLpHntLjKx/0Q=; b=ZsbB3F2uIMS3HP27xBGZeZRJrVqrQHHDm9gLzZXSDC46BLIRNgDXpX9QG9Wt8DZ6adgqpbvFJ1SgDq1Qp62widlndPCyNpZRDMr/N+UsMGcN0fV8GNrYIExtReflqrvb7dfrWTl/8Ef62FmU8FYfVPfyTJfCKPyz+zzm8CoUkqQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1578987306782894.5881052700724; Mon, 13 Jan 2020 23:35:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-265-XS-bsT83M1mA2BJLlgUAfg-1; Tue, 14 Jan 2020 02:35:03 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 61E87800053; Tue, 14 Jan 2020 07:34:57 +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 DC922675AE; Tue, 14 Jan 2020 07:34:56 +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 B823B824F3; Tue, 14 Jan 2020 07:34:53 +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 00E7YpLb020044 for ; Tue, 14 Jan 2020 02:34:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id C71FB8886E; Tue, 14 Jan 2020 07:34:51 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F5D78177F for ; Tue, 14 Jan 2020 07:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578987305; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qY3PeCz5wjB/ojREnZXtoerIX3cZ4uqLpHntLjKx/0Q=; b=S34MWB7t6ACMnEDsGEjjZWxxbEkIoVxDc91wf40w+AzIh0DgpogoD+cXdC+JkbVbdH5Do5 keRxDxHZV2aE7clnl9ZP1/xFR9dZqtlBqwkiUUT7shy9TFgQ+TxvoibOD+lbYj9yD75WFl csmPwK/6+PK4Lr1DguJ7sxrcY3z8o0Y= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 14 Jan 2020 08:35:35 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/7] virbuftest: remove extra G_GNUC_UNUSED markers 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: , 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-MC-Unique: XS-bsT83M1mA2BJLlgUAfg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) These functions do use the opaque argument. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- tests/virbuftest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/virbuftest.c b/tests/virbuftest.c index 56a6ece8f6..f8eadea25a 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -244,7 +244,7 @@ struct testBufAddStrData { }; =20 static int -testBufAddStr(const void *opaque G_GNUC_UNUSED) +testBufAddStr(const void *opaque) { const struct testBufAddStrData *data =3D opaque; virBuffer buf =3D VIR_BUFFER_INITIALIZER; @@ -277,7 +277,7 @@ testBufAddStr(const void *opaque G_GNUC_UNUSED) =20 =20 static int -testBufEscapeStr(const void *opaque G_GNUC_UNUSED) +testBufEscapeStr(const void *opaque) { const struct testBufAddStrData *data =3D opaque; virBuffer buf =3D VIR_BUFFER_INITIALIZER; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 14:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578987305; cv=none; d=zohomail.com; s=zohoarc; b=gHVKyujgNmWrLSRvQcCR6XFwhRJAgC51CFWOamcPYUYl4qVFjnwt9evk51Em7ftMyjq4fkE6MQHFoRz3Yvmz2O5arB8R44orb5Ae/N7PpYcModQRkZBjqiASvsr/zLTpIlqFkI8JpMdEsePggXUcKnMmjDyc9n25JocZMnKl+Z0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578987305; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jKzeVzKgkzJVCUzhwmvmKekc/QSkSEjeLKiZp7GND3w=; b=blLzTAc/l0XNw+fqGG1HP/WQNzizpSuBGCvvJfd/dElkCa2/QSuIc6w0I4mJbl0qzkJZ9hrANUHzQmkCtS9QxGT5ok/2HsGosjiAXUhkOHI38xSzco/1wJredLLrVXo8QxwU6aLl+fiDiAJHXpN0v4W3I2+NryajhP6kV/ej0fM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1578987305821938.620787346503; Mon, 13 Jan 2020 23:35:05 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-122-ZiZNnPoHN4-W2u8-4TZBfw-1; Tue, 14 Jan 2020 02:35:02 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 761831800D48; Tue, 14 Jan 2020 07:34:57 +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 E664F19C70; Tue, 14 Jan 2020 07:34:56 +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 AF35718089CD; Tue, 14 Jan 2020 07:34:53 +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 00E7Yq2A020052 for ; Tue, 14 Jan 2020 02:34:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 978C48886E; Tue, 14 Jan 2020 07:34:52 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 202A38177F for ; Tue, 14 Jan 2020 07:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578987304; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jKzeVzKgkzJVCUzhwmvmKekc/QSkSEjeLKiZp7GND3w=; b=jLgCT0VniJfF/aSPASiZ5w1QijkUfRpAUX0/W/aOmM1leNvzXYldtltjcXCMxCKzBCzUH4 0bDrMR2X3SzdS0QpoiSnVfyTkWHgfQKWbUxLKk9+AnxmM1j0Ef4d25v5vF6KTb/oHFYVP3 2DhOvOV3AI95SE+Vb7qd50uXa+joKoE= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 14 Jan 2020 08:35:36 +0100 Message-Id: <6cc29e6bcc36bb103b333d1bb0ca548237132228.1578987257.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/7] virbuftest: use g_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: , 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-MC-Unique: ZiZNnPoHN4-W2u8-4TZBfw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- tests/virbuftest.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tests/virbuftest.c b/tests/virbuftest.c index f8eadea25a..2b241424ad 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -15,7 +15,7 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUS= ED) virBufferPtr buf =3D &bufinit; const char expected[] =3D " 1\n 2\n 3\n 4\n 5\n 6\n 7\n &\n 8\n 9\n 10\n ' 1= 1'\n"; - char *result =3D NULL; + g_autofree char *result =3D NULL; int ret =3D 0; =20 if (virBufferGetIndent(buf) !=3D 0 || @@ -85,7 +85,6 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUS= ED) virTestDifference(stderr, expected, result); ret =3D -1; } - VIR_FREE(result); return ret; } =20 @@ -93,7 +92,7 @@ static int testBufTrim(const void *data G_GNUC_UNUSED) { virBuffer bufinit =3D VIR_BUFFER_INITIALIZER; virBufferPtr buf =3D NULL; - char *result =3D NULL; + g_autofree char *result =3D NULL; const char *expected =3D "a,b"; int ret =3D -1; =20 @@ -123,7 +122,6 @@ static int testBufTrim(const void *data G_GNUC_UNUSED) =20 cleanup: virBufferFreeAndReset(buf); - VIR_FREE(result); return ret; } =20 @@ -133,7 +131,7 @@ static int testBufAddBuffer(const void *data G_GNUC_UNU= SED) virBuffer buf2 =3D VIR_BUFFER_INITIALIZER; virBuffer buf3 =3D VIR_BUFFER_INITIALIZER; int ret =3D -1; - char *result =3D NULL; + g_autofree char *result =3D NULL; const char *expected =3D \ " A long time ago, in a galaxy far,\n" \ " far away...\n" \ @@ -234,7 +232,6 @@ static int testBufAddBuffer(const void *data G_GNUC_UNU= SED) cleanup: virBufferFreeAndReset(&buf1); virBufferFreeAndReset(&buf2); - VIR_FREE(result); return ret; } =20 @@ -248,7 +245,7 @@ testBufAddStr(const void *opaque) { const struct testBufAddStrData *data =3D opaque; virBuffer buf =3D VIR_BUFFER_INITIALIZER; - char *actual; + g_autofree char *actual =3D NULL; int ret =3D -1; =20 virBufferAddLit(&buf, "\n"); @@ -271,7 +268,6 @@ testBufAddStr(const void *opaque) ret =3D 0; =20 cleanup: - VIR_FREE(actual); return ret; } =20 @@ -281,7 +277,7 @@ testBufEscapeStr(const void *opaque) { const struct testBufAddStrData *data =3D opaque; virBuffer buf =3D VIR_BUFFER_INITIALIZER; - char *actual; + g_autofree char *actual =3D NULL; int ret =3D -1; =20 virBufferAddLit(&buf, "\n"); @@ -304,7 +300,6 @@ testBufEscapeStr(const void *opaque) ret =3D 0; =20 cleanup: - VIR_FREE(actual); return ret; } =20 @@ -314,7 +309,7 @@ testBufEscapeRegex(const void *opaque) { const struct testBufAddStrData *data =3D opaque; virBuffer buf =3D VIR_BUFFER_INITIALIZER; - char *actual; + g_autofree char *actual =3D NULL; int ret =3D -1; =20 virBufferEscapeRegex(&buf, "%s", data->data); @@ -333,7 +328,6 @@ testBufEscapeRegex(const void *opaque) ret =3D 0; =20 cleanup: - VIR_FREE(actual); return ret; } =20 @@ -342,7 +336,7 @@ static int testBufSetIndent(const void *opaque G_GNUC_UNUSED) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; - char *actual; + g_autofree char *actual =3D NULL; int ret =3D -1; =20 virBufferSetIndent(&buf, 11); @@ -361,7 +355,6 @@ testBufSetIndent(const void *opaque G_GNUC_UNUSED) ret =3D 0; =20 cleanup: - VIR_FREE(actual); return ret; } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 14:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578987558; cv=none; d=zohomail.com; s=zohoarc; b=IWsApUrSpt9EjC4uXyLfrCmQnlSi4h9ue5hD9pj4vLbHLsiqbcxm0DZIhb8P0GzPpwMXznTyThKXoPDyYnIWHzjy2e/rsUYwbfHcqnyfgRTJBiy274pEe+3WqSSPDD3YlFEpmIVZTrYOqLeeNVSFyRJxGCCDJC0EITh51Fv50C4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578987558; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kDI8YxVzYSIlt0t5zyfNk+B+V6eScKzIsGMbC2jvE10=; b=UDhoV+FeHh2jxvztvvGHltzZZKB2j2blnKq+0hCW8VReZAW+mRpoV0Tj3aZFoEWn4ssbg5MG2XB/e3E3XC73pVI/zGFE7v83VqWDpWjiEq7JAvQ72jfDU38kalyEVEMi4vz+cS/7WUWEaEesII1gfGCd3pMkkLpeUUdytY4T81g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1578987558348302.1562526785119; Mon, 13 Jan 2020 23:39:18 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-334-F9bl4HBdNayRPx61njoqpQ-1; Tue, 14 Jan 2020 02:35:25 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 924DE18C8C00; Tue, 14 Jan 2020 07:35:19 +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 577AC10841A6; Tue, 14 Jan 2020 07:35:19 +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 E854418089D6; Tue, 14 Jan 2020 07:35:18 +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 00E7Yr0q020060 for ; Tue, 14 Jan 2020 02:34:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 688678886E; Tue, 14 Jan 2020 07:34:53 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id E60F88177F for ; Tue, 14 Jan 2020 07:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578987557; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kDI8YxVzYSIlt0t5zyfNk+B+V6eScKzIsGMbC2jvE10=; b=S0Y3fezg/37WdtneXjPdOLWxUmJhVVdOvB87FsD6CWbkNxhrABxHABtSNdQDlrjNVwdwaw /JrbQzyydPjpsLEYfBfDt+/Hrm3lWGS9qJNollM8fk1sfcEjd8x2ktQjVa/HIXjYT8c9F+ bjK1SFXwvR/OD4+L1bj3CZafXMaz7T0= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 14 Jan 2020 08:35:37 +0100 Message-Id: <203578ea9ef1eb9cbacf4f7314daf67cbf98c2b8.1578987257.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/7] virbuftest: remove unnecessary labels 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: F9bl4HBdNayRPx61njoqpQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Remove the ret variables and labels from functions that no longer need them. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- tests/virbuftest.c | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/tests/virbuftest.c b/tests/virbuftest.c index 2b241424ad..bb7fa9e2e9 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -246,7 +246,6 @@ testBufAddStr(const void *opaque) const struct testBufAddStrData *data =3D opaque; virBuffer buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *actual =3D NULL; - int ret =3D -1; =20 virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); @@ -256,19 +255,16 @@ testBufAddStr(const void *opaque) =20 if (!(actual =3D virBufferContentAndReset(&buf))) { VIR_TEST_DEBUG("buf is empty"); - goto cleanup; + return -1; } =20 if (STRNEQ_NULLABLE(actual, data->expect)) { VIR_TEST_DEBUG("testBufAddStr(): Strings don't match:"); virTestDifference(stderr, data->expect, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -278,7 +274,6 @@ testBufEscapeStr(const void *opaque) const struct testBufAddStrData *data =3D opaque; virBuffer buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *actual =3D NULL; - int ret =3D -1; =20 virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); @@ -288,19 +283,16 @@ testBufEscapeStr(const void *opaque) =20 if (!(actual =3D virBufferContentAndReset(&buf))) { VIR_TEST_DEBUG("buf is empty"); - goto cleanup; + return -1; } =20 if (STRNEQ_NULLABLE(actual, data->expect)) { VIR_TEST_DEBUG("testBufEscapeStr(): Strings don't match:"); virTestDifference(stderr, data->expect, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -310,25 +302,21 @@ testBufEscapeRegex(const void *opaque) const struct testBufAddStrData *data =3D opaque; virBuffer buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *actual =3D NULL; - int ret =3D -1; =20 virBufferEscapeRegex(&buf, "%s", data->data); =20 if (!(actual =3D virBufferContentAndReset(&buf))) { VIR_TEST_DEBUG("testBufEscapeRegex: buf is empty"); - goto cleanup; + return -1; } =20 if (STRNEQ_NULLABLE(actual, data->expect)) { VIR_TEST_DEBUG("testBufEscapeRegex: Strings don't match:"); virTestDifference(stderr, data->expect, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -337,7 +325,6 @@ testBufSetIndent(const void *opaque G_GNUC_UNUSED) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *actual =3D NULL; - int ret =3D -1; =20 virBufferSetIndent(&buf, 11); virBufferAddLit(&buf, "test\n"); @@ -345,17 +332,14 @@ testBufSetIndent(const void *opaque G_GNUC_UNUSED) virBufferAddLit(&buf, "test2\n"); =20 if (!(actual =3D virBufferContentAndReset(&buf))) - goto cleanup; + return -1; =20 if (STRNEQ(actual, " test\n test2\n")) { VIR_TEST_DEBUG("testBufSetIndent: expected indent not set"); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 14:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578987334; cv=none; d=zohomail.com; s=zohoarc; b=X27+cvrrNUJP0YZTKw451mMpfSXFM4Vo4OkthvSqgDvdZdZVmfchZ+B1vJB5xCliq3ffBgROob25yBGU3UHJJIXfmcsiXTzXnbb294RY0IDeFUbeyVnw91VZ/vQXneblA+GS+aMFdehvvZJTM1QroDieauiuWrbiSlOJCVzmIfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578987334; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wUNRo4s/tCRcI0YIkw5+eyxioWptrP4I4e8aXeZ1ejg=; b=A7Yv6pAvGe1VsZ69RGWe3pmHXGUGhBQt1Fo13yhzhEkTGLWbqdM0+4z1HzM2XZTXntrNcO0sRr/vIu8dckSEEindiVtS0K7XbHcCF5/pJpwTbviUFSoBQBXeqnJBGmQZ5XgHAc11YVDtFkvCMj+zl5dA/fBcrz5KERoKRqc54Lk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1578987334037359.5400628938197; Mon, 13 Jan 2020 23:35:34 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-148-zadzZqqmPWSV8Oswn86LiA-1; Tue, 14 Jan 2020 02:35:30 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2049C18C8C05; Tue, 14 Jan 2020 07:35:24 +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 EA103A4B60; Tue, 14 Jan 2020 07:35:23 +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 964894E166; Tue, 14 Jan 2020 07:35:23 +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 00E7Yseu020069 for ; Tue, 14 Jan 2020 02:34:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 396968177F; Tue, 14 Jan 2020 07:34:54 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id B692988872 for ; Tue, 14 Jan 2020 07:34:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578987332; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wUNRo4s/tCRcI0YIkw5+eyxioWptrP4I4e8aXeZ1ejg=; b=HYKSbt3HagaWNZ7Ut8Zc28+R6w6A4hMR5sRmiup4fIYZF49Ob0L3+DVBcVtS/jacGlUf4z //ZzOY6O0O6OJIqhhL5mv6GQ2GqHv2fKve3uNvhVMW7d2rQOw6OiqBBcx1CkQbbJLkdw/A 7p3RQuGYix+0tWvND5EnSRL3bE//R00= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 14 Jan 2020 08:35:38 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/7] virbuftest: declare testBufAddStrData earlier 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: , 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-MC-Unique: zadzZqqmPWSV8Oswn86LiA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Move the declaration to the beginning of the file for reuse. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- tests/virbuftest.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/virbuftest.c b/tests/virbuftest.c index bb7fa9e2e9..bb606c1c28 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -9,6 +9,11 @@ =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 +struct testBufAddStrData { + const char *data; + const char *expect; +}; + static int testBufAutoIndent(const void *data G_GNUC_UNUSED) { virBuffer bufinit =3D VIR_BUFFER_INITIALIZER; @@ -235,11 +240,6 @@ static int testBufAddBuffer(const void *data G_GNUC_UN= USED) return ret; } =20 -struct testBufAddStrData { - const char *data; - const char *expect; -}; - static int testBufAddStr(const void *opaque) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 14:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578987324; cv=none; d=zohomail.com; s=zohoarc; b=K71jbXcSm03fM+GYSqNIvIdC4MNF/A38i5oBiEUTsAYrd6zdwb4a9k2Cd2cZ9MyC/TT2njqu0W2CmD7gQbuEo3nylbJIaOJ8cceMUr0C6oA1Y3YXYbj5QP9cJypNd9l/b0J6n/mMvIfJVkhLtqp105G92DYHYv9mYMJSyPrvfSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578987324; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fytPvWhrd6RZPCAiAtfD6oTcOSh6GeG+Pehojc3N8mo=; b=JilvAswi1WWzgJDLBQoSErfKb4rI/uxT7lu0nVT4A/uo739pr1YmYjLPDr1PzzNUb7d4gjMQbOgfhS/5PYLGBFq1g5Ffr2OoxqP/t3G8GGBuSvuXZa5RKqYNJk5liFFN+F2KireR1x5P64WXrdsbcegMGiH6ZmYuwKS/5wrXE20= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1578987324226188.69113575919255; Mon, 13 Jan 2020 23:35:24 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-47-2tdiSRccNHKYm_nePeqMeg-1; Tue, 14 Jan 2020 02:35:21 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0DE0800D41; Tue, 14 Jan 2020 07:35:15 +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 88C775C1BB; Tue, 14 Jan 2020 07:35:15 +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 281A5825C4; Tue, 14 Jan 2020 07:35:15 +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 00E7Yt8O020083 for ; Tue, 14 Jan 2020 02:34:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0C1408177F; Tue, 14 Jan 2020 07:34:55 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 869488886A for ; Tue, 14 Jan 2020 07:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578987323; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fytPvWhrd6RZPCAiAtfD6oTcOSh6GeG+Pehojc3N8mo=; b=dQHZjL9AqvnAkK0Ys35kyDZZ8yT2uE4iy3aNkkiiAw1rfDBHaPCZXUbOW8c4g8edKQjSwC YTBzBHzZE+acREfF4iynaBrp0hyHfKAW84tUO31uZHkyCdATIEADeDaowJ8fi6EiA0tzqA Ep9bBN7kbQ22FIYDIkBgVGOXpjaeqBU= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 14 Jan 2020 08:35:39 +0100 Message-Id: <81a87c07756289092b5d71fd2170f0eed0f30e10.1578987257.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/7] virbuftest: use field names when initalizing test info 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: 2tdiSRccNHKYm_nePeqMeg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Allow adding new fields without changing all the macros. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- tests/virbuftest.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/virbuftest.c b/tests/virbuftest.c index bb606c1c28..1780b62bf4 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -372,9 +372,9 @@ mymain(void) DO_TEST("set indent", testBufSetIndent); DO_TEST("autoclean", testBufferAutoclean); =20 -#define DO_TEST_ADD_STR(DATA, EXPECT) \ +#define DO_TEST_ADD_STR(_data, _expect) \ do { \ - struct testBufAddStrData info =3D { DATA, EXPECT }; \ + struct testBufAddStrData info =3D { .data =3D _data, .expect =3D _= expect }; \ if (virTestRun("Buf: AddStr", testBufAddStr, &info) < 0) \ ret =3D -1; \ } while (0) @@ -384,9 +384,9 @@ mymain(void) DO_TEST_ADD_STR("\n", "\n \n"); DO_TEST_ADD_STR("\n \n\n", "\n \n \n \n= "); =20 -#define DO_TEST_ESCAPE(data, expect) \ +#define DO_TEST_ESCAPE(_data, _expect) \ do { \ - struct testBufAddStrData info =3D { data, expect }; \ + struct testBufAddStrData info =3D { .data =3D _data, .expect =3D _= expect }; \ if (virTestRun("Buf: EscapeStr", testBufEscapeStr, &info) < 0) \ ret =3D -1; \ } while (0) @@ -400,9 +400,9 @@ mymain(void) DO_TEST_ESCAPE("\x01\x01\x02\x03\x05\x08", "\n \n"); =20 -#define DO_TEST_ESCAPE_REGEX(data, expect) \ +#define DO_TEST_ESCAPE_REGEX(_data, _expect) \ do { \ - struct testBufAddStrData info =3D { data, expect }; \ + struct testBufAddStrData info =3D { .data =3D _data, .expect =3D _= expect }; \ if (virTestRun("Buf: EscapeRegex", testBufEscapeRegex, &info) < 0)= \ ret =3D -1; \ } while (0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 14:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578987337; cv=none; d=zohomail.com; s=zohoarc; b=dO29JgWIgVk/jckcal+ngB5qNb3ttYgFK0RO5fLZ/+p1ajFm1YUCXZJFCkj1RPu2iRZrWL9YR4CbUt2CcJJB29szq1ScrzrS8EpXbRZGsdwoL+pwyrMHzTMEzdTV0Y+uf0e2PsquNStU/9mO5zUU0ghmpmNthAJmXtwGJgh4GnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578987337; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rrXFdUHSLTwjcNB1rEjwWu2dABF+hB+QSPAa0UdqSVg=; b=QuRINfH4sPCsglb8l39atgfa91CAxqVVzzHCjeAuyr4ND27F3jf5skH0hj7X1Piiu7whbg8Rixn3NpOiSzacpojOk2OV2CKUxpScrlfWXXJGUpE4uzd9aXCJPwRzUyeWC+N8wFNY6QvhIUPSGQ4e+C3FRUfmbFB/57baChdlye8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1578987337037492.9887942386699; Mon, 13 Jan 2020 23:35:37 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-440--NAWeiRPOAe9CVX3TlvWtw-1; Tue, 14 Jan 2020 02:35:33 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5968918C8C01; Tue, 14 Jan 2020 07:35:28 +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 281455C1B0; Tue, 14 Jan 2020 07:35:28 +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 C623318089D6; Tue, 14 Jan 2020 07:35:27 +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 00E7YtlW020089 for ; Tue, 14 Jan 2020 02:34:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id D064787EFE; Tue, 14 Jan 2020 07:34:55 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 586A18177F for ; Tue, 14 Jan 2020 07:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578987335; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rrXFdUHSLTwjcNB1rEjwWu2dABF+hB+QSPAa0UdqSVg=; b=Or6eM55RwhalOZ8dSuF3XGyKrPMNZoqj+QgMvDRCR0BMHY675Cmwll3gdDmp+ua+tX9u+e un79gdg8mN0vjRxsGCBiDtbw/b4+YBUYbiVdGTPl/wAXfBklJZit4sUns7rimVCjBsPoE7 g4eLMrSXMe0yiFCBhv62+yiontzR4gU= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 14 Jan 2020 08:35:40 +0100 Message-Id: <018127cd165e8fe66f8f9f2692cbc186d2f15a76.1578987257.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/7] util: add virBufferTrimChars 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: -NAWeiRPOAe9CVX3TlvWtw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) A new helper for trimming combinations of specified characters from the tail of the buffer. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/libvirt_private.syms | 1 + src/util/virbuffer.c | 26 ++++++++++++++++++++++++++ src/util/virbuffer.h | 1 + tests/virbuftest.c | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b97906b852..f46ed29eac 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1642,6 +1642,7 @@ virBufferSetIndent; virBufferStrcat; virBufferStrcatVArgs; virBufferTrim; +virBufferTrimChars; virBufferURIEncodeString; virBufferUse; virBufferVasprintf; diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c index 1b93110919..914c386b18 100644 --- a/src/util/virbuffer.c +++ b/src/util/virbuffer.c @@ -673,6 +673,32 @@ virBufferTrim(virBufferPtr buf, const char *str, int l= en) g_string_truncate(buf->str, buf->str->len - len); } =20 +/** + * virBufferTrimChars: + * @buf: the buffer to trim + * @trim: the characters to be trimmed + * + * Trim the tail of the buffer. The longest string that can be formed with + * the characters from @trim is trimmed. + */ +void +virBufferTrimChars(virBufferPtr buf, const char *trim) +{ + ssize_t i; + + if (!buf || !buf->str) + return; + + if (!trim) + return; + + for (i =3D buf->str->len - 1; i > 0; i--) { + if (!strchr(trim, buf->str->str[i])) + break; + } + + g_string_truncate(buf->str, i + 1); +} =20 /** * virBufferAddStr: diff --git a/src/util/virbuffer.h b/src/util/virbuffer.h index 38758a9125..183f78f279 100644 --- a/src/util/virbuffer.h +++ b/src/util/virbuffer.h @@ -92,4 +92,5 @@ size_t virBufferGetIndent(const virBuffer *buf); size_t virBufferGetEffectiveIndent(const virBuffer *buf); =20 void virBufferTrim(virBufferPtr buf, const char *trim, int len); +void virBufferTrimChars(virBufferPtr buf, const char *trim); void virBufferAddStr(virBufferPtr buf, const char *str); diff --git a/tests/virbuftest.c b/tests/virbuftest.c index 1780b62bf4..7919075000 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -12,6 +12,7 @@ struct testBufAddStrData { const char *data; const char *expect; + const char *arg; }; =20 static int testBufAutoIndent(const void *data G_GNUC_UNUSED) @@ -130,6 +131,30 @@ static int testBufTrim(const void *data G_GNUC_UNUSED) return ret; } =20 +static int +testBufTrimChars(const void *opaque) +{ + const struct testBufAddStrData *data =3D opaque; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_autofree char *actual =3D NULL; + + virBufferAddStr(&buf, data->data); + virBufferTrimChars(&buf, data->arg); + + if (!(actual =3D virBufferContentAndReset(&buf))) { + VIR_TEST_DEBUG("buf is empty"); + return -1; + } + + if (STRNEQ_NULLABLE(actual, data->expect)) { + VIR_TEST_DEBUG("testBufEscapeStr(): Strings don't match:"); + virTestDifference(stderr, data->expect, actual); + return -1; + } + + return 0; +} + static int testBufAddBuffer(const void *data G_GNUC_UNUSED) { virBuffer buf1 =3D VIR_BUFFER_INITIALIZER; @@ -411,6 +436,17 @@ mymain(void) DO_TEST_ESCAPE_REGEX("^$.|?*+()[]{}\\", "\\^\\$\\.\\|\\?\\*\\+\\(\\)\\[\\]\\{\\}\\\\"); =20 +#define DO_TEST_TRIM_CHARS(_data, _arg, _expect) \ + do { \ + struct testBufAddStrData info =3D { .data =3D _data, .expect =3D _= expect, .arg =3D _arg }; \ + if (virTestRun("Buf: Trim: " #_data, testBufTrimChars, &info) < 0)= \ + ret =3D -1; \ + } while (0) + + DO_TEST_TRIM_CHARS("Trimmm", "m", "Tri"); + DO_TEST_TRIM_CHARS("-abcd-efgh--", "-", "-abcd-efgh"); + DO_TEST_TRIM_CHARS("-hABC-efgh--", "-h", "-hABC-efg"); + return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 14:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578987323; cv=none; d=zohomail.com; s=zohoarc; b=fH3OBoosV+dWeudI6OgwQp0nAbTEdtqIxBpgOmgVWf+pg4+8FeEZS7yP8uAcOR+Cm1w6x8Hd5zGlLFN0OQfqE1NM7Fx4JTkXmziFB9+AyKymF7ar6nHACWKWcYSZHzh87Yuo8p4b9WYlkfdkFXv+KNJ844UxOCjVfGYeKevDuWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578987323; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XhUlmdkeSVovRwK/eoBMq9HZizLhl3UvA1H56X13G6A=; b=Z73ESNBwZ9QedosiWWdoEqn0ZT+w+Tozug/c6d9dUa8V6+4zkeDdzeny7WP+DB5Ei24tigHO2+EE1SV62ji0tNGqKsHD6ERtRGTqk2jmuLLt+kuIc8CbQHO63SvhAENJsbmQYRxEXZO3Xmu+8/DLinIfHTeo8d5V4bMtswcGcoI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1578987323641207.35428604845492; Mon, 13 Jan 2020 23:35:23 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-145-IrwaIZOgNq2DBn9oXuKITQ-1; Tue, 14 Jan 2020 02:35:21 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 56154477; Tue, 14 Jan 2020 07:35:15 +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 264591081333; Tue, 14 Jan 2020 07:35:15 +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 C342518089D0; Tue, 14 Jan 2020 07:35:14 +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 00E7YuJ3020103 for ; Tue, 14 Jan 2020 02:34:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id A3BD187EFE; Tue, 14 Jan 2020 07:34:56 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A4618177F for ; Tue, 14 Jan 2020 07:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578987322; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XhUlmdkeSVovRwK/eoBMq9HZizLhl3UvA1H56X13G6A=; b=aM0r6zQT5KaICjO6fDx9n3B4OnlQkAu1AQHENi1VyoYAmRkzuLo7Tg3Ju8sodmHk/yvB3a MzNVnqjoL2VgXt5WrJq3aYFkoJW391eOefSIeEBwJ1PxWe29alnOaSmH3U9bMNYoESnCAA LBhS+PHSqGs0qecKluYbLfbC0QT+p3g= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 14 Jan 2020 08:35:41 +0100 Message-Id: <5f45d74b79c582a5a4c73c160d2b9ba7aae1ad4a.1578987257.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/7] conf: do not generate machine names ending with a dash 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: IrwaIZOgNq2DBn9oXuKITQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) As of systemd commit: commit d65652f1f21a4b0c59711320f34266c635393c89 Author: Zbigniew J=C4=99drzejewski-Szmek CommitDate: 2018-12-10 09:56:56 +0100 Partially unify hostname_is_valid() and dns_name_is_valid() Dashes are no longer allowed at the end of machine names. Trim the trailing dashes from the generated name before passing it to machined. https://bugzilla.redhat.com/show_bug.cgi?id=3D1790409 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/conf/domain_conf.c | 3 +++ tests/virsystemdtest.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1290241923..512b7c49d2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30467,6 +30467,9 @@ virDomainMachineNameAppendValid(virBufferPtr buf, =20 virBufferAddChar(buf, *name); } + + /* trailing dashes are not allowed */ + virBufferTrimChars(buf, "-"); } =20 #undef HOSTNAME_CHARS diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c index 9b95ca6789..26876850b8 100644 --- a/tests/virsystemdtest.c +++ b/tests/virsystemdtest.c @@ -740,6 +740,10 @@ mymain(void) "qemu-7-1234567890123456789012345678901234567890123456789= 01234567"); TEST_MACHINE("12345678901234567890123456789012345678901234567890123456= 7890", 8, "qemu-8-1234567890123456789012345678901234567890123456789= 01234567"); + TEST_MACHINE("kstest-network-device-default-httpks_(c9eed63e-981e-48ec= -acdc-56b3f8c5f678)", 100, + "qemu-100-kstest-network-device-default-httpksc9eed63e-98= 1e-48ec"); + TEST_MACHINE("kstest-network-device-default-httpks_(c9eed63e-981e-48ec= --cdc-56b3f8c5f678)", 10, + "qemu-10-kstest-network-device-default-httpksc9eed63e-981= e-48ec"); =20 # define TESTS_PM_SUPPORT_HELPER(name, function) \ do { \ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list