From nobody Sun Feb 8 22:35:22 2026 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=1601039950; cv=none; d=zohomail.com; s=zohoarc; b=dKcNvJxEHFLnFjJ5k46kL2v2D/OBUQhh5nFGBSJFBtogpriR3auWtxm/jO3ZoLMtt4EG5BHps2Rd+d2y8IZUUG54bcJXg4Y+Rg18eXvrxD3ydcYdfn8yPmxEH755SP2ojfHNKAYYyuQFXYLoyEPAztF7/eUUcYcjjrCxt8ktF1g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601039950; 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=h6+KHC4u/pEgyw8Rt2hmcp/6B5mBgUkvIZV5/gMJ4jg=; b=OeVbtw4iY7a/9yRNy8/tVBbCrhdl8qOsk9ffIw1Zn64x3ya5aU/oNTTuKb+XQcoNujBOUxpm/UNjegJDorCg9LhVpUMbSBCV/47uzuR4YFQA+B8h7jkLQhn7sKTCIJmA0TAWOIuT8ASLo0XqSJkZ/Tatx+dntbftmJnPZgMtlwE= 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 1601039950963238.7647827748632; Fri, 25 Sep 2020 06:19:10 -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-29-z58LHSflPx6mN3UnwX9JUw-1; Fri, 25 Sep 2020 09:19:05 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 088A657244; Fri, 25 Sep 2020 13:18:59 +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 D94067368C; Fri, 25 Sep 2020 13:18:58 +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 A297E8C7A4; Fri, 25 Sep 2020 13:18:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08PDGNnS005158 for ; Fri, 25 Sep 2020 09:16:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 688705C1C2; Fri, 25 Sep 2020 13:16:23 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id E06705C1BB for ; Fri, 25 Sep 2020 13:16:22 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601039949; 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=h6+KHC4u/pEgyw8Rt2hmcp/6B5mBgUkvIZV5/gMJ4jg=; b=DRzfjE2gyubedOL4mB0MbnDP1gULSRheyF9Sx5R+JR0R1zIz4fbC82UtRZ7dagnAFsiLz1 ilhyctr5bwknDGrikZyTVmGPPwPKIPUxrd6lcWX0ACJTsR2fcSQdh43GTnHKCAjtskFVe/ cjwf81Tzo+5Q28qtPyh8p/mi0F/tbf8= X-MC-Unique: z58LHSflPx6mN3UnwX9JUw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/7] interface: use g_new0 instead of VIR_ALLOC* Date: Fri, 25 Sep 2020 15:16:10 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.13 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: Peter Krempa --- src/interface/interface_backend_netcf.c | 16 ++++++---------- src/interface/interface_backend_udev.c | 22 ++++++++-------------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index f30829442d..df04484c59 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -247,8 +247,7 @@ netcfGetMinimalDefForDevice(struct netcf_if *iface) virInterfaceDef *def; =20 /* Allocate our interface definition structure */ - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virInterfaceDef, 1); =20 def->name =3D g_strdup(ncf_if_name(iface)); def->mac =3D g_strdup(ncf_if_mac_string(iface)); @@ -375,8 +374,7 @@ static int netcfConnectNumOfInterfacesImpl(virConnectPt= r conn, goto cleanup; } =20 - if (VIR_ALLOC_N(names, count) < 0) - goto cleanup; + names =3D g_new0(char *, count); =20 if ((count =3D ncf_list_interfaces(driver->netcf, count, names, status= )) < 0) { const char *errmsg, *details; @@ -465,8 +463,7 @@ static int netcfConnectListInterfacesImpl(virConnectPtr= conn, goto cleanup; } =20 - if (VIR_ALLOC_N(allnames, count) < 0) - goto cleanup; + allnames =3D g_new0(char *, count); =20 if ((count =3D ncf_list_interfaces(driver->netcf, count, allnames, sta= tus)) < 0) { const char *errmsg, *details; @@ -651,8 +648,7 @@ netcfConnectListAllInterfaces(virConnectPtr conn, goto cleanup; } =20 - if (VIR_ALLOC_N(names, count) < 0) - goto cleanup; + names =3D g_new0(char *, count); =20 if ((count =3D ncf_list_interfaces(driver->netcf, count, names, ncf_flags)) < 0) { @@ -666,8 +662,8 @@ netcfConnectListAllInterfaces(virConnectPtr conn, goto cleanup; } =20 - if (ifaces && VIR_ALLOC_N(tmp_iface_objs, count + 1) < 0) - goto cleanup; + if (ifaces) + tmp_iface_objs =3D g_new0(virInterfacePtr, count + 1); =20 for (i =3D 0; i < count; i++) { virInterfaceDefPtr def; diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index 670de48d52..4e0a80765c 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -86,8 +86,7 @@ udevGetMinimalDefForDevice(struct udev_device *dev) virInterfaceDef *def; =20 /* Allocate our interface definition structure */ - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virInterfaceDef, 1); =20 def->name =3D g_strdup(udev_device_get_sysname(dev)); def->mac =3D g_strdup(udev_device_get_sysattr_value(dev, "address")); @@ -352,10 +351,8 @@ udevConnectListAllInterfaces(virConnectPtr conn, } =20 /* If we're asked for the ifaces then alloc up memory */ - if (ifaces && VIR_ALLOC_N(ifaces_list, count + 1) < 0) { - ret =3D -1; - goto cleanup; - } + if (ifaces) + ifaces_list =3D g_new0(virInterfacePtr, count + 1); =20 /* Get a list we can walk */ devices =3D udev_enumerate_get_list_entry(enumerate); @@ -758,8 +755,8 @@ udevGetIfaceDefBond(struct udev *udev, } =20 /* Allocate our list of slave devices */ - if (VIR_ALLOC_N(ifacedef->data.bond.itf, slave_count) < 0) - goto error; + ifacedef->data.bond.itf =3D g_new0(struct _virInterfaceDef *, + slave_count); ifacedef->data.bond.nbItf =3D slave_count; =20 for (i =3D 0; i < slave_count; i++) { @@ -873,8 +870,7 @@ udevGetIfaceDefBridge(struct udev *udev, } =20 /* Allocate our list of member devices */ - if (VIR_ALLOC_N(ifacedef->data.bridge.itf, member_count) < 0) - goto error; + ifacedef->data.bridge.itf =3D g_new0(struct _virInterfaceDef *, member= _count); ifacedef->data.bridge.nbItf =3D member_count; =20 /* Get the interface definitions for each member of the bridge */ @@ -976,8 +972,7 @@ udevGetIfaceDef(struct udev *udev, const char *name) const char *devtype; =20 /* Allocate our interface definition structure */ - if (VIR_ALLOC(ifacedef) < 0) - return NULL; + ifacedef =3D g_new0(virInterfaceDef, 1); =20 /* Clear our structure and set safe defaults */ ifacedef->startmode =3D VIR_INTERFACE_START_UNSPECIFIED; @@ -1158,8 +1153,7 @@ udevStateInitialize(bool privileged, return -1; } =20 - if (VIR_ALLOC(driver) < 0) - goto cleanup; + driver =3D g_new0(struct udev_iface_driver, 1); =20 driver->lockFD =3D -1; =20 --=20 2.26.2