From nobody Thu May 2 04:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508185232426495.9048751828784; Mon, 16 Oct 2017 13:20:32 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 81E7F820E2; Mon, 16 Oct 2017 20:20: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 7293D5C1A1; Mon, 16 Oct 2017 20:20: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 573E01800C91; Mon, 16 Oct 2017 20:20:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9GKKMNZ031623 for ; Mon, 16 Oct 2017 16:20:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id EA8F660BE6; Mon, 16 Oct 2017 20:20:22 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2B3260C94 for ; Mon, 16 Oct 2017 20:20:21 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C260D285B9 for ; Mon, 16 Oct 2017 20:20:19 +0000 (UTC) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9GKIir2016108 for ; Mon, 16 Oct 2017 16:20:19 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dn1npw9db-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 16 Oct 2017 16:20:19 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Oct 2017 21:20:17 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 16 Oct 2017 21:20:14 +0100 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9GKKCKC20971618; Mon, 16 Oct 2017 20:20:13 GMT Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v9GKKGl7011183; Tue, 17 Oct 2017 07:20:16 +1100 Received: from madhu-ThinkPad-T460.in.ibm.com ([9.79.187.168]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v9GKKDeN011109; Tue, 17 Oct 2017 07:20:15 +1100 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 81E7F820E2 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 81E7F820E2 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C260D285B9 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=kmp@linux.vnet.ibm.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C260D285B9 From: Kothapally Madhu Pavan To: libvir-list@redhat.com Date: Tue, 17 Oct 2017 01:50:04 +0530 X-TM-AS-MML: disable x-cbid: 17101620-0040-0000-0000-000003E36243 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101620-0041-0000-0000-000025E59B21 Message-Id: <1508185204-30786-1-git-send-email-kmp@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-16_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710160284 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 205 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 16 Oct 2017 20:20:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 16 Oct 2017 20:20:20 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'kmp@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -3.5 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Kothapally Madhu Pavan Subject: [libvirt] [PATCH] qemu: Move qemuFreeKeywords into qemu_parse_command.c 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 16 Oct 2017 20:20:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move qemuFreeKeywords into qemu_parse_command.c as qemuKeywordsFree and call it rather than inline code in multiple places. Signed-off-by: Kothapally Madhu Pavan Reviewed-by: John Ferlan --- src/qemu/qemu_monitor_json.c | 15 ++----------- src/qemu/qemu_parse_command.c | 52 ++++++++++++++++-----------------------= ---- src/qemu/qemu_parse_command.h | 5 +++++ 3 files changed, 26 insertions(+), 46 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 5546d1a..af66967 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -468,17 +468,6 @@ qemuMonitorJSONMakeCommandRaw(bool wrap, const char *c= mdname, ...) #define qemuMonitorJSONMakeCommand(cmdname, ...) \ qemuMonitorJSONMakeCommandRaw(false, cmdname, __VA_ARGS__) =20 -static void -qemuFreeKeywords(int nkeywords, char **keywords, char **values) -{ - size_t i; - for (i =3D 0; i < nkeywords; i++) { - VIR_FREE(keywords[i]); - VIR_FREE(values[i]); - } - VIR_FREE(keywords); - VIR_FREE(values); -} =20 static virJSONValuePtr qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeywo= rd) @@ -513,11 +502,11 @@ qemuMonitorJSONKeywordStringToJSON(const char *str, c= onst char *firstkeyword) } } =20 - qemuFreeKeywords(nkeywords, keywords, values); + qemuKeywordsFree(nkeywords, keywords, values); return ret; =20 error: - qemuFreeKeywords(nkeywords, keywords, values); + qemuKeywordsFree(nkeywords, keywords, values); virJSONValueFree(ret); return NULL; } diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index 9f739ae..d5ea5aa 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -381,6 +381,20 @@ static const char *qemuFindEnv(char **progenv, return NULL; } =20 + +void +qemuKeywordsFree(int nkeywords, char **keywords, char **values) +{ + size_t i; + for (i =3D 0; i < nkeywords; i++) { + VIR_FREE(keywords[i]); + VIR_FREE(values[i]); + } + VIR_FREE(keywords); + VIR_FREE(values); +} + + /* * Takes a string containing a set of key=3Dvalue,key=3Dvalue,key... * parameters and splits them up, returning two arrays with @@ -401,7 +415,6 @@ qemuParseKeywords(const char *str, char **values =3D NULL; const char *start =3D str; const char *end; - size_t i; =20 *retkeywords =3D NULL; *retvalues =3D NULL; @@ -479,12 +492,7 @@ qemuParseKeywords(const char *str, return 0; =20 error: - for (i =3D 0; i < keywordCount; i++) { - VIR_FREE(keywords[i]); - VIR_FREE(values[i]); - } - VIR_FREE(keywords); - VIR_FREE(values); + qemuKeywordsFree(keywordCount, keywords, values); return -1; } =20 @@ -949,12 +957,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, } =20 cleanup: - for (i =3D 0; i < nkeywords; i++) { - VIR_FREE(keywords[i]); - VIR_FREE(values[i]); - } - VIR_FREE(keywords); - VIR_FREE(values); + qemuKeywordsFree(nkeywords, keywords, values); return def; =20 error: @@ -1132,12 +1135,7 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt, virDomainNetGenerateMAC(xmlopt, &def->mac); =20 cleanup: - for (i =3D 0; i < nkeywords; i++) { - VIR_FREE(keywords[i]); - VIR_FREE(values[i]); - } - VIR_FREE(keywords); - VIR_FREE(values); + qemuKeywordsFree(nkeywords, keywords, values); return def; =20 error: @@ -1704,13 +1702,7 @@ qemuParseCommandLineMem(virDomainDefPtr dom, ret =3D 0; =20 cleanup: - for (i =3D 0; i < nkws; i++) { - VIR_FREE(kws[i]); - VIR_FREE(vals[i]); - } - VIR_FREE(kws); - VIR_FREE(vals); - + qemuKeywordsFree(nkws, kws, vals); return ret; } =20 @@ -1795,13 +1787,7 @@ qemuParseCommandLineSmp(virDomainDefPtr dom, ret =3D 0; =20 cleanup: - for (i =3D 0; i < nkws; i++) { - VIR_FREE(kws[i]); - VIR_FREE(vals[i]); - } - VIR_FREE(kws); - VIR_FREE(vals); - + qemuKeywordsFree(nkws, kws, vals); return ret; =20 syntax: diff --git a/src/qemu/qemu_parse_command.h b/src/qemu/qemu_parse_command.h index ed65342..4c553f2 100644 --- a/src/qemu/qemu_parse_command.h +++ b/src/qemu/qemu_parse_command.h @@ -43,6 +43,11 @@ virDomainDefPtr qemuParseCommandLinePid(virCapsPtr caps, virDomainChrSourceDefPtr *monConfi= g, bool *monJSON); =20 +void +qemuKeywordsFree(int nkeywords, + char **keywords, + char **values); + int qemuParseKeywords(const char *str, char ***retkeywords, --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list