From nobody Mon Feb 9 15:11:06 2026 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