From nobody Mon May 6 02:40:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1601850173; cv=none; d=zohomail.com; s=zohoarc; b=RQsSdFD/akDvTwhvmGESKSwaG3DmHCgdHOIh0963hXAm/WdGzw3xU5UQsykA98NzzNFYcUsaCnHsk1BPXBFlJECynS3Oj8TvOIKlHmP5YZ3yXOGh1tWmKCSQUROVCgKSBOoMSOBuDYnLdQf3qnVTa7vn/uX6rL9qbbuwbWwLGV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601850173; 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=1KP2y6kl3uvXvyXSC0W1WscZH8nCjo54gLw1bCFY9s8=; b=nZYnbJeEf5bvG5F/VgBOxtvTvvy1Fntb6I39xFyZFLr1Qg3h0l+8OKS1YPsk4GScVQGJE6T0ja+D7O/pUweWgBwDB8ZuJZ2zIwts0FnV5SWXFz/tal+RLx3ui5RnW5SyIe7Qq0fywvqzbQbzee800VHNaOC8zKTVXEHLkJO6iC8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601850173747454.38681830317773; Sun, 4 Oct 2020 15:22:53 -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-502-Fv6JxkXKNpSmw5tkegPjkg-1; Sun, 04 Oct 2020 18:22:50 -0400 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 ECB9610054FF; Sun, 4 Oct 2020 22:22:44 +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 C9BDD55783; Sun, 4 Oct 2020 22:22:44 +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 9A21E181A2E5; Sun, 4 Oct 2020 22:22:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 094MMhha031587 for ; Sun, 4 Oct 2020 18:22:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6049055789; Sun, 4 Oct 2020 22:22:43 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC1F955783 for ; Sun, 4 Oct 2020 22:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601850172; 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=1KP2y6kl3uvXvyXSC0W1WscZH8nCjo54gLw1bCFY9s8=; b=CGyCWDzNB4bStvtm3PZcPOA6VAsOhA+ZHt5KwddOq61C+s+k9Mi5kpapEHNJ7JxcokKZfU sAses+UuOKhQvQ+xCRQFje5WjssYove5AvBhWEjlLnEMhJs23F0j0HVXoROE4/YUJy3soU C/uRMVqRU4bpJxKqNzl34GrJA3VH+oI= X-MC-Unique: Fv6JxkXKNpSmw5tkegPjkg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/4] vbox: use g_new0 in vboxDumpAudio Date: Mon, 5 Oct 2020 00:22:23 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.15 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) Elimination of the positive conditions reduces the indentation by two levels. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/vbox/vbox_common.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 9f6ef2f2ac..45fd670a11 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3798,20 +3798,16 @@ vboxDumpAudio(virDomainDefPtr def, vboxDriverPtr da= ta G_GNUC_UNUSED, PRUint32 audioController =3D AudioControllerType_AC97; =20 def->nsounds =3D 1; - if (VIR_ALLOC_N(def->sounds, def->nsounds) >=3D 0) { - if (VIR_ALLOC(def->sounds[0]) >=3D 0) { - gVBoxAPI.UIAudioAdapter.GetAudioController(audioAdapte= r, &audioController); - if (audioController =3D=3D AudioControllerType_SB16) { - def->sounds[0]->model =3D VIR_DOMAIN_SOUND_MODEL_S= B16; - } else if (audioController =3D=3D AudioControllerType_= AC97) { - def->sounds[0]->model =3D VIR_DOMAIN_SOUND_MODEL_A= C97; - } - } else { - VIR_FREE(def->sounds); - def->nsounds =3D 0; - } - } else { - def->nsounds =3D 0; + if (VIR_ALLOC_N(def->sounds, def->nsounds) < 0) + return; + if (VIR_ALLOC(def->sounds[0]) < 0) + return; + + gVBoxAPI.UIAudioAdapter.GetAudioController(audioAdapter, &audi= oController); + if (audioController =3D=3D AudioControllerType_SB16) { + def->sounds[0]->model =3D VIR_DOMAIN_SOUND_MODEL_SB16; + } else if (audioController =3D=3D AudioControllerType_AC97) { + def->sounds[0]->model =3D VIR_DOMAIN_SOUND_MODEL_AC97; } } VBOX_RELEASE(audioAdapter); --=20 2.26.2 From nobody Mon May 6 02:40:10 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=1601850309; cv=none; d=zohomail.com; s=zohoarc; b=KsMRHqFRaSXZxxldmfXdxZX9JfE7yOo5o3l0/UekXfzxp0zZ2v5fAEKKnxhHa2KeIujgJZ5TfrUk2pxwuQHFQxMGLkP4/pl3VIYqHUyBRu2Z2KRFh7ZZh3qojTvzgg79d6wMWGMUoDfLSJWwt83W+UwKL5k6WoajNv+V7DYIaMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601850309; 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=MFzPC1jV7Mxje73MNvCIWM0uPOV9ruWMVfOqyIaGhWo=; b=Uwm2dpjuGZg5C02cRh4xdvCzuWXCzq4i+ANkAPLiV48TBB8pgPi1CRQCXS4fOzdPt1JBKn2y2F4lgOn2wLFy7pkTGfXeGamtblIDAtiqkzCgg3A31XOmW5gPc9FngzaZ43ioUzv03Nd7sECQOtuJU0kQR4Bf7bWe2MvWgewWcL0= 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 16018503095711004.6156579513796; Sun, 4 Oct 2020 15:25:09 -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-210-1JaG7PkuP12KW2C9J_xk1Q-1; Sun, 04 Oct 2020 18:22:53 -0400 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 69880801ADC; Sun, 4 Oct 2020 22:22:48 +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 42E955D9CD; Sun, 4 Oct 2020 22:22:48 +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 1384344A67; Sun, 4 Oct 2020 22:22:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 094MMk09031604 for ; Sun, 4 Oct 2020 18:22:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 56A3555783; Sun, 4 Oct 2020 22:22:46 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2B4E55789 for ; Sun, 4 Oct 2020 22:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601850308; 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=MFzPC1jV7Mxje73MNvCIWM0uPOV9ruWMVfOqyIaGhWo=; b=XwAT6Zfc2rC4xglgR4AAJ/RXG39ScOroCFgzrhZeKBI1uYxN7rJkxSXkgd/nOA+cKFxHIl 0PW07FYRc93R7IratOUhorcrSQXKUsuXnV9VKg1T+yjyqkXZkH+wk+iqaussqR0iTHpqSH 1IGimX1QUnc0+NOBEjlCwbtOe/AWlOk= X-MC-Unique: 1JaG7PkuP12KW2C9J_xk1Q-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/4] vbox: invert condition in vboxSnapshotGetReadOnlyDisks Date: Mon, 5 Oct 2020 00:22:24 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.14 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) Error out on (impossible) failed allocation, to reduce indentation. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/vbox/vbox_common.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 45fd670a11..f59af697ea 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -5971,15 +5971,14 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDefPt= r def, } =20 /* Allocate mem, if fails return error */ - if (VIR_ALLOC_N(defdom->disks, defdom->ndisks) >=3D 0) { - for (i =3D 0; i < defdom->ndisks; i++) { - virDomainDiskDefPtr diskDef =3D virDomainDiskDefNew(NULL); - if (!diskDef) - goto cleanup; - defdom->disks[i] =3D diskDef; - } - } else { + if (VIR_ALLOC_N(defdom->disks, defdom->ndisks) < 0) goto cleanup; + + for (i =3D 0; i < defdom->ndisks; i++) { + virDomainDiskDefPtr diskDef =3D virDomainDiskDefNew(NULL); + if (!diskDef) + goto cleanup; + defdom->disks[i] =3D diskDef; } =20 /* get the attachment details here */ --=20 2.26.2 From nobody Mon May 6 02:40:10 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=1601850321; cv=none; d=zohomail.com; s=zohoarc; b=Ag2v16zzDq8td8n+WzeAEF0mQs1AQvb3cSTiCh88aHj+R8ZZA4HLgiTj84Cyr5qBef+9vLtbpJzTU2T5FIRu6CR4yvMUPx/8OBkSI8F9O4X3mZB+au0lSMzZKtaiI+47Vd8BXTDltFtca4pCp8sc9cDs2gF/vpjXHLMAO+/7/8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601850321; 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=FvwPJ6IaQnb3KOE6fF5bXdS27J6yA92jNZuAUVnCGMU=; b=ie7FNCdJ10PmyV/qkK7NU7vH+bV4wWKBUkqHvWdOP0M+eT58CsL7hFDca3A8ZSqz/QBXanIIC+G6aj7P3zOn/fPv5iaMo6NShMVcbbM7g4QMi1XMvQFLSXY+jiyb92G2UY68mkg84SRSBpl9v62oVoVmou0rjG2x1qbyer/xk3g= 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 160185032187982.31027430717893; Sun, 4 Oct 2020 15:25:21 -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-488-yGBqlD59O8abMcwtzKUYSA-1; Sun, 04 Oct 2020 18:22:58 -0400 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 1A50A1868403; Sun, 4 Oct 2020 22:22:53 +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 ED9B978804; Sun, 4 Oct 2020 22:22:52 +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 B8F71181A6DF; Sun, 4 Oct 2020 22:22:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 094MMp4k031628 for ; Sun, 4 Oct 2020 18:22:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id AFE7B55797; Sun, 4 Oct 2020 22:22:51 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3892155794 for ; Sun, 4 Oct 2020 22:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601850320; 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=FvwPJ6IaQnb3KOE6fF5bXdS27J6yA92jNZuAUVnCGMU=; b=fOnRuG1LYfjOzf4YrBy+QmIQnLoXF817L2A25rNvWxXi0n3PICX6EeKACfeyVQthDiAZES QvMV+LlG4xFvBobzfWC87M7wREcywjacQCW/rnp8POeeQG5fvFnXo7vm8PXKsjJn1e8ZY0 MpPsJDPRAdhyJF1WMnL5aeLN7/xZiLo= X-MC-Unique: yGBqlD59O8abMcwtzKUYSA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/4] vbox: refactor vboxNetworkGetXMLDesc a bit Date: Mon, 5 Oct 2020 00:22:25 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.11 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) Error out on allocation failure to reduce the nesting. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/vbox/vbox_network.c | 102 +++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 53 deletions(-) diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index dafbc114f6..ceffc2053d 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -821,69 +821,65 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr netw= ork, unsigned int flags) networkNameUtf16, &dhcpServer); if (dhcpServer) { + PRUnichar *ipAddressUtf16 =3D NULL; + PRUnichar *networkMaskUtf16 =3D NULL; + PRUnichar *fromIPAddressUtf16 =3D NULL; + PRUnichar *toIPAddressUtf16 =3D NULL; + PRUnichar *macAddressUtf16 =3D NULL; + bool errorOccurred =3D false; + ipdef->nranges =3D 1; - if (VIR_ALLOC_N(ipdef->ranges, ipdef->nranges) >=3D 0) { - PRUnichar *ipAddressUtf16 =3D NULL; - PRUnichar *networkMaskUtf16 =3D NULL; - PRUnichar *fromIPAddressUtf16 =3D NULL; - PRUnichar *toIPAddressUtf16 =3D NULL; - bool errorOccurred =3D false; =20 - gVBoxAPI.UIDHCPServer.GetIPAddress(dhcpServer, &ipAddressUtf16= ); - gVBoxAPI.UIDHCPServer.GetNetworkMask(dhcpServer, &networkMaskU= tf16); - gVBoxAPI.UIDHCPServer.GetLowerIP(dhcpServer, &fromIPAddressUtf= 16); - gVBoxAPI.UIDHCPServer.GetUpperIP(dhcpServer, &toIPAddressUtf16= ); - /* Currently virtualbox supports only one dhcp server per netw= ork - * with contiguous address space from start to end - */ - addr =3D ipdef->ranges[0].addr; - if (vboxSocketParseAddrUtf16(data, ipAddressUtf16, - &ipdef->address) < 0 || - vboxSocketParseAddrUtf16(data, networkMaskUtf16, - &ipdef->netmask) < 0 || - vboxSocketParseAddrUtf16(data, fromIPAddressUtf16, - &addr.start) < 0 || - vboxSocketParseAddrUtf16(data, toIPAddressUtf16, - &addr.end) < 0) { - errorOccurred =3D true; - } + if (VIR_ALLOC_N(ipdef->ranges, ipdef->nranges) < 0) + goto cleanup; =20 - VBOX_UTF16_FREE(ipAddressUtf16); - VBOX_UTF16_FREE(networkMaskUtf16); - VBOX_UTF16_FREE(fromIPAddressUtf16); - VBOX_UTF16_FREE(toIPAddressUtf16); - - if (errorOccurred) - goto cleanup; - } else { - ipdef->nranges =3D 0; + gVBoxAPI.UIDHCPServer.GetIPAddress(dhcpServer, &ipAddressUtf16); + gVBoxAPI.UIDHCPServer.GetNetworkMask(dhcpServer, &networkMaskUtf16= ); + gVBoxAPI.UIDHCPServer.GetLowerIP(dhcpServer, &fromIPAddressUtf16); + gVBoxAPI.UIDHCPServer.GetUpperIP(dhcpServer, &toIPAddressUtf16); + /* Currently virtualbox supports only one dhcp server per network + * with contiguous address space from start to end + */ + addr =3D ipdef->ranges[0].addr; + if (vboxSocketParseAddrUtf16(data, ipAddressUtf16, + &ipdef->address) < 0 || + vboxSocketParseAddrUtf16(data, networkMaskUtf16, + &ipdef->netmask) < 0 || + vboxSocketParseAddrUtf16(data, fromIPAddressUtf16, + &addr.start) < 0 || + vboxSocketParseAddrUtf16(data, toIPAddressUtf16, + &addr.end) < 0) { + errorOccurred =3D true; } =20 + VBOX_UTF16_FREE(ipAddressUtf16); + VBOX_UTF16_FREE(networkMaskUtf16); + VBOX_UTF16_FREE(fromIPAddressUtf16); + VBOX_UTF16_FREE(toIPAddressUtf16); + + if (errorOccurred) + goto cleanup; + ipdef->nhosts =3D 1; - if (VIR_ALLOC_N(ipdef->hosts, ipdef->nhosts) >=3D 0) { - PRUnichar *macAddressUtf16 =3D NULL; - PRUnichar *ipAddressUtf16 =3D NULL; - bool errorOccurred =3D false; + if (VIR_ALLOC_N(ipdef->hosts, ipdef->nhosts) < 0) + goto cleanup; =20 - ipdef->hosts[0].name =3D g_strdup(network->name); - gVBoxAPI.UIHNInterface.GetHardwareAddress(networkInterface, &m= acAddressUtf16); - gVBoxAPI.UIHNInterface.GetIPAddress(networkInterface, &ipAddre= ssUtf16); + ipdef->hosts[0].name =3D g_strdup(network->name); + gVBoxAPI.UIHNInterface.GetHardwareAddress(networkInterface, &macAd= dressUtf16); + gVBoxAPI.UIHNInterface.GetIPAddress(networkInterface, &ipAddressUt= f16); =20 - VBOX_UTF16_TO_UTF8(macAddressUtf16, &ipdef->hosts[0].mac); + VBOX_UTF16_TO_UTF8(macAddressUtf16, &ipdef->hosts[0].mac); =20 - if (vboxSocketParseAddrUtf16(data, ipAddressUtf16, - &ipdef->hosts[0].ip) < 0) { - errorOccurred =3D true; - } - - VBOX_UTF16_FREE(macAddressUtf16); - VBOX_UTF16_FREE(ipAddressUtf16); - - if (errorOccurred) - goto cleanup; - } else { - ipdef->nhosts =3D 0; + if (vboxSocketParseAddrUtf16(data, ipAddressUtf16, + &ipdef->hosts[0].ip) < 0) { + errorOccurred =3D true; } + + VBOX_UTF16_FREE(macAddressUtf16); + VBOX_UTF16_FREE(ipAddressUtf16); + + if (errorOccurred) + goto cleanup; } else { PRUnichar *networkMaskUtf16 =3D NULL; PRUnichar *ipAddressUtf16 =3D NULL; --=20 2.26.2 From nobody Mon May 6 02:40:10 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=1601850244; cv=none; d=zohomail.com; s=zohoarc; b=LdbrHnrmMKA6XPlC6fTokoGFQdEG1eBbvlnEH1N76aJzFwTCDcVzfKP7mQK4oxEMa2nbK2DRj1Em684JZY9Pq0YwHG6TWW3OZYVf467ZU/m275m1lfsKpwYwkHZvYtD6vR4rGAJg2la/zd0oqD1QU3u9x1dmTlDLcI0LzPZML6A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601850244; 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=/+32GAMFz0AhhA46q3Neaggzi/vXzuFPBEjZCwvRM0s=; b=msVjsQmNL8qMxLU5v4vWxlhn78f5LhbQntzRVn8R+qnznawcfEXCBzchpcdWdaUGGs7vORmYMgT7cbi/F4/Buqm8n0/VB8YE1oPlJXRHInDplUrH3GWjAh26oEzsS0LUPNIEYuuYHn92xlt2RDOLtgyEJCnVv9cXOYAxRBwPlz4= 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 1601850244339221.9268996042731; Sun, 4 Oct 2020 15:24:04 -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-335-h0xOt_ksPYShrT0Fgxgxyw-1; Sun, 04 Oct 2020 18:23:02 -0400 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 A76D11DDF4; Sun, 4 Oct 2020 22:22:56 +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 8346F19D7C; Sun, 4 Oct 2020 22:22:56 +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 509CD181A869; Sun, 4 Oct 2020 22:22:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 094MMsgO031640 for ; Sun, 4 Oct 2020 18:22:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id BE21355789; Sun, 4 Oct 2020 22:22:54 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FF4155797 for ; Sun, 4 Oct 2020 22:22:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601850243; 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=/+32GAMFz0AhhA46q3Neaggzi/vXzuFPBEjZCwvRM0s=; b=fNKssjVeTmP8c6v4hM8RSzx1rCMDnenTmwYKvzKkRGlEbFo66tg9oSsMeFc2EerJ783XbQ dHUS8CmHoLa0060Ag1LAzpGN5/Up1E7IvpQ3DAvhoeg+8uN30gX3fzjJT+K99DvyknOsup y2Qw5GZCtCjlNABVrAQ1Vpzp3aQK/0k= X-MC-Unique: h0xOt_ksPYShrT0Fgxgxyw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/4] vbox: use g_new0 instead of VIR_ALLOC Date: Mon, 5 Oct 2020 00:22:26 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.84 on 10.5.11.23 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/vbox/vbox_common.c | 90 +++++++++++------------------------ src/vbox/vbox_network.c | 13 ++--- src/vbox/vbox_snapshot_conf.c | 48 ++++++++----------- 3 files changed, 53 insertions(+), 98 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index f59af697ea..317fb5ce92 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3010,8 +3010,7 @@ vboxHostDeviceGetXMLDesc(vboxDriverPtr data, virDomai= nDefPtr def, IMachine *mach goto release_filters; =20 /* Alloc mem needed for the filters now */ - if (VIR_ALLOC_N(def->hostdevs, def->nhostdevs) < 0) - goto release_filters; + def->hostdevs =3D g_new0(virDomainHostdevDefPtr, def->nhostdevs); =20 for (i =3D 0; i < def->nhostdevs; i++) { def->hostdevs[i] =3D virDomainHostdevDefNew(); @@ -3219,8 +3218,7 @@ vboxDumpDisks(virDomainDefPtr def, vboxDriverPtr data= , IMachine *machine) } =20 /* Allocate mem, if fails return error */ - if (VIR_ALLOC_N(def->disks, def->ndisks) < 0) - goto cleanup; + def->disks =3D g_new0(virDomainDiskDefPtr, def->ndisks); =20 for (i =3D 0; i < def->ndisks; i++) { disk =3D virDomainDiskDefNew(NULL); @@ -3452,12 +3450,10 @@ vboxDumpVideo(virDomainDefPtr def, vboxDriverPtr da= ta G_GNUC_UNUSED, PRBool accelerate2DEnabled =3D PR_FALSE; =20 /* Currently supports only one graphics card */ - if (VIR_ALLOC_N(def->videos, 1) < 0) - return -1; + def->videos =3D g_new0(virDomainVideoDefPtr, 1); def->nvideos =3D 1; =20 - if (VIR_ALLOC(def->videos[0]) < 0) - return -1; + def->videos[0] =3D g_new0(virDomainVideoDef, 1); =20 gVBoxAPI.UIMachine.GetVRAMSize(machine, &VRAMSize); gVBoxAPI.UIMachine.GetMonitorCount(machine, &monitorCount); @@ -3467,8 +3463,7 @@ vboxDumpVideo(virDomainDefPtr def, vboxDriverPtr data= G_GNUC_UNUSED, def->videos[0]->type =3D VIR_DOMAIN_VIDEO_TYPE_VBOX; def->videos[0]->vram =3D VRAMSize * 1024; def->videos[0]->heads =3D monitorCount; - if (VIR_ALLOC(def->videos[0]->accel) < 0) - return -1; + def->videos[0]->accel =3D g_new0(virDomainVideoAccelDef, 1); def->videos[0]->accel->accel3d =3D accelerate3DEnabled ? VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO; def->videos[0]->accel->accel2d =3D accelerate2DEnabled ? @@ -3506,8 +3501,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) PRUnichar *valueDisplayUtf16 =3D NULL; char *valueDisplayUtf8 =3D NULL; =20 - if (VIR_ALLOC(graphics) < 0) - goto cleanup; + graphics =3D g_new0(virDomainGraphicsDef, 1); =20 VBOX_UTF8_TO_UTF16("FRONTEND/Display", &keyUtf16); gVBoxAPI.UIMachine.GetExtraData(machine, keyUtf16, &valueDisplayUt= f16); @@ -3534,8 +3528,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) } VBOX_UTF8_FREE(valueDisplayUtf8); } else if (STRNEQ_NULLABLE(valueTypeUtf8, "vrdp")) { - if (VIR_ALLOC(graphics) < 0) - goto cleanup; + graphics =3D g_new0(virDomainGraphicsDef, 1); =20 graphics->type =3D VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP; graphics->data.desktop.display =3D g_strdup(getenv("DISPLAY")); @@ -3554,8 +3547,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) PRBool allowMultiConnection =3D PR_FALSE; PRBool reuseSingleConnection =3D PR_FALSE; =20 - if (VIR_ALLOC(graphics) < 0) - goto cleanup; + graphics =3D g_new0(virDomainGraphicsDef, 1); =20 gVBoxAPI.UIVRDEServer.GetPorts(data, VRDEServer, machine, graphics= ); =20 @@ -3612,8 +3604,7 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxDriver= Ptr data, IMachine *machine goto cleanup; } =20 - if (VIR_ALLOC_N(def->fss, sharedFolders.count) < 0) - goto cleanup; + def->fss =3D g_new0(virDomainFSDefPtr, sharedFolders.count); =20 for (i =3D 0; i < sharedFolders.count; i++) { ISharedFolder *sharedFolder =3D sharedFolders.items[i]; @@ -3798,10 +3789,8 @@ vboxDumpAudio(virDomainDefPtr def, vboxDriverPtr dat= a G_GNUC_UNUSED, PRUint32 audioController =3D AudioControllerType_AC97; =20 def->nsounds =3D 1; - if (VIR_ALLOC_N(def->sounds, def->nsounds) < 0) - return; - if (VIR_ALLOC(def->sounds[0]) < 0) - return; + def->sounds =3D g_new0(virDomainSoundDefPtr, def->nsounds); + def->sounds[0] =3D g_new0(virDomainSoundDef, 1); =20 gVBoxAPI.UIAudioAdapter.GetAudioController(audioAdapter, &audi= oController); if (audioController =3D=3D AudioControllerType_SB16) { @@ -3839,8 +3828,7 @@ vboxDumpSerial(virDomainDefPtr def, vboxDriverPtr dat= a, IMachine *machine, PRUin =20 /* Allocate memory for the serial ports which are enabled */ if (def->nserials > 0) { - if (VIR_ALLOC_N(def->serials, def->nserials) < 0) - return -1; + def->serials =3D g_new0(virDomainChrDefPtr, def->nserials); =20 for (i =3D 0; i < def->nserials; i++) { def->serials[i] =3D virDomainChrDefNew(NULL); @@ -3934,8 +3922,7 @@ vboxDumpParallel(virDomainDefPtr def, vboxDriverPtr d= ata, IMachine *machine, PRU =20 /* Allocate memory for the parallel ports which are enabled */ if (def->nparallels > 0) { - if (VIR_ALLOC_N(def->parallels, def->nparallels) < 0) - return -1; + def->parallels =3D g_new0(virDomainChrDefPtr, def->nparallels); =20 for (i =3D 0; i < def->nparallels; i++) { def->parallels[i] =3D virDomainChrDefNew(NULL); @@ -4715,10 +4702,7 @@ vboxSnapshotRedefine(virDomainPtr dom, VBOX_UTF16_TO_UTF8(formatUtf, &format); VBOX_UTF16_FREE(formatUtf); =20 - if (VIR_ALLOC(readWriteDisk) < 0) { - VIR_FREE(formatUtf); - goto cleanup; - } + readWriteDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); =20 readWriteDisk->format =3D format; readWriteDisk->uuid =3D uuid; @@ -4855,11 +4839,7 @@ vboxSnapshotRedefine(virDomainPtr dom, goto cleanup; } =20 - if (VIR_ALLOC(readOnlyDisk) < 0) { - VIR_FREE(uuid); - VIR_FREE(parentUuid); - goto cleanup; - } + readOnlyDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); =20 readOnlyDisk->format =3D format; readOnlyDisk->uuid =3D uuid; @@ -4953,8 +4933,7 @@ vboxSnapshotRedefine(virDomainPtr dom, /* Here, all disks are closed or deleted */ =20 /* We are now going to create and fill the Snapshot xml struct */ - if (VIR_ALLOC(newSnapshotPtr) < 0) - goto cleanup; + newSnapshotPtr =3D g_new0(virVBoxSnapshotConfSnapshot, 1); =20 if (virUUIDGenerate(snapshotUuid) < 0) goto cleanup; @@ -5088,8 +5067,7 @@ vboxSnapshotRedefine(virDomainPtr dom, } VBOX_UTF16_FREE(locationUtf16); =20 - if (VIR_ALLOC(disk) < 0) - goto cleanup; + disk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); =20 rc =3D gVBoxAPI.UIMedium.GetFormat(medium, &formatUtf16); if (NS_FAILED(rc)) { @@ -5248,8 +5226,7 @@ vboxSnapshotRedefine(virDomainPtr dom, * media registry and the machine storage controllers. */ =20 - if (VIR_ALLOC(newHardDisk) < 0) - goto cleanup; + newHardDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); =20 rc =3D gVBoxAPI.UIMedium.GetId(newMedium, &iid); if (NS_FAILED(rc)) { @@ -5559,8 +5536,7 @@ vboxDomainSnapshotGetAll(virDomainPtr dom, if (count =3D=3D 0) goto out; =20 - if (VIR_ALLOC_N(list, count) < 0) - goto error; + list =3D g_new0(ISnapshot *, count); =20 rc =3D gVBoxAPI.UIMachine.FindSnapshot(machine, &empty, list); if (NS_FAILED(rc) || !list[0]) { @@ -5742,11 +5718,9 @@ vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPt= r def, } } /* Allocate mem, if fails return error */ - if (VIR_ALLOC_N(def->disks, def->ndisks) < 0) - goto cleanup; + def->disks =3D g_new0(virDomainSnapshotDiskDef, def->ndisks); for (i =3D 0; i < def->ndisks; i++) { - if (VIR_ALLOC(def->disks[i].src) < 0) - goto cleanup; + def->disks[i].src =3D g_new0(virStorageSource, 1); } =20 /* get the attachment details here */ @@ -5971,8 +5945,7 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDefPtr = def, } =20 /* Allocate mem, if fails return error */ - if (VIR_ALLOC_N(defdom->disks, defdom->ndisks) < 0) - goto cleanup; + defdom->disks =3D g_new0(virDomainDiskDefPtr, defdom->ndisks); =20 for (i =3D 0; i < defdom->ndisks; i++) { virDomainDiskDefPtr diskDef =3D virDomainDiskDefNew(NULL); @@ -6339,8 +6312,7 @@ static int vboxDomainSnapshotListNames(virDomainPtr d= om, char **names, vboxIID empty; =20 VBOX_IID_INITIALIZE(&empty); - if (VIR_ALLOC_N(snapshots, 1) < 0) - goto cleanup; + snapshots =3D g_new0(ISnapshot *, 1); rc =3D gVBoxAPI.UIMachine.FindSnapshot(machine, &empty, snapshots); if (NS_FAILED(rc) || !snapshots[0]) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -7015,8 +6987,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) * the machine storage controller. */ =20 - if (VIR_ALLOC(disk) < 0) - goto cleanup; + disk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); =20 rc =3D gVBoxAPI.UIMedium.GetId(newMedium, &iid); if (NS_FAILED(rc)) { @@ -7508,9 +7479,8 @@ vboxConnectListAllDomains(virConnectPtr conn, !MATCH(VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART)) || (MATCH(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE) && !MATCH(VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE))) { - if (domains && - VIR_ALLOC_N(*domains, 1) < 0) - goto cleanup; + if (domains) + *domains =3D g_new0(virDomainPtr, 1); =20 ret =3D 0; goto cleanup; @@ -7523,9 +7493,8 @@ vboxConnectListAllDomains(virConnectPtr conn, goto cleanup; } =20 - if (domains && - VIR_ALLOC_N(doms, machines.count + 1) < 0) - goto cleanup; + if (domains) + doms =3D g_new0(virDomainPtr, machines.count + 1); =20 for (i =3D 0; i < machines.count; i++) { IMachine *machine =3D machines.items[i]; @@ -7784,8 +7753,7 @@ vboxDomainSendKey(virDomainPtr dom, =20 keyDownCodes =3D (PRInt32 *) keycodes; =20 - if (VIR_ALLOC_N(keyUpCodes, nkeycodes) < 0) - return ret; + keyUpCodes =3D g_new0(PRInt32, nkeycodes); =20 /* translate keycodes to xt and generate keyup scancodes */ for (i =3D 0; i < nkeycodes; i++) { diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index ceffc2053d..c3c9a55248 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -785,10 +785,8 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr netwo= rk, unsigned int flags) VBOX_IID_INITIALIZE(&vboxnet0IID); virCheckFlags(0, NULL); =20 - if (VIR_ALLOC(def) < 0) - goto cleanup; - if (VIR_ALLOC(ipdef) < 0) - goto cleanup; + def =3D g_new0(virNetworkDef, 1); + ipdef =3D g_new0(virNetworkIPDef, 1); def->ips =3D ipdef; def->nips =3D 1; =20 @@ -829,9 +827,7 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr networ= k, unsigned int flags) bool errorOccurred =3D false; =20 ipdef->nranges =3D 1; - - if (VIR_ALLOC_N(ipdef->ranges, ipdef->nranges) < 0) - goto cleanup; + ipdef->ranges =3D g_new0(virNetworkDHCPRangeDef, ipdef->nranges); =20 gVBoxAPI.UIDHCPServer.GetIPAddress(dhcpServer, &ipAddressUtf16); gVBoxAPI.UIDHCPServer.GetNetworkMask(dhcpServer, &networkMaskUtf16= ); @@ -861,8 +857,7 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr networ= k, unsigned int flags) goto cleanup; =20 ipdef->nhosts =3D 1; - if (VIR_ALLOC_N(ipdef->hosts, ipdef->nhosts) < 0) - goto cleanup; + ipdef->hosts =3D g_new0(virNetworkDHCPHostDef, ipdef->nhosts); =20 ipdef->hosts[0].name =3D g_strdup(network->name); gVBoxAPI.UIHNInterface.GetHardwareAddress(networkInterface, &macAd= dressUtf16); diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c index a18958fcc0..cb201e777e 100644 --- a/src/vbox/vbox_snapshot_conf.c +++ b/src/vbox/vbox_snapshot_conf.c @@ -45,8 +45,8 @@ virVBoxSnapshotConfCreateVBoxSnapshotConfHardDiskPtr(xmlN= odePtr diskNode, char *location =3D NULL; char *tmp =3D NULL; int n =3D 0; - if (VIR_ALLOC(hardDisk) < 0) - goto cleanup; + + hardDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); =20 xPathContext->node =3D diskNode; =20 @@ -54,8 +54,8 @@ virVBoxSnapshotConfCreateVBoxSnapshotConfHardDiskPtr(xmlN= odePtr diskNode, if (n < 0) goto cleanup; =20 - if (n && VIR_ALLOC_N(hardDisk->children, n) < 0) - goto cleanup; + if (n) + hardDisk->children =3D g_new0(virVBoxSnapshotConfHardDiskPtr, n); hardDisk->nchildren =3D n; for (i =3D 0; i < hardDisk->nchildren; i++) { hardDisk->children[i] =3D virVBoxSnapshotConfCreateVBoxSnapshotCon= fHardDiskPtr(nodes[i], xPathContext, machineLocation); @@ -123,8 +123,7 @@ virVBoxSnapshotConfRetrieveMediaRegistry(xmlNodePtr med= iaRegistryNode, int result =3D -1; int n =3D 0; =20 - if (VIR_ALLOC(mediaRegistry) < 0) - goto cleanup; + mediaRegistry =3D g_new0(virVBoxSnapshotConfMediaRegistry, 1); =20 xPathContext->node =3D mediaRegistryNode; hardDisksNode =3D virXPathNode("./vbox:HardDisks", xPathContext); @@ -133,8 +132,8 @@ virVBoxSnapshotConfRetrieveMediaRegistry(xmlNodePtr med= iaRegistryNode, n =3D virXPathNodeSet("./vbox:HardDisk", xPathContext, &nodes); if (n < 0) goto cleanup; - if (n && VIR_ALLOC_N(mediaRegistry->disks, n) < 0) - goto cleanup; + if (n) + mediaRegistry->disks =3D g_new0(virVBoxSnapshotConfHardDiskPtr, n); mediaRegistry->ndisks =3D n; for (i =3D 0; i < mediaRegistry->ndisks; i++) { mediaRegistry->disks[i] =3D virVBoxSnapshotConfCreateVBoxSnapshotC= onfHardDiskPtr(nodes[i], @@ -154,8 +153,9 @@ virVBoxSnapshotConfRetrieveMediaRegistry(xmlNodePtr med= iaRegistryNode, xPathContext, &nodes); if (n < 0) goto cleanup; - if (n && VIR_ALLOC_N(mediaRegistry->otherMedia, n) < 0) - goto cleanup; + if (n) + mediaRegistry->otherMedia =3D g_new0(char *, n); + mediaRegistry->notherMedia =3D n; for (i =3D 0; i < mediaRegistry->notherMedia; i++) { mediaRegistry->otherMedia[i] =3D virXMLNodeToString(mediaRegistryN= ode->doc, @@ -190,8 +190,7 @@ virVBoxSnapshotConfRetrieveSnapshot(xmlNodePtr snapshot= Node, int result =3D -1; int n =3D 0; =20 - if (VIR_ALLOC(snapshot) < 0) - goto cleanup; + snapshot =3D g_new0(virVBoxSnapshotConfSnapshot, 1); =20 uuid =3D virXMLPropString(snapshotNode, "uuid"); /* we use virStringSearch because the uuid is between brackets */ @@ -248,8 +247,8 @@ virVBoxSnapshotConfRetrieveSnapshot(xmlNodePtr snapshot= Node, n =3D virXPathNodeSet("./vbox:Snapshot", xPathContext, &nodes); if (n < 0) goto cleanup; - if (n && VIR_ALLOC_N(snapshot->children, n) < 0) - goto cleanup; + if (n) + snapshot->children =3D g_new0(virVBoxSnapshotConfSnapshotPtr, = n); snapshot->nchildren =3D n; for (i =3D 0; i < snapshot->nchildren; i++) { snapshot->children[i] =3D virVBoxSnapshotConfRetrieveSnapshot(= nodes[i], xPathContext); @@ -469,8 +468,7 @@ virVBoxSnapshotConfAllChildren(virVBoxSnapshotConfHardD= iskPtr disk, size_t i =3D 0; size_t j =3D 0; =20 - if (VIR_ALLOC_N(ret, 0) < 0) - return 0; + ret =3D g_new0(virVBoxSnapshotConfHardDiskPtr, 0); =20 for (i =3D 0; i < disk->nchildren; i++) { tempSize =3D virVBoxSnapshotConfAllChildren(disk->children[i], &te= mpList); @@ -601,8 +599,7 @@ virVBoxSnapshotConfLoadVboxFile(const char *filePath, goto cleanup; } =20 - if (VIR_ALLOC(machineDescription) < 0) - goto cleanup; + machineDescription =3D g_new0(virVBoxSnapshotConfMachine, 1); =20 xml =3D virXMLParse(filePath, NULL, NULL); if (xml =3D=3D NULL) { @@ -1283,8 +1280,7 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(cons= t char *filePath, xPathContext, &nodes)) < 0) goto cleanup; =20 - if (VIR_ALLOC_N(ret, nodeSize) < 0) - goto cleanup; + ret =3D g_new0(char *, nodeSize); =20 for (i =3D 0; i < nodeSize; i++) { xmlNodePtr node =3D nodes[i]; @@ -1346,8 +1342,7 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(cons= t char *filePath, xPathContext, &nodes)) < 0) goto cleanup; - if (VIR_ALLOC_N(ret, nodeSize) < 0) - goto cleanup; + ret =3D g_new0(char *, nodeSize); =20 for (i =3D 0; i < nodeSize; i++) { xmlNodePtr node =3D nodes[i]; @@ -1414,8 +1409,7 @@ virVBoxSnapshotConfDiskListToOpen(virVBoxSnapshotConf= MachinePtr machine, } if (hardDisk =3D=3D NULL) return 0; - if (VIR_ALLOC_N(ret, 1) < 0) - return 0; + ret =3D g_new0(virVBoxSnapshotConfHardDiskPtr, 1); =20 returnSize =3D 1; ret[returnSize - 1] =3D hardDisk; @@ -1446,8 +1440,7 @@ virVBoxSnapshotConfRemoveFakeDisks(virVBoxSnapshotCon= fMachinePtr machine) virVBoxSnapshotConfHardDiskPtr *tempList =3D NULL; virVBoxSnapshotConfHardDiskPtr *diskList =3D NULL; =20 - if (VIR_ALLOC_N(diskList, 0) < 0) - return -1; + diskList =3D g_new0(virVBoxSnapshotConfHardDiskPtr, 0); =20 for (i =3D 0; i < machine->mediaRegistry->ndisks; i++) { tempSize =3D virVBoxSnapshotConfAllChildren(machine->mediaRegistry= ->disks[i], &tempList); @@ -1498,8 +1491,7 @@ virVBoxSnapshotConfDiskIsInMediaRegistry(virVBoxSnaps= hotConfMachinePtr machine, virVBoxSnapshotConfHardDiskPtr *tempList =3D NULL; virVBoxSnapshotConfHardDiskPtr *diskList =3D NULL; =20 - if (VIR_ALLOC_N(diskList, 0) < 0) - return -1; + diskList =3D g_new0(virVBoxSnapshotConfHardDiskPtr, 0); =20 for (i =3D 0; i < machine->mediaRegistry->ndisks; i++) { tempSize =3D virVBoxSnapshotConfAllChildren(machine->mediaRegistry= ->disks[i], &tempList); --=20 2.26.2