From nobody Sat May 4 23:23:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573660095; cv=none; d=zoho.com; s=zohoarc; b=RBSksBIj0ZlOF2VUQLy1x/QWg+vQ6F0JC7IiECmfMJ12EGoTyTNemuZ4k3WEgIrHCT4m1huToGvrAWvjh9Cs8byf60dhQ3bvoGFg7Sd3r+I9vBTcwC1yheSUNiLZq7QvD9UIQTEo86bvqOeTTuwR0jVHapVO+S+c0wP+PVvl6zs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573660095; 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=SHvm0cmY7Nk1+QMSyKNBdLYYaHd8JPp4i+s6mt5fHCA=; b=jS1Alr/49G3QYjsAK2t19FEOdaLlvSsgHvgt9XzVywIoLxEmJIKjSlm14flHsz4htCevza87ZQBYgfBS4qjmfJ+54Ts6Ooche5upfhEL+RuGzoEg+d4D/cak6JKS4naAAcJUdKEMo9IQUnl5a7HUfMmNHY5pKznbU35it16wq9c= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1573660095966555.9992787344424; Wed, 13 Nov 2019 07:48:15 -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-365-1b49LjecPCKVIiK6dRf2fQ-1; Wed, 13 Nov 2019 10:48:12 -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 3ECA0DB5B; Wed, 13 Nov 2019 15:48:05 +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 CCCFC46462; Wed, 13 Nov 2019 15:48:04 +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 6A6D94BB65; Wed, 13 Nov 2019 15:48:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADFm0ih017588 for ; Wed, 13 Nov 2019 10:48:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id E3C49101E814; Wed, 13 Nov 2019 15:48:00 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-61.brq.redhat.com [10.40.200.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48FFF10027B9 for ; Wed, 13 Nov 2019 15:48:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573660094; 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=SHvm0cmY7Nk1+QMSyKNBdLYYaHd8JPp4i+s6mt5fHCA=; b=hTcnkkGldsLvPt2qkMuLrvGw/hPQhrcPWzbkRd0nKshHVsw8lLTnnUJe51ZjsjjY6VtmyY ZgjnMdVuCBcQBYXT1qdwblU8jmju2K9sYaC+xu1e9zq1Gtz/mSGK/NVjZZxIRfNcD258hB mxeQmtlr2Hmpml7NzLuGP4Kl15xq7sY= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 16:48:42 +0100 Message-Id: <8123fd023f61eed1d9f0fcf7f9856337d41f08d3.1573660076.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/12] libxl: do not use G_REGEX_EXTENDED 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: 1b49LjecPCKVIiK6dRf2fQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This flag is not needed to use extended regular expression syntax with GRegex and it makes GRegex ignore whitespace in the regex. Remove the unintended usage, even though it should not matter in this case. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/libxl/libxl_capabilities.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index fe792e9a82..0fb9c0b344 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -397,7 +397,7 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps) return -1; } =20 - regex =3D g_regex_new(XEN_CAP_REGEX, G_REGEX_EXTENDED, 0, &err); + regex =3D g_regex_new(XEN_CAP_REGEX, 0, 0, &err); if (!regex) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to compile regex %s"), err->message); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:23:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573660109; cv=none; d=zoho.com; s=zohoarc; b=gflNb695qowL7gj5MWX3KfD33gsUQXNHmMxg/71fs32X/p7+lXb7HsZHCC69DH7itrESaiOsfiEcEMv0eeyyq173vJMLus90PAS8HYVT7RpZUdN9Id9XjZv/CKOZI9YKjGPcJf/h073BMs8U5jdU1Sv3gZdnAbk5oXUeRW5ckuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573660109; 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=K+csR528+zq1kzLvEMpe7N67bJ93AZIehc3Qw0vrcLw=; b=YTwt2SOFw1gmTkwWAThBELazWAWrOlCNyL3Q/uj/URP26akPWPgGdFwAEBRcKFJnibbdYt/Ij1tJfrM0HQ8iAL1mMxgwdMa/KDf7er8pHLisMk+qZlue3nHoZ1rHrg+Xc+UB10TcLK4jl4P9XfOq2fKVQ+nBHmJUrb/FKG3i4G4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1573660109719174.9908025115286; Wed, 13 Nov 2019 07:48:29 -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-375-T0ivUlkoNA6U-DUJ7YucmQ-1; Wed, 13 Nov 2019 10:48:22 -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 878471949B36; Wed, 13 Nov 2019 15:48:16 +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 5E53910246F8; Wed, 13 Nov 2019 15:48:16 +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 1665318034EF; Wed, 13 Nov 2019 15:48:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADFm1JQ017600 for ; Wed, 13 Nov 2019 10:48:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id EF565101E814; Wed, 13 Nov 2019 15:48:01 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-61.brq.redhat.com [10.40.200.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5382010027B9 for ; Wed, 13 Nov 2019 15:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573660108; 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=K+csR528+zq1kzLvEMpe7N67bJ93AZIehc3Qw0vrcLw=; b=AwHhyu3f4YhJ9qv714s1tTVBrcU6huXmkzYxNNqL07K4AIVjpdz3HGr/Qr+iPV1KFNKU6B cC/528TI1d5So+Bpv5lMXwcZHp6aVXiG8CT7tuvb9WzGOKiCh9jKqRmjlRpgqzg2Qu30Je fRczeo+01N6yZmECJxnR1GEwwRQYObY= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 16:48:43 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/12] remove unused regex.h includes 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: T0ivUlkoNA6U-DUJ7YucmQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The code using regexes got moved, but the include stayed. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/libxl/libxl_driver.c | 1 - src/storage/storage_util.c | 1 - src/util/viriscsi.c | 2 -- src/util/virnetdevtap.c | 1 - tests/testutils.c | 1 - 5 files changed, 6 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 277d99b2b0..ec6a010030 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -27,7 +27,6 @@ #include #include #include -#include =20 #include "internal.h" #include "virlog.h" diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index f91c2c64ee..9ba9bb2a57 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -18,7 +18,6 @@ =20 #include =20 -#include #include #include #include diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c index 9f4c8f4e03..da27894b0b 100644 --- a/src/util/viriscsi.c +++ b/src/util/viriscsi.c @@ -22,8 +22,6 @@ =20 #include =20 -#include - #include "viriscsi.h" =20 #include "viralloc.h" diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index aea4c91a6a..445aaa2727 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -32,7 +32,6 @@ #include "datatypes.h" =20 #include -#include #include #include #include diff --git a/tests/testutils.c b/tests/testutils.c index a3bedd0fef..3cd3391dfa 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include "testutils.h" --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:23:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573660114; cv=none; d=zoho.com; s=zohoarc; b=CPEGElZxi4CJlWxcybM1JnMiZYS3ZIp9n617JYtaUWXeAYTH0yhYJE8Kck4Pfe1gI7BsviZF8edMQsI492FtW35JJFi8DhPp5ZIxJTxdO9pDEhSW8rdUnoQELXS34qoJ7z+efVzbNEfe9R6fyhLrLagAI4RyVL2txWOFzU3wpQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573660114; 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=ooHbHN+JmZuZEWjXFk6tc3d4o1+3LIEhA+sUck7mAVM=; b=R7ywEnMDHcByJxGMEnyZanEW+1rFlRA0A0eZJHJpbxf3eTwJR4eKfSSfJBJxwgbNED3EgepIkaivdW8Y2ywO024yL8kVzYe1Z90t+BgWfdRTypcnhPmJX8Rq4R+XVAFRPkBRZ7Cmny3l7MZ2Us82aXd5xk3lheLyEFqQztvCNLQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1573660114260833.4025325981314; Wed, 13 Nov 2019 07:48: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-200-83xRhIAkOBCRXq-nQTxPLg-1; Wed, 13 Nov 2019 10:48:31 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2F0438D02AD; Wed, 13 Nov 2019 15:48:20 +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 053BE5E25C; Wed, 13 Nov 2019 15:48:20 +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 AFFAA4E56C; Wed, 13 Nov 2019 15:48:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADFm3Fj017609 for ; Wed, 13 Nov 2019 10:48:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 079FE10246F6; Wed, 13 Nov 2019 15:48:03 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-61.brq.redhat.com [10.40.200.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F2F1101E814 for ; Wed, 13 Nov 2019 15:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573660113; 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=ooHbHN+JmZuZEWjXFk6tc3d4o1+3LIEhA+sUck7mAVM=; b=PosBcVyEV7MuVMY9Tj+IHL/u3ZffOxUu4GhyExlZ18Kbow+3YEfKeAttANzZ7oS/e6n0ye NzERH84i9lhvsY6ZnuvJscGM4U9cREJwSsE3PXQ00zyza2er1W34JeXC57Qy0WaAt3aDJT Rih/WXGnP9a5et+t8spD132eKl3nplg= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 16:48:44 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/12] libxl: use GRegex in libxlGetAutoballoonConf 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.14 X-MC-Unique: 83xRhIAkOBCRXq-nQTxPLg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace the use of regcomp with GRegex. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/libxl/libxl_conf.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 920f228d6a..be7d85b264 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -22,7 +22,6 @@ =20 #include =20 -#include #include #include #include @@ -1664,7 +1663,8 @@ static int libxlGetAutoballoonConf(libxlDriverConfigPtr cfg, virConfPtr conf) { - regex_t regex; + g_autoptr(GRegex) regex =3D NULL; + g_autoptr(GError) err =3D NULL; int res; =20 res =3D virConfGetValueBool(conf, "autoballoon", &cfg->autoballoon); @@ -1673,21 +1673,15 @@ libxlGetAutoballoonConf(libxlDriverConfigPtr cfg, else if (res =3D=3D 1) return 0; =20 - if ((res =3D regcomp(®ex, - "(^| )dom0_mem=3D((|min:|max:)[0-9]+[bBkKmMgG]?,?)+(= $| )", - REG_NOSUB | REG_EXTENDED)) !=3D 0) { - char error[100]; - regerror(res, ®ex, error, sizeof(error)); + regex =3D g_regex_new("(^| )dom0_mem=3D((|min:|max:)[0-9]+[bBkKmMgG]?,= ?)+($| )", + 0, 0, &err); + if (!regex) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to compile regex %s"), - error); - + _("Failed to compile regex %s"), err->message); return -1; } =20 - res =3D regexec(®ex, cfg->verInfo->commandline, 0, NULL, 0); - regfree(®ex); - cfg->autoballoon =3D res =3D=3D REG_NOMATCH; + cfg->autoballoon =3D !g_regex_match(regex, cfg->verInfo->commandline, = 0, NULL); return 0; } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:23:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573660120; cv=none; d=zoho.com; s=zohoarc; b=BV2u4T6CqC6TXnsP+tYXlDa0y5RKWpYsIa97F0ukIXCRQflVJAPVCPiAPMwYd6pm0GaUB5uWm5vlzuG3gQyym2n8O2bfO/vjy8WkvvVL4fZZEBSv2+lMsO7zqwN+OzFhcuJyQbVA+h5oY4ghltWWTEzo1A51H8Ithr5jG0xQ3NQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573660120; 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=YP0Vo5HlEYo15ztYd0JmEtQ4QCls0cL+FmSOpKU0Oc8=; b=S9XMcLJ92y/uafIjpZwmxgPaxPg/qsPMMr0h1SjGuU87E5Jv7n377sVsRiKadB+IqEEQIC/+/cARczO203BTEEfkinMh/JVioy7LkZWRkLe8UOyNTjPncUg05K8sM5nQzCJ6KmzO8d1RiXyOHWRvseizssMH0aGk4jzLexaHQF0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1573660120074839.6792533495908; Wed, 13 Nov 2019 07:48:40 -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-36-CP-DpXazOAaec_qshOM0jw-1; Wed, 13 Nov 2019 10:48:37 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2C468D02D6; Wed, 13 Nov 2019 15:48:23 +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 9636360C88; Wed, 13 Nov 2019 15:48: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 570FB18034EB; Wed, 13 Nov 2019 15:48:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADFm4hS017617 for ; Wed, 13 Nov 2019 10:48:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0F4B010246F6; Wed, 13 Nov 2019 15:48:04 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-61.brq.redhat.com [10.40.200.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AAAD10246E3 for ; Wed, 13 Nov 2019 15:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573660118; 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=YP0Vo5HlEYo15ztYd0JmEtQ4QCls0cL+FmSOpKU0Oc8=; b=DpZiXkYOEDiTK6rAq2OrrawKUEbh8WlJZJLOkPD2PRldhFhkGurX1LIltcMxG3dH57NPHV jpzikzfKwwxZxnT3asTP7CwIWNwrlVCLA09LGeaNCt2gcDgbnaVtRU+h/Momyz2sBvKUlc O4QO3i7r+k45zKmgbA1LNOVJouNJytg= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 16:48:45 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/12] libxl: use g_autofree in xenParseSxprVifRate 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.12 X-MC-Unique: CP-DpXazOAaec_qshOM0jw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/libxl/xen_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index c31a5c952e..c06ab6e995 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -1060,7 +1060,7 @@ static const char *vif_bytes_per_sec_re =3D "^[0-9]+[= GMK]?[Bb]/s$"; static int xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec) { - char *trate =3D NULL; + g_autofree char *trate =3D NULL; char *p; regex_t rec; int err; @@ -1109,7 +1109,6 @@ xenParseSxprVifRate(const char *rate, unsigned long l= ong *kbytes_per_sec) =20 cleanup: regfree(&rec); - VIR_FREE(trate); 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 May 4 23:23:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573660105; cv=none; d=zoho.com; s=zohoarc; b=KSsdKFx7DN06OwyyTGzoNSTZQIooKdDBLALmjfvuohmiQJjVNg2qTzTDeDPPIXV6AGmt3Il0WlWRH6RtEwzgUXT2TvGnZepyqLsI7RFhIV8lMy5fNEjybwpady4ceoTXExLGFVe2WT0SftnxrwFDhhQWv9AvhdRbHDSgF5MyhS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573660105; 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=J4aLkAL1qw6IU3jE+Glh0cfoi2CcwSe72V5RWw2JAZE=; b=VHUoDm6YZcBa4Wm19yMA/hxSm7hfpf2IV0vN1uvwxf+K3MedLo/dp3VInINVRVP42hT0w0ga/PL94zVGkl+UMax8NvbZFq2J9G0fI6rj5kuL3rzT+cz+KDLabCyz0eA61FAyTyo7fRdLPX3V8CclCUjSLXwqqRHkqPjTyMihTfw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1573660105946208.60829703271668; Wed, 13 Nov 2019 07:48:25 -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-73-CwC9WfKrNhaBBpUBf0XZ6w-1; Wed, 13 Nov 2019 10:48:22 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 819DBDC13; Wed, 13 Nov 2019 15:48:16 +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 5B8D560474; Wed, 13 Nov 2019 15:48:16 +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 1567518034EE; Wed, 13 Nov 2019 15:48:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADFm8oR017643 for ; Wed, 13 Nov 2019 10:48:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0787F10246FB; Wed, 13 Nov 2019 15:48:08 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-61.brq.redhat.com [10.40.200.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D15310246EA for ; Wed, 13 Nov 2019 15:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573660104; 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=J4aLkAL1qw6IU3jE+Glh0cfoi2CcwSe72V5RWw2JAZE=; b=Owbp6I5NL4uxJPGTgyuEVcXAYu1qPG2P7PrcNtxUBTwOjmG+GC0OeUCTJDHa7obQ+COix+ jAGhjZmZTJjT1jdksSQFKXqSrZib9svoeKa3JXndrn1QRnTAGqMnwrPTnbWCNFdLkcCKIC qRVHMSaxToTa/woN9DCztt6/VYm6D9E= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 16:48:46 +0100 Message-Id: <9575a786f621dd49cc8056b12ee93f7d6a750b9d.1573660076.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/12] libxl: use GRegex in xenParseSxprVifRate 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.11 X-MC-Unique: CwC9WfKrNhaBBpUBf0XZ6w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use GRegex from GLib instead of regcomp. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/libxl/xen_common.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index c06ab6e995..15a2db8add 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -24,8 +24,6 @@ =20 #include =20 -#include - #include "internal.h" #include "virerror.h" #include "virconf.h" @@ -1060,10 +1058,10 @@ static const char *vif_bytes_per_sec_re =3D "^[0-9]= +[GMK]?[Bb]/s$"; static int xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec) { + g_autoptr(GRegex) regex =3D NULL; + g_autoptr(GError) err =3D NULL; g_autofree char *trate =3D NULL; char *p; - regex_t rec; - int err; char *suffix; unsigned long long tmp; int ret =3D -1; @@ -1074,17 +1072,14 @@ xenParseSxprVifRate(const char *rate, unsigned long= long *kbytes_per_sec) if (p !=3D NULL) *p =3D 0; =20 - err =3D regcomp(&rec, vif_bytes_per_sec_re, REG_EXTENDED|REG_NOSUB); - if (err !=3D 0) { - char error[100]; - regerror(err, &rec, error, sizeof(error)); + regex =3D g_regex_new(vif_bytes_per_sec_re, 0, 0, &err); + if (!regex) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to compile regular expression '%s': %s"), - vif_bytes_per_sec_re, error); - goto cleanup; + _("Failed to compile regex %s"), err->message); + return -1; } =20 - if (regexec(&rec, trate, 0, NULL, 0)) { + if (!g_regex_match(regex, trate, 0, NULL)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid rate '%s' specified"), rate); goto cleanup; @@ -1108,7 +1103,6 @@ xenParseSxprVifRate(const char *rate, unsigned long l= ong *kbytes_per_sec) ret =3D 0; =20 cleanup: - regfree(&rec); 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 May 4 23:23:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573660155; cv=none; d=zoho.com; s=zohoarc; b=jdxpQkxoBpeXsiqqMn6AuZtTv6685vm04EPmxh5ob9Nzpp3QQ9dLUGqWvjpuw0b239gmjKgpaVDfh+RtWJEUesPoQRJ5E3+mp+BIjtAhm9Z9Jq/qH9/mC/MX105fLZdVDkBGYEmSqmkpdhBBga77myJpRQc18NH6eBQs/p3+c8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573660155; 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=UWDIPdKgWlzqConZdIvRszmj+nQGdlNaBYALlRl0pcc=; b=GL/ykMmuyuy7jvdwyiHkm8yN78VNNQpH3NDdY8zFimh6ZRs7zPg/XjYepllTY07Upq6xJ4o1yZTFUItrGm6xS4vL6uh5quHraM685vpByn0QE4cFgwxy3P/SaDC2xt0iN5bECjTaRoXkw6BrZzLZE/F+PZHARcRg6Oy8ugXjjk4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1573660155358880.6714908416038; Wed, 13 Nov 2019 07:49:15 -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-165-SILTl-Q6NEuM970mZmfQ2A-1; Wed, 13 Nov 2019 10:48:40 -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 2C9988C09A2; Wed, 13 Nov 2019 15:48:27 +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 05F7A10027B9; Wed, 13 Nov 2019 15:48:27 +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 BB9D518034FA; Wed, 13 Nov 2019 15:48:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADFm9GU017654 for ; Wed, 13 Nov 2019 10:48:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1BE35108117F; Wed, 13 Nov 2019 15:48:09 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-61.brq.redhat.com [10.40.200.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C28B1024802 for ; Wed, 13 Nov 2019 15:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573660154; 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=UWDIPdKgWlzqConZdIvRszmj+nQGdlNaBYALlRl0pcc=; b=X5bCZ+kwvvbqPzYa8htv+MQ/bqCranS9rpMsKt09YZ8Kn7ElO3BXipAUgpUAxSke+T/V6O lCZRqWfckksDlURex8cKPTQlL13vKcdfFEY/Ajl0aJtC4sy0CS/fJenFWLcmsmoUTrkEzM 4iXbtq0IgwzteH6fkCv0BAeKYrdpv+M= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 16:48:47 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/12] libxl: remove 'ret' from xenParseSxprVifRate 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: SILTl-Q6NEuM970mZmfQ2A-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Now that the cleanup section is empty, the ret variable is no longer necessary. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/libxl/xen_common.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 15a2db8add..0cb7f0f331 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -1064,7 +1064,6 @@ xenParseSxprVifRate(const char *rate, unsigned long l= ong *kbytes_per_sec) char *p; char *suffix; unsigned long long tmp; - int ret =3D -1; =20 trate =3D g_strdup(rate); =20 @@ -1082,13 +1081,13 @@ xenParseSxprVifRate(const char *rate, unsigned long= long *kbytes_per_sec) if (!g_regex_match(regex, trate, 0, NULL)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid rate '%s' specified"), rate); - goto cleanup; + return -1; } =20 if (virStrToLong_ull(rate, &suffix, 10, &tmp)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to parse rate '%s'"), rate); - goto cleanup; + return -1; } =20 if (*suffix =3D=3D 'G') @@ -1100,10 +1099,7 @@ xenParseSxprVifRate(const char *rate, unsigned long = long *kbytes_per_sec) tmp /=3D 8; =20 *kbytes_per_sec =3D tmp; - 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 May 4 23:23:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573660215; cv=none; d=zoho.com; s=zohoarc; b=J90blC15IYnBPFyjkdCtFjx/zSy7qiDEcMPZRZ68UQ75pd6vlc0DQjFYk+kzrKv2vjxh/I44luJn7Prx/1mqvC1Hefr9ZmMIIM0LZLQhcyBAZj3Q6SXBHk0Z02wOVsis9szPcJAHfPoa1UF+n2MO0s7Bf9H14SwCGLiRMnmMQ1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573660215; 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=zZ+wPzE1NFc95ni1GIkg/njCDKptKlNA3/uTvO2o5n8=; b=JsrhnsEwu7DtCEQr6Ra5CAcFKMwXkWSLiFsE0khnq9YBAC7dvab67zQCjj8r6lOKn9E1FCO/duJdiyPjy1SOYdz/eqXgVezANc5X4gjM64xi1FTnDZvDr8eb+EwoeR4lKYX/N2nSk3q7KVR0aZENCGJsLYc/Rwh1tMiQAv4YtA4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1573660215689889.8185937671248; Wed, 13 Nov 2019 07:50:15 -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-155-2yf9ge7DNp-KB_EaO2Hmyg-1; Wed, 13 Nov 2019 10:48:40 -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 C13A61010F53; Wed, 13 Nov 2019 15:48:30 +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 94D336293B; Wed, 13 Nov 2019 15:48:30 +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 4D2ED18034FD; Wed, 13 Nov 2019 15:48:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADFmAE5017664 for ; Wed, 13 Nov 2019 10:48:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 69ACE101E58D; Wed, 13 Nov 2019 15:48:10 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-61.brq.redhat.com [10.40.200.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id C759B10840DD for ; Wed, 13 Nov 2019 15:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573660214; 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=zZ+wPzE1NFc95ni1GIkg/njCDKptKlNA3/uTvO2o5n8=; b=SDSTDO+q5wrqCgpN3Gj1Tk9Nwc4dA1niLvN1GudjK+doFsUmRRVxaDuy7WZARx5+2pL2AJ Owt55HOVFCj1Eg6hZ0JPvKvMd+kOQ1wGI/XuEPPP0fKGC4My7foiqMj7z3o1FreBeYamcE 6LBe2/2WhTTQCn3q3KMsDOvT1hTJKSw= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 16:48:48 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/12] storage: use GRegex virStorageBackendLogicalParseVolExtents 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: 2yf9ge7DNp-KB_EaO2Hmyg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Using GRegex simplifies the code since g_match_info_fetch will copy the matched substring for us. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/storage/storage_backend_logical.c | 49 +++++++-------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 48023abd1a..d6c81e25b1 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -23,7 +23,6 @@ =20 #include #include -#include #include #include =20 @@ -121,16 +120,16 @@ static int virStorageBackendLogicalParseVolExtents(virStorageVolDefPtr vol, char **const groups) { + g_autoptr(GRegex) re =3D NULL; + g_autoptr(GError) err =3D NULL; + g_autoptr(GMatchInfo) info =3D NULL; int nextents, ret =3D -1; const char *regex_unit =3D "(\\S+)\\((\\S+)\\)"; char *p =3D NULL; size_t i; - int err, nvars; unsigned long long offset, size, length; virStorageVolSourceExtent extent; g_autofree char *regex =3D NULL; - g_autofree regex_t *reg =3D NULL; - g_autofree regmatch_t *vars =3D NULL; =20 memset(&extent, 0, sizeof(extent)); =20 @@ -174,29 +173,14 @@ virStorageBackendLogicalParseVolExtents(virStorageVol= DefPtr vol, strcat(regex, regex_unit); } =20 - if (VIR_ALLOC(reg) < 0) - goto cleanup; - - /* Each extent has a "path:offset" pair, and vars[0] will - * be the whole matched string. - */ - nvars =3D (nextents * 2) + 1; - if (VIR_ALLOC_N(vars, nvars) < 0) - goto cleanup; - - err =3D regcomp(reg, regex, REG_EXTENDED); - if (err !=3D 0) { - char error[100]; - regerror(err, reg, error, sizeof(error)); + re =3D g_regex_new(regex, 0, 0, &err); + if (!re) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to compile regex %s"), - error); - goto cleanup; + _("Failed to compile regex %s"), err->message); + return -1; } =20 - err =3D regexec(reg, groups[3], nvars, vars, 0); - regfree(reg); - if (err !=3D 0) { + if (!g_regex_match(re, groups[3], 0, &info)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed volume extent devices value")); goto cleanup; @@ -204,23 +188,16 @@ virStorageBackendLogicalParseVolExtents(virStorageVol= DefPtr vol, =20 p =3D groups[3]; =20 - /* vars[0] is skipped */ + /* Each extent has a "path:offset" pair, and match #0 + * is the whole matched string. + */ for (i =3D 0; i < nextents; i++) { size_t j; - int len; g_autofree char *offset_str =3D NULL; =20 j =3D (i * 2) + 1; - len =3D vars[j].rm_eo - vars[j].rm_so; - p[vars[j].rm_eo] =3D '\0'; - - if (VIR_STRNDUP(extent.path, - p + vars[j].rm_so, len) < 0) - goto cleanup; - - len =3D vars[j + 1].rm_eo - vars[j + 1].rm_so; - if (VIR_STRNDUP(offset_str, p + vars[j + 1].rm_so, len) < 0) - goto cleanup; + extent.path =3D g_match_info_fetch(info, j); + offset_str =3D g_match_info_fetch(info, j + 1); =20 if (virStrToLong_ull(offset_str, NULL, 10, &offset) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:23:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573660104; cv=none; d=zoho.com; s=zohoarc; b=mEMnncYBR9IkJLSuji0WS2tbziCcSMrOJtoKfJufwYDgnp1sGlbA6w/IOTg1UYEQUq+zbY1lG3ajtp807PypJ24fzBKPRCq3a6/QYlmVGJc+JGZA7MIQf710v10ZwouRJZQY0gWfSwdWGqjyaUP0NGsjx5od4QFqb6pu4z4M5bY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573660104; 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=OrfAksxCjY13W/SCn3MwOcDTU/f7h1HhOpPyCjdz2AY=; b=PYCx1DuSFy6nzpLzRUI9FZlzQdAJfbbU0yfUo4zPHgrMCYQE5iShzWz+5tOOSZV9IMd2K593mvZat7kFSqLCpx+RbUDVNga9dFQAtpNvF58KkNE4KEbu37sdxbjSMBSwqZ44TBmKEJ17m3oIYEZ2aTxpqKSndRnil6GzZn4Mc24= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1573660104922896.4543626245074; Wed, 13 Nov 2019 07:48: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-387-J2zZ0oeuOR6IvTgFIlmuSw-1; Wed, 13 Nov 2019 10:48:20 -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 482ABDBE5; Wed, 13 Nov 2019 15:48:13 +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 1CCB590A8; Wed, 13 Nov 2019 15:48:13 +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 CFAAB4E567; Wed, 13 Nov 2019 15:48:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADFmB9g017672 for ; Wed, 13 Nov 2019 10:48:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id 748F9104B4C9; Wed, 13 Nov 2019 15:48:11 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-61.brq.redhat.com [10.40.200.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF074101F967 for ; Wed, 13 Nov 2019 15:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573660103; 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=OrfAksxCjY13W/SCn3MwOcDTU/f7h1HhOpPyCjdz2AY=; b=ezElVqEO+U6LPKbGfaHweRTkbYTLQPasKT22Bg8FAu/yat4wqgESS7tWGqG2nGCvL65qNO X4x/Vhu4oAfF9zWVYOw7y7jsIKVcnSSfSEY3ROa5qdb+4fV7RE0Mh/ZdM9t8ugRxGr82pp Mtx1jPKwj0I1rzYxaBQFgo5+SKZPqXY= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 16:48:49 +0100 Message-Id: <2bbb2370a5d702f6adf817e9cf72327d7d355bcf.1573660076.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/12] util: use GRegex in virCommandRunRegex 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: J2zZ0oeuOR6IvTgFIlmuSw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This saves us from allocating vars upfront, since GLib deals with that for us. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/util/vircommand.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 49432ddfcb..1ab3dbc819 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -22,7 +22,6 @@ #include =20 #include -#include #include #include #include @@ -3077,11 +3076,10 @@ virCommandRunRegex(virCommandPtr cmd, const char *prefix, int *exitstatus) { - int err; - regex_t *reg; - g_autofree regmatch_t *vars =3D NULL; + GRegex **reg =3D NULL; + g_autoptr(GMatchInfo) info =3D NULL; size_t i, j, k; - int totgroups =3D 0, ngroup =3D 0, maxvars =3D 0; + int totgroups =3D 0, ngroup =3D 0; char **groups; g_autofree char *outbuf =3D NULL; VIR_AUTOSTRINGLIST lines =3D NULL; @@ -3092,29 +3090,23 @@ virCommandRunRegex(virCommandPtr cmd, return -1; =20 for (i =3D 0; i < nregex; i++) { - err =3D regcomp(®[i], regex[i], REG_EXTENDED); - if (err !=3D 0) { - char error[100]; - regerror(err, ®[i], error, sizeof(error)); + g_autoptr(GError) err =3D NULL; + reg[i] =3D g_regex_new(regex[i], G_REGEX_OPTIMIZE, 0, &err); + if (!reg[i]) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to compile regex %s"), error); + _("Failed to compile regex %s"), err->message); for (j =3D 0; j < i; j++) - regfree(®[j]); + g_regex_unref(reg[j]); VIR_FREE(reg); return -1; } =20 totgroups +=3D nvars[i]; - if (nvars[i] > maxvars) - maxvars =3D nvars[i]; - } =20 /* Storage for matched variables */ if (VIR_ALLOC_N(groups, totgroups) < 0) goto cleanup; - if (VIR_ALLOC_N(vars, maxvars+1) < 0) - goto cleanup; =20 virCommandSetOutputBuffer(cmd, &outbuf); if (virCommandRun(cmd, exitstatus) < 0) @@ -3140,15 +3132,12 @@ virCommandRunRegex(virCommandPtr cmd, =20 ngroup =3D 0; for (i =3D 0; i < nregex; i++) { - if (regexec(®[i], p, nvars[i]+1, vars, 0) !=3D 0) + if (!(g_regex_match(reg[i], p, 0, &info))) break; =20 - /* NB vars[0] is the full pattern, so we offset j by 1 */ - for (j =3D 1; j <=3D nvars[i]; j++) { - if (VIR_STRNDUP(groups[ngroup++], p + vars[j].rm_so, - vars[j].rm_eo - vars[j].rm_so) < 0) - goto cleanup; - } + /* NB match #0 is the full pattern, so we offset j by 1 */ + for (j =3D 1; j <=3D nvars[i]; j++) + groups[ngroup++] =3D g_match_info_fetch(info, j); =20 } /* We've matched on the last regex, so callback time */ @@ -3170,7 +3159,7 @@ virCommandRunRegex(virCommandPtr cmd, } =20 for (i =3D 0; i < nregex; i++) - regfree(®[i]); + g_regex_unref(reg[i]); =20 VIR_FREE(reg); return ret; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:23:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573660112; cv=none; d=zoho.com; s=zohoarc; b=V4szd7+veJ8iN3heKAGZdWcDhDG2YCAfPTtbUv22OB9vTrPg+/RLC0fQy7/5JjxjiZf5fmtKbQlykXlo6LhCQ2LuqwgYKu5fsNT0ABomAJUSumDVpt0x4elqYP0T9Cmch4B+LMY9rauxYvS3PBJjQJTwxm2LtC00CI6NOW/lu0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573660112; 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=AelkYeAarSmhROGihnjf7dXU1jntaOA7oY3eqBpbam0=; b=W/HApcq1IbW4AsZ4nD1Af8T4rrooPx9OvtQBZfbBm8hmGoY2I6CAtZneHnZCSetMVTN68xWU0uBNtBurmOXxHmHT+7nnlPx0R89i9kx9F6DY6y1iMeOFK4wl6/FcmydUQv05GImWapU76Eb4Sy6XeWKceeq1mW9JWxmiq5Axeeo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1573660112901262.92459304632746; Wed, 13 Nov 2019 07:48:32 -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-198-HLuw0jjyP5aBGDkkNSOD6A-1; Wed, 13 Nov 2019 10:48:28 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0797196285B; Wed, 13 Nov 2019 15:48:19 +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 8BC985E265; Wed, 13 Nov 2019 15:48: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 4ACF94E562; Wed, 13 Nov 2019 15:48:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADFmCOr017677 for ; Wed, 13 Nov 2019 10:48:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7F32D101E58D; Wed, 13 Nov 2019 15:48:12 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-61.brq.redhat.com [10.40.200.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4B63101F967 for ; Wed, 13 Nov 2019 15:48:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573660111; 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=AelkYeAarSmhROGihnjf7dXU1jntaOA7oY3eqBpbam0=; b=Mbv+eMUXV7srMibi+eFKvwUs0qayoARByyOJx4AWbDWrSS17WeXaCcXO7Uty30SSiJnB01 E3hR5KfdICtLqoXcsrLmCIO5YkUanuTNwqvUSkUF+b+wG8BV2nHXa/o3XVcLwYPVk/m+JG xEvh8DZCdiV4xOdcYW6tTRzT4kfvBCI= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 16:48:50 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/12] util: use GRegex for virLogRegex 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.14 X-MC-Unique: HLuw0jjyP5aBGDkkNSOD6A-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/util/virlog.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index b3460d85fe..47e77e63b7 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #if HAVE_SYSLOG_H # include @@ -61,7 +60,7 @@ =20 VIR_LOG_INIT("util.log"); =20 -static regex_t *virLogRegex; +static GRegex *virLogRegex; static char virLogHostname[HOST_NAME_MAX+1]; =20 =20 @@ -268,10 +267,7 @@ virLogOnceInit(void) virLogLock(); virLogDefaultPriority =3D VIR_LOG_DEFAULT; =20 - if (VIR_ALLOC_QUIET(virLogRegex) >=3D 0) { - if (regcomp(virLogRegex, VIR_LOG_REGEX, REG_EXTENDED) !=3D 0) - VIR_FREE(virLogRegex); - } + virLogRegex =3D g_regex_new(VIR_LOG_REGEX, G_REGEX_OPTIMIZE, 0, NULL); =20 /* We get and remember the hostname early, because at later time * it might not be possible to load NSS modules via getaddrinfo() @@ -1262,12 +1258,11 @@ virLogSetFromEnv(void) */ bool virLogProbablyLogMessage(const char *str) { - bool ret =3D false; if (!virLogRegex) return false; - if (regexec(virLogRegex, str, 0, NULL, 0) =3D=3D 0) - ret =3D true; - return ret; + if (g_regex_match(virLogRegex, str, 0, NULL)) + return true; + return false; } =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 May 4 23:23:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573660114; cv=none; d=zoho.com; s=zohoarc; b=kI1y3zjTS0vVoHhZzcMEe2KFgFiyDWrqgZqBmhBY46LicrQ/WyDKgM5s5YfB+ecUne3q1MxV9QaD1BrCych7Swe3EI3e5lL24mYpNofwWsifrliS6vJYuNldupX3rA0mSi2zr8tQW2tlEhkJUL/dUUVz3sgzahRfDYYgxzYwaSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573660114; 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=vHI2w4O4FfGvNtS+njdtJs7aiU+vCNaWqsDgE8MaP3Q=; b=Rzl4gUTkiccasJ3shb1bZ2QUYFjhOzhiKvzN/WoAY5GMlAy+uiFtpryISL2AytZvTk7aDBvYO66IN2RnK19lFiKBmL6FpvlEsSPPQZQ3nQAGlWEravZVkkfr8j/cUApwsEmJax263ABWQMm1x4nN4gi3eloeVfSOiKe0Te8B6dQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1573660114644539.7938991985712; Wed, 13 Nov 2019 07:48: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-190-0ys13gr4OIO7aaeG3uf0gA-1; Wed, 13 Nov 2019 10:48:32 -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 3BE3B86A072; Wed, 13 Nov 2019 15:48:20 +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 0AE0410027B9; Wed, 13 Nov 2019 15:48:20 +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 BA3F44E56D; Wed, 13 Nov 2019 15:48:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADFmFl3017706 for ; Wed, 13 Nov 2019 10:48:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 073CB10246E3; Wed, 13 Nov 2019 15:48:15 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-61.brq.redhat.com [10.40.200.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39986101E58D for ; Wed, 13 Nov 2019 15:48:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573660113; 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=vHI2w4O4FfGvNtS+njdtJs7aiU+vCNaWqsDgE8MaP3Q=; b=iP7o9v57572b1GMmLq8KMhTU2nxGsZRkNdYV7nBD6/Nk8d8z06y8b1Bp87I3WQ1C+bIyFP Q12JCH8DzGAt4WopSlT/fDhqtU+JvBPXbe8G5gwsn7FJppCryWPh4timDr3pL6P1HU+5/5 up6qXlW5ByE4IP/TJdrGu95qyDzB1Nw= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 16:48:51 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/12] util: use GRegex in virStringSearch 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: 0ys13gr4OIO7aaeG3uf0gA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/util/virstring.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/util/virstring.c b/src/util/virstring.c index 283cf8c8d8..3da793c87a 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -1017,29 +1017,27 @@ virStringSearch(const char *str, size_t max_matches, char ***matches) { - regex_t re; - regmatch_t rem; + g_autoptr(GRegex) regex =3D NULL; + g_autoptr(GError) err =3D NULL; + g_autoptr(GMatchInfo) info =3D NULL; size_t nmatches =3D 0; ssize_t ret =3D -1; - int rv =3D -1; =20 *matches =3D NULL; =20 VIR_DEBUG("search '%s' for '%s'", str, regexp); =20 - if ((rv =3D regcomp(&re, regexp, REG_EXTENDED)) !=3D 0) { - char error[100]; - regerror(rv, &re, error, sizeof(error)); + regex =3D g_regex_new(regexp, 0, 0, &err); + if (!regex) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Error while compiling regular expression '%s': %= s"), - regexp, error); + _("Failed to compile regex %s"), err->message); return -1; } =20 - if (re.re_nsub !=3D 1) { + if (g_regex_get_capture_count(regex) !=3D 1) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Regular expression '%s' must have exactly 1 matc= h group, not %zu"), - regexp, re.re_nsub); + _("Regular expression '%s' must have exactly 1 matc= h group, not %d"), + regexp, g_regex_get_capture_count(regex)); goto cleanup; } =20 @@ -1051,28 +1049,27 @@ virStringSearch(const char *str, =20 while ((nmatches - 1) < max_matches) { char *match; + int endpos; =20 - if (regexec(&re, str, 1, &rem, 0) !=3D 0) + if (!g_regex_match(regex, str, 0, &info)) break; =20 if (VIR_EXPAND_N(*matches, nmatches, 1) < 0) goto cleanup; =20 - if (VIR_STRNDUP(match, str + rem.rm_so, - rem.rm_eo - rem.rm_so) < 0) - goto cleanup; + match =3D g_match_info_fetch(info, 1); =20 VIR_DEBUG("Got '%s'", match); =20 (*matches)[nmatches-2] =3D match; =20 - str =3D str + rem.rm_eo; + g_match_info_fetch_pos(info, 1, NULL, &endpos); + str +=3D endpos; } =20 ret =3D nmatches - 1; /* don't count the trailing null */ =20 cleanup: - regfree(&re); if (ret < 0) { virStringListFree(*matches); *matches =3D NULL; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:23:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573660117; cv=none; d=zoho.com; s=zohoarc; b=jWAEBw7JxiCYh7w4dgvSc2j9CMJuuot2OGSZ12X/uLWUvxNZPGQ2Kk5GnY9bmWlDD5AYtNnecSn3cZbs0k3lp3IQQeDc/scSQ5Dh1UvoAQnEH6VXOSbVXBx0kBuqBfn/kI5tNgaK+uKpD0BQIByIzRh4LEgXRMaTwVv2GZU5Ef0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573660117; 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=9lOrfjIJ1jBeewIdhAmVEYYOYWUucEVO+D0TZo9Caz4=; b=QH68WdJ+ygu9ryq/FAP+6rWRJoBomWbxbp8trT+A2YRBUyEADPtO/vM/rBUaTmr5cUjM6HDpxTwtUtm9ecfay4d46T5x6ONnd+Vb0CGFE6GEXRzqZmxUCmzPc06KyL/e9rk3b6zeCgFd6BBTTdgmHQ2zoMy12toJRR0pcTlbhk8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1573660117831342.23798199352234; Wed, 13 Nov 2019 07:48: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-57-byroJtf0PQmwgaL_5NIJEA-1; Wed, 13 Nov 2019 10:48:34 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CF7D4107B291; Wed, 13 Nov 2019 15:48: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 A76455E265; Wed, 13 Nov 2019 15:48: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 631034E570; Wed, 13 Nov 2019 15:48:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADFmJxQ017723 for ; Wed, 13 Nov 2019 10:48:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4C3B6101E58D; Wed, 13 Nov 2019 15:48:19 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-61.brq.redhat.com [10.40.200.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id A802E10027B9 for ; Wed, 13 Nov 2019 15:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573660116; 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=9lOrfjIJ1jBeewIdhAmVEYYOYWUucEVO+D0TZo9Caz4=; b=A84p6Nmoq5dE6WMoC+HmhkOP7c2KLo5d1Tpw65m5SPASsLe7lfN06mBdFXSsHm6nJG/+h/ ObX7UuwiT0vFpAvtnwNtANXraREUMdrv1W5Ks/M0C1JR7HHC4I5lLhqKvW2byNhIBEymHW MpV5SfFBG1wecYDbzCX1sY744SOJmhM= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 16:48:52 +0100 Message-Id: <202809ceffc5d1cae3b7c99d9e3dd2bfa51b786e.1573660076.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/12] util: use GRegex in virStringMatch 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.14 X-MC-Unique: byroJtf0PQmwgaL_5NIJEA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/util/virstring.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/util/virstring.c b/src/util/virstring.c index 3da793c87a..6add2278d8 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -19,7 +19,6 @@ #include =20 #include -#include #include =20 #include "c-ctype.h" @@ -1089,24 +1088,19 @@ bool virStringMatch(const char *str, const char *regexp) { - regex_t re; - int rv; + g_autoptr(GRegex) regex =3D NULL; + g_autoptr(GError) err =3D NULL; =20 VIR_DEBUG("match '%s' for '%s'", str, regexp); =20 - if ((rv =3D regcomp(&re, regexp, REG_EXTENDED | REG_NOSUB)) !=3D 0) { - char error[100]; - regerror(rv, &re, error, sizeof(error)); - VIR_WARN("error while compiling regular expression '%s': %s", - regexp, error); - return false; + regex =3D g_regex_new(regexp, 0, 0, &err); + if (!regex) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to compile regex %s"), err->message); + return -1; } =20 - rv =3D regexec(&re, str, 0, NULL, 0); - - regfree(&re); - - return rv =3D=3D 0; + return g_regex_match(regex, str, 0, NULL); } =20 /** --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:23:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573660146; cv=none; d=zoho.com; s=zohoarc; b=ONDYY0rK+AqUAO8QkFMnlZPQnXY328TMSWHEGugT6qrgG3Rd4qVFuPmq490JzXARk0RLLYSR6l2QaDR12oOEQOZhR1dQuPPmq2aXW/ud+d5/5fSnogvhnA6GFnOFzpbrCKnG2AkKInpYxCnWdz5nZZ8I0NM3oj90UDHDQ1Tx3ng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573660146; 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=WQDNZfl46BW3hxrC7ElzAAsvLEDhk6Ax7FKoLTalmmo=; b=IurFQP1rLCMK6kzixSqV7r1LHHiwMU9NynhjZDbE+msb3Kp5JnwuNciX5EZQ2te2tYWPHanuaYD4l9eFUjvk6H4WS0RwC4LzhraYyg/uxzkSzQCFZrQd8UMoWgxf4f4Em/B5Ge/GLgfSNlHiU5IxOmA+nlokuinfUDZkm5pHPdI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1573660146294797.4889257254073; Wed, 13 Nov 2019 07:49: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-307-fX6SBBcUOJahojOx_7Bp2w-1; Wed, 13 Nov 2019 10:48:41 -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 5E36C976D8; Wed, 13 Nov 2019 15:48:34 +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 328C610246E3; Wed, 13 Nov 2019 15:48:34 +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 D46B318034EC; Wed, 13 Nov 2019 15:48:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADFmKCN017728 for ; Wed, 13 Nov 2019 10:48:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5695B101E58D; Wed, 13 Nov 2019 15:48:20 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-61.brq.redhat.com [10.40.200.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id B189510246F7 for ; Wed, 13 Nov 2019 15:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573660145; 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=WQDNZfl46BW3hxrC7ElzAAsvLEDhk6Ax7FKoLTalmmo=; b=gpfIeARwK3TaigkiUYQ+aPaAlUJ9hhh9MUXd74OP30fAYB2sfd1ycBjseKU9ikLatdHtXr un6CnF+//jNG7epkiI9OBNqZbD0wkl4QqYCmOV/auK63zQDyIiGCYNmvWItq2xynK++44x EOEiBHzpti5QiIw7lhJVa8pPdyhkLZE= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 16:48:53 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/12] tests: use GRegex in vboxsnapshotxmltest 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: fX6SBBcUOJahojOx_7Bp2w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- tests/vboxsnapshotxmltest.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c index 8faf2b9c26..d1a7522931 100644 --- a/tests/vboxsnapshotxmltest.c +++ b/tests/vboxsnapshotxmltest.c @@ -4,7 +4,6 @@ =20 #ifdef WITH_VBOX =20 -# include # include "vbox/vbox_snapshot_conf.h" =20 # define VIR_FROM_THIS VIR_FROM_NONE @@ -12,7 +11,7 @@ static const char *testSnapshotXMLVariableLineRegexStr =3D "lastStateChange=3D[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0= -9]{2}Z"; =20 -regex_t *testSnapshotXMLVariableLineRegex =3D NULL; +GRegex *testSnapshotXMLVariableLineRegex =3D NULL; =20 static char * testFilterXML(char *xml) @@ -29,8 +28,7 @@ testFilterXML(char *xml) VIR_FREE(xml); =20 for (xmlLine =3D xmlLines; *xmlLine; xmlLine++) { - if (regexec(testSnapshotXMLVariableLineRegex, - *xmlLine, 0, NULL, 0) =3D=3D 0) + if (g_regex_match(testSnapshotXMLVariableLineRegex, *xmlLine, 0, N= ULL)) continue; =20 virBufferStrcat(&buf, *xmlLine, "\n", NULL); @@ -112,12 +110,12 @@ static int mymain(void) { int ret =3D 0; - if (VIR_ALLOC(testSnapshotXMLVariableLineRegex) < 0) - goto cleanup; + g_autoptr(GError) err =3D NULL; + + testSnapshotXMLVariableLineRegex =3D g_regex_new(testSnapshotXMLVariab= leLineRegexStr, + 0, 0, &err); =20 - if (regcomp(testSnapshotXMLVariableLineRegex, - testSnapshotXMLVariableLineRegexStr, - REG_EXTENDED | REG_NOSUB) !=3D 0) { + if (!testSnapshotXMLVariableLineRegex) { ret =3D -1; virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "failed to compile test regex"); @@ -136,9 +134,7 @@ mymain(void) DO_TEST("2disks-3snap-brother"); =20 cleanup: - if (testSnapshotXMLVariableLineRegex) - regfree(testSnapshotXMLVariableLineRegex); - VIR_FREE(testSnapshotXMLVariableLineRegex); + g_regex_unref(testSnapshotXMLVariableLineRegex); 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