From nobody Sun May 5 15:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1601850220; cv=none; d=zohomail.com; s=zohoarc; b=KuW4TQ0JdZ0li/qmjre8x2ul/0v+HVMKLJ0j8DIgc1nXK+qiGD2ifK+OidEm9uoJaWrwVsGl9mF5qHUvL7AGCTeQYDfr1NGkR5YTZh3x4Ost48BKj5dPNmjWFRpiGwjmQQ5Jy9/+4jbnl4ToY3B6/uFNJAp0KhCIfhXXJvm8yps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601850220; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Bt6PngoohfItzFxOrSyebJPYa29nbjrqDh8EYmQPkqY=; b=a4WhBr2o0Ni/wP82GUpuu/CdqXqSN0V7xMiYNUTs0/JrYQ3DF4vDvCrh0zp32zyj8Xvw+BA+uAAyvnlTx5yDUKwwXyd1pO4shoPCUdTpGeVLvtfWSqKzXbW4ff6LZTEA+3KyIVc3w9aQuSEh1zgMgM6HXdth0F66uXdM8EYjs3w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601850220557720.2646007640261; Sun, 4 Oct 2020 15:23:40 -0700 (PDT) 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-61-D1gBIS2UPO2phtZig-EQhg-1; Sun, 04 Oct 2020 18:23:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E19B80B736; Sun, 4 Oct 2020 22:23:31 +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 2D0FE5C1BD; Sun, 4 Oct 2020 22:23:31 +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 EFF43181A872; Sun, 4 Oct 2020 22:23:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 094MNUgi031807 for ; Sun, 4 Oct 2020 18:23:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1F72678805; Sun, 4 Oct 2020 22:23:30 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B3EE7B7A0 for ; Sun, 4 Oct 2020 22:23:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601850219; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Bt6PngoohfItzFxOrSyebJPYa29nbjrqDh8EYmQPkqY=; b=d53v0wwNOyjrpG2b8nuyAJnV5YfkINi5xGn6ualIc61k+7lsKPQd/gHmGO+5525ZjyAxpL thfXvnTvTuXj42c+8aqiGL7iPAIEcaBQY998YOvkV47S4LyHm3MsAGsTqQpsr2rmiTaHGa crvshv6x1jFV/F4kvz/FpW6b3Igagew= X-MC-Unique: D1gBIS2UPO2phtZig-EQhg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH] vmware: use g_new0 instead of VIR_ALLOC (glib chronicles) Date: Mon, 5 Oct 2020 00:23:25 +0200 Message-Id: <6c47727816fc9cd1402574497fd000312ec8f9a6.1601850189.git.jtomko@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/vmware/vmware_driver.c | 6 ++--- src/vmx/vmx.c | 46 ++++++++++---------------------------- 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index e82edf2a11..087664a341 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -97,8 +97,7 @@ vmwareDataAllocFunc(void *opaque G_GNUC_UNUSED) { vmwareDomainPtr dom; =20 - if (VIR_ALLOC(dom) < 0) - return NULL; + dom =3D g_new0(vmwareDomain, 1); =20 dom->vmxPath =3D NULL; dom->gui =3D true; @@ -184,8 +183,7 @@ vmwareConnectOpen(virConnectPtr conn, /* We now know the URI is definitely for this driver, so beyond * here, don't return DECLINED, always use ERROR */ =20 - if (VIR_ALLOC(driver) < 0) - return VIR_DRV_OPEN_ERROR; + driver =3D g_new0(struct vmware_driver, 1); =20 /* Find vmrun, which is what this driver uses to communicate to * the VMware hypervisor. We look this up first since we use it diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 9894d5c0ce..0e8a690d0d 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -637,8 +637,7 @@ virVMXEscapeHex(const char *string, char escape, const = char *special) ++length; } =20 - if (VIR_ALLOC_N(escaped, length) < 0) - return NULL; + escaped =3D g_new0(char, length); =20 tmp1 =3D string; /* reading from this one */ tmp2 =3D escaped; /* writing to this one */ @@ -1150,8 +1149,7 @@ virVMXGatherSCSIControllers(virVMXContext *ctx, virDo= mainDefPtr def, int count =3D 0; int *autodetectedModels; =20 - if (VIR_ALLOC_N(autodetectedModels, def->ndisks) < 0) - return -1; + autodetectedModels =3D g_new0(int, def->ndisks); =20 for (i =3D 0; i < def->ncontrollers; ++i) { controller =3D def->controllers[i]; @@ -1611,9 +1609,7 @@ virVMXParseConfig(virVMXContext *ctx, /* FIXME */ =20 /* def:graphics */ - if (VIR_ALLOC_N(def->graphics, 1) < 0) - goto cleanup; - + def->graphics =3D g_new0(virDomainGraphicsDefPtr, 1); def->ngraphics =3D 0; =20 if (virVMXParseVNC(conf, &def->graphics[def->ngraphics]) < 0) @@ -1623,9 +1619,7 @@ virVMXParseConfig(virVMXContext *ctx, ++def->ngraphics; =20 /* def:disks: 4 * 15 scsi + 2 * 2 ide + 2 floppy =3D 66 */ - if (VIR_ALLOC_N(def->disks, 66) < 0) - goto cleanup; - + def->disks =3D g_new0(virDomainDiskDefPtr, 66); def->ndisks =3D 0; =20 /* def:disks (scsi) */ @@ -1733,9 +1727,7 @@ virVMXParseConfig(virVMXContext *ctx, if (sharedFolder_maxNum > 0) { int number; =20 - if (VIR_ALLOC_N(def->fss, sharedFolder_maxNum) < 0) - goto cleanup; - + def->fss =3D g_new0(virDomainFSDefPtr, sharedFolder_maxNum); def->nfss =3D 0; =20 for (number =3D 0; number < sharedFolder_maxNum; ++number) { @@ -1767,9 +1759,7 @@ virVMXParseConfig(virVMXContext *ctx, /* FIXME */ =20 /* def:videos */ - if (VIR_ALLOC_N(def->videos, 1) < 0) - goto cleanup; - + def->videos =3D g_new0(virDomainVideoDefPtr, 1); def->nvideos =3D 0; =20 if (virVMXParseSVGA(conf, &def->videos[def->nvideos]) < 0) @@ -1784,9 +1774,7 @@ virVMXParseConfig(virVMXContext *ctx, /* FIXME */ =20 /* def:serials */ - if (VIR_ALLOC_N(def->serials, 4) < 0) - goto cleanup; - + def->serials =3D g_new0(virDomainChrDefPtr, 4); def->nserials =3D 0; =20 for (port =3D 0; port < 4; ++port) { @@ -1800,9 +1788,7 @@ virVMXParseConfig(virVMXContext *ctx, } =20 /* def:parallels */ - if (VIR_ALLOC_N(def->parallels, 3) < 0) - goto cleanup; - + def->parallels =3D g_new0(virDomainChrDefPtr, 3); def->nparallels =3D 0; =20 for (port =3D 0; port < 3; ++port) { @@ -1819,10 +1805,7 @@ virVMXParseConfig(virVMXContext *ctx, if (ctx->datacenterPath || ctx->moref) { struct virVMXDomainDefNamespaceData *nsdata =3D NULL; =20 - if (VIR_ALLOC(nsdata) < 0) { - virVMXDomainDefNamespaceFree(nsdata); - goto cleanup; - } + nsdata =3D g_new0(struct virVMXDomainDefNamespaceData, 1); =20 nsdata->datacenterPath =3D g_strdup(ctx->datacenterPath); =20 @@ -1891,9 +1874,7 @@ virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefP= tr *def) if (! enabled) return 0; =20 - if (VIR_ALLOC(*def) < 0) - goto failure; - + *def =3D g_new0(virDomainGraphicsDef, 1); (*def)->type =3D VIR_DOMAIN_GRAPHICS_TYPE_VNC; =20 if (virVMXGetConfigLong(conf, "RemoteDisplay.vnc.port", &port, -1, @@ -2588,8 +2569,7 @@ virVMXParseEthernet(virConfPtr conf, int controller, = virDomainNetDefPtr *def) if (! present/* && ! startConnected*/) return 0; =20 - if (VIR_ALLOC(*def) < 0) - return -1; + *def =3D g_new0(virDomainNetDef, 1); =20 /* vmx:connectionType -> def:type */ if (virVMXGetConfigString(conf, connectionType_name, &connectionType, @@ -3040,9 +3020,7 @@ virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr= *def) return -1; } =20 - if (VIR_ALLOC(*def) < 0) - return -1; - + *def =3D g_new0(virDomainVideoDef, 1); (*def)->type =3D VIR_DOMAIN_VIDEO_TYPE_VMVGA; =20 /* vmx:vramSize */ --=20 2.26.2