From nobody Sun May 5 22:43:59 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=1601920127; cv=none; d=zohomail.com; s=zohoarc; b=L2Hlnx05Is24Ki5I4AByRTggVpNAxbvb657yu91OGqGL5+z48X1Pds9lne/ltT38w0a8swKiPIqthzM1+ScTQ2BJbKd0ETn9ukH3WTk2RCwgCr0DTfCdBllyKc9FvTkgUOGH5mnjtXokto2naE1I2EgJ5vau0aW3cVzfVENUcJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920127; 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=17kfacYTlT2PJo6vYZea+iKoubNtJuUwG38uBIFB8A8=; b=A9FepJZtgPWLQKf2eEAIgREyBXTNEMU98+CR3nTDMvcN6sGHzeJTkqagQ/2+X2NldsaJ0oV73wjT4ZPxBDcNcyrBKj22h1I+DjXznpmHhgaroFpz9bpEf2GM4E287fqS+mdmG1SkSgX4xkAmeNesqopNMzzYprxXtld4OpMPFps= 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 1601920127631723.760224963659; Mon, 5 Oct 2020 10:48:47 -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-491-IX0ZjhzBONCL_tHv-UEehA-1; Mon, 05 Oct 2020 13:48:44 -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 1B6B29CC2D; Mon, 5 Oct 2020 17:48:38 +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 E166E5D9D2; Mon, 5 Oct 2020 17:48:37 +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 CE64B44A66; Mon, 5 Oct 2020 17:48:35 +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 095HmYEL015579 for ; Mon, 5 Oct 2020 13:48:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 949CC5C22E; Mon, 5 Oct 2020 17:48:34 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 196415C225 for ; Mon, 5 Oct 2020 17:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920126; 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=17kfacYTlT2PJo6vYZea+iKoubNtJuUwG38uBIFB8A8=; b=eeg8bqJk5EPS1n2C9s+ZLzDW5d3B79iZ9+dGkdUmnsZ45xaVFwOJUDBdUSmt2gseKiqIGc wBKsHaCepdu4kgFyOO2jEGk4qIO2NV1ciyEAk/OHRglVEMtURIyG/TwgrvstaFH+9icABn pUeTA5iMxKnyEoIL8EtHXTJ3DXju+j4= X-MC-Unique: IX0ZjhzBONCL_tHv-UEehA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 01/12] util: resctrl fix spacing in comment Date: Mon, 5 Oct 2020 19:48:16 +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.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) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/util/virresctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index aea3fe8687..2535627d63 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1879,7 +1879,7 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info) } } =20 - /* set default free memory bandwidth to 100%*/ + /* set default free memory bandwidth to 100% */ if (info->membw_info) { if (VIR_ALLOC(ret->mem_bw) < 0) goto error; --=20 2.26.2 From nobody Sun May 5 22:43:59 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=1601920127; cv=none; d=zohomail.com; s=zohoarc; b=UpJrMIEoRJwqWHlveqBIJrIsuwtnyC4oRcR0n4fIIuCj/ixJpMzXWD3mIqSVVE/i7/QAiS5lj7Cb72l9Bp8jc61ZYXU80s+jJ+DqkZXJh4wRZA2KP7UWprjoN9niZdb2G3sH3SJyVCNB0fxhFJ2/Zl68n88/kdgFWFFtIsBumS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920127; 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=Mxk6Rrb4i3heViZ1h42KZ5ADHU8twdn8w1ddoE0tCww=; b=k6Ct9nuzlWALF6Je/F9w0l0R7ND6GqqMBzTi6qhfpC1zMc4G2yQ/I0Oy4m7GhOud1cEOi6Aie6+shUTEb6TQsBkFddgQjaG9XwR+O3vgYEtPTey8oWRrdm6jr1HPs/V0W62HhuzgKsFF8srRKo4JyQk6lD5mjuS1m+OOUMtTtFM= 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 1601920127250750.5494780738155; Mon, 5 Oct 2020 10:48:47 -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-446-SqTwGVqiNmusgDlstPEnjA-1; Mon, 05 Oct 2020 13:48:43 -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 1771C108598B; Mon, 5 Oct 2020 17:48:38 +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 E9C7B7368A; Mon, 5 Oct 2020 17:48:37 +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 EAFD944A67; Mon, 5 Oct 2020 17:48:36 +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 095HmZdU015586 for ; Mon, 5 Oct 2020 13:48:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 647875C1C4; Mon, 5 Oct 2020 17:48:35 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE1935C225 for ; Mon, 5 Oct 2020 17:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920125; 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=Mxk6Rrb4i3heViZ1h42KZ5ADHU8twdn8w1ddoE0tCww=; b=HVpC/0drXP9JLZr1rPlxtspLBETyGX29jbcfCWUsjT+rfklpjnzkkzxykSGTV32i5VRFyG kJeI8tZMZ1JVVMTjXAWUgLZIvzyuLQyu6Ocq4CL3msEcbLfFiUXw1QshjMHiKarwgZuCod NGAXIP0Cr3+E4MPMc/VhBWGPG72zoTw= X-MC-Unique: SqTwGVqiNmusgDlstPEnjA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 02/12] util: split out VIR_ALLOC calls Date: Mon, 5 Oct 2020 19:48:17 +0200 Message-Id: <4ecff66bb23ce0671171d4af05ce386c8cc713ba.1601920046.git.jtomko@redhat.com> 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) To make the following commits simpler. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/util/vircommand.c | 6 ++++-- src/util/virxml.c | 10 ++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 859d6b0ce5..8060cdfada 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -2636,8 +2636,10 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid) VIR_FORCE_CLOSE(cmd->infd); /* clear any error so we can catch if the helper thread reports on= e */ cmd->has_error =3D 0; - if (VIR_ALLOC(cmd->asyncioThread) < 0 || - virThreadCreateFull(cmd->asyncioThread, true, + if (VIR_ALLOC(cmd->asyncioThread) < 0) + ret =3D -1; + + if (virThreadCreateFull(cmd->asyncioThread, true, virCommandDoAsyncIOHelper, "cmd-async-io", false, cmd) < 0) { virReportSystemError(errno, "%s", diff --git a/src/util/virxml.c b/src/util/virxml.c index 5315d4ff6f..1927ff490f 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -672,12 +672,10 @@ virXPathNodeSet(const char *xpath, =20 ret =3D obj->nodesetval->nodeNr; if (list !=3D NULL && ret) { - if (VIR_ALLOC_N(*list, ret) < 0) { - ret =3D -1; - } else { - memcpy(*list, obj->nodesetval->nodeTab, - ret * sizeof(xmlNodePtr)); - } + if (VIR_ALLOC_N(*list, ret) < 0) + return -1; + + memcpy(*list, obj->nodesetval->nodeTab, ret * sizeof(xmlNodePtr)); } xmlXPathFreeObject(obj); return ret; --=20 2.26.2 From nobody Sun May 5 22:43:59 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=1601920142; cv=none; d=zohomail.com; s=zohoarc; b=nqko2TURaCCKM+Cn4OAU5hFIdnpaX70Sf7JBaAJ2Fy86OlCryCLwat0KT3xqZxDNbaMj9f795qcwcAj0hpUNoff6eCHmxKrdIPQfbIV2ES7qKzsAwf5+/jrGSdYXGkTQyyM4qjMQPd5tiLeKmXaqS+QOAV0Q9Yx2KgBos4+GSfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920142; 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=BexZ7FYZ978og8URu5wx2rPUCWF1k5HJfN2D8enIrCY=; b=CPGIS2FUHj3Q5vY3Av/SpJ3+y3fnwCC6IEsWH9Edhbx0epkDikVwPUH5o+mlGHy47IiGQy11jKqin0HHIfbl3NLWn793fz5Xuqr8E95fiBtUX5jHrRCfSSNungdVY5VnFZwIlzJvL8Nkv8RLTpNit+mOpNWMQWHKN0+FGYkGCQw= 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 1601920142356441.9677269985939; Mon, 5 Oct 2020 10:49:02 -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-572-JY8QvMiSMrO3CC6fxQcRig-1; Mon, 05 Oct 2020 13:48:53 -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 87CA118C89D7; Mon, 5 Oct 2020 17:48:45 +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 596AC7514B; Mon, 5 Oct 2020 17:48:45 +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 20CA444A6D; Mon, 5 Oct 2020 17:48:45 +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 095HmaNa015598 for ; Mon, 5 Oct 2020 13:48:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 35A8C5C22E; Mon, 5 Oct 2020 17:48:36 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1D4D5C225 for ; Mon, 5 Oct 2020 17:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920141; 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=BexZ7FYZ978og8URu5wx2rPUCWF1k5HJfN2D8enIrCY=; b=FOdQS3N0RPxSF/bg0JS1x8PRPOI0MlI4bELSUoFim/UyTZcNI6rsVGYEFcxE7zc/+mk3Zx dGkr3iPgAYsTeYmW5DhM2Kff3vWmSNLLriALsg7nPvgCOAKUXgJxtBDpPgDYhLH3aHmgPS voRuX/K0jptT20lKezjQBJyLiseGq84= X-MC-Unique: JY8QvMiSMrO3CC6fxQcRig-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 03/12] util: resctrl: use g_new0 Date: Mon, 5 Oct 2020 19:48:18 +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.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) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/util/virresctrl.c | 77 ++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 52 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 2535627d63..400c8e9981 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -552,9 +552,7 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl, continue; } =20 - if (VIR_ALLOC(i_type) < 0) - goto cleanup; - + i_type =3D g_new0(virResctrlInfoPerType, 1); i_type->control.scope =3D type; =20 rv =3D virFileReadValueUint(&i_type->control.max_allocation, @@ -617,13 +615,9 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl, if (!resctrl->levels[level]) { virResctrlInfoPerTypePtr *types =3D NULL; =20 - if (VIR_ALLOC_N(types, VIR_CACHE_TYPE_LAST) < 0) - goto cleanup; + types =3D g_new0(virResctrlInfoPerTypePtr, VIR_CACHE_TYPE_LAST= ); =20 - if (VIR_ALLOC(resctrl->levels[level]) < 0) { - VIR_FREE(types); - goto cleanup; - } + resctrl->levels[level] =3D g_new0(virResctrlInfoPerLevel, 1); resctrl->levels[level]->types =3D types; } =20 @@ -654,8 +648,7 @@ virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr resc= trl) virResctrlInfoMemBWPtr i_membw =3D NULL; =20 /* query memory bandwidth allocation info */ - if (VIR_ALLOC(i_membw) < 0) - goto cleanup; + i_membw =3D g_new0(virResctrlInfoMemBW, 1); rv =3D virFileReadValueUint(&i_membw->bandwidth_granularity, SYSFS_RESCTRL_PATH "/info/MB/bandwidth_gran"= ); if (rv =3D=3D -2) { @@ -721,8 +714,7 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl) size_t nfeatures =3D 0; virResctrlInfoMongrpPtr info_monitor =3D NULL; =20 - if (VIR_ALLOC(info_monitor) < 0) - return -1; + info_monitor =3D g_new0(virResctrlInfoMongrp, 1); =20 /* For now, monitor only exists in level 3 cache */ info_monitor->cache_level =3D 3; @@ -947,9 +939,7 @@ virResctrlInfoGetCache(virResctrlInfoPtr resctrl, =20 if (VIR_EXPAND_N(*controls, *ncontrols, 1) < 0) goto error; - if (VIR_ALLOC((*controls)[*ncontrols - 1]) < 0) - goto error; - + (*controls)[*ncontrols - 1] =3D g_new0(virResctrlInfoPerCache, 1); memcpy((*controls)[*ncontrols - 1], &i_type->control, sizeof(i_typ= e->control)); } =20 @@ -1004,8 +994,7 @@ virResctrlInfoGetMonitorPrefix(virResctrlInfoPtr resct= rl, =20 for (i =3D 0; i < VIR_RESCTRL_MONITOR_TYPE_LAST; i++) { if (STREQ(prefix, virResctrlMonitorPrefixTypeToString(i))) { - if (VIR_ALLOC(mon) < 0) - goto cleanup; + mon =3D g_new0(virResctrlInfoMon, 1); mon->type =3D i; break; } @@ -1121,20 +1110,16 @@ virResctrlAllocGetType(virResctrlAllocPtr alloc, if (!alloc->levels[level]) { virResctrlAllocPerTypePtr *types =3D NULL; =20 - if (VIR_ALLOC_N(types, VIR_CACHE_TYPE_LAST) < 0) - return NULL; + types =3D g_new0(virResctrlAllocPerTypePtr, VIR_CACHE_TYPE_LAST); =20 - if (VIR_ALLOC(alloc->levels[level]) < 0) { - VIR_FREE(types); - return NULL; - } + alloc->levels[level] =3D g_new0(virResctrlAllocPerLevel, 1); alloc->levels[level]->types =3D types; } =20 a_level =3D alloc->levels[level]; =20 - if (!a_level->types[type] && VIR_ALLOC(a_level->types[type]) < 0) - return NULL; + if (!a_level->types[type]) + a_level->types[type] =3D g_new0(virResctrlAllocPerType, 1); =20 return a_level->types[type]; } @@ -1181,8 +1166,8 @@ virResctrlAllocUpdateSize(virResctrlAllocPtr alloc, cache - a_type->nsizes + 1) < 0) return -1; =20 - if (!a_type->sizes[cache] && VIR_ALLOC(a_type->sizes[cache]) < 0) - return -1; + if (!a_type->sizes[cache]) + a_type->sizes[cache] =3D g_new0(unsigned long long, 1); =20 *(a_type->sizes[cache]) =3D size; =20 @@ -1332,8 +1317,7 @@ virResctrlAllocSetMemoryBandwidth(virResctrlAllocPtr = alloc, } =20 if (!mem_bw) { - if (VIR_ALLOC(mem_bw) < 0) - return -1; + mem_bw =3D g_new0(virResctrlAllocMemBW, 1); alloc->mem_bw =3D mem_bw; } =20 @@ -1349,9 +1333,7 @@ virResctrlAllocSetMemoryBandwidth(virResctrlAllocPtr = alloc, return -1; } =20 - if (VIR_ALLOC(mem_bw->bandwidths[id]) < 0) - return -1; - + mem_bw->bandwidths[id] =3D g_new0(unsigned int, 1); *(mem_bw->bandwidths[id]) =3D memory_bandwidth; return 0; } @@ -1497,10 +1479,8 @@ virResctrlAllocParseProcessMemoryBandwidth(virResctr= lInfoPtr resctrl, id - alloc->mem_bw->nbandwidths + 1) < 0) { return -1; } - if (!alloc->mem_bw->bandwidths[id]) { - if (VIR_ALLOC(alloc->mem_bw->bandwidths[id]) < 0) - return -1; - } + if (!alloc->mem_bw->bandwidths[id]) + alloc->mem_bw->bandwidths[id] =3D g_new0(unsigned int, 1); =20 *(alloc->mem_bw->bandwidths[id]) =3D bandwidth; return 0; @@ -1536,10 +1516,8 @@ virResctrlAllocParseMemoryBandwidthLine(virResctrlIn= foPtr resctrl, return -1; } =20 - if (!alloc->mem_bw) { - if (VIR_ALLOC(alloc->mem_bw) < 0) - return -1; - } + if (!alloc->mem_bw) + alloc->mem_bw =3D g_new0(virResctrlAllocMemBW, 1); =20 tmp =3D strchr(line, ':'); if (!tmp) @@ -1881,16 +1859,14 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info) =20 /* set default free memory bandwidth to 100% */ if (info->membw_info) { - if (VIR_ALLOC(ret->mem_bw) < 0) - goto error; + ret->mem_bw =3D g_new0(virResctrlAllocMemBW, 1); =20 if (VIR_EXPAND_N(ret->mem_bw->bandwidths, ret->mem_bw->nbandwidths, info->membw_info->max_id + 1) < 0) goto error; =20 for (i =3D 0; i < ret->mem_bw->nbandwidths; i++) { - if (VIR_ALLOC(ret->mem_bw->bandwidths[i]) < 0) - goto error; + ret->mem_bw->bandwidths[i] =3D g_new0(unsigned int, 1); *(ret->mem_bw->bandwidths[i]) =3D 100; } } @@ -2171,9 +2147,8 @@ virResctrlAllocCopyMemBW(virResctrlAllocPtr dst, if (!src->mem_bw) return 0; =20 - if (!dst->mem_bw && - VIR_ALLOC(dst->mem_bw) < 0) - return -1; + if (!dst->mem_bw) + dst->mem_bw =3D g_new0(virResctrlAllocMemBW, 1); =20 dst_bw =3D dst->mem_bw; =20 @@ -2185,8 +2160,7 @@ virResctrlAllocCopyMemBW(virResctrlAllocPtr dst, for (i =3D 0; i < src_bw->nbandwidths; i++) { if (dst_bw->bandwidths[i]) continue; - if (VIR_ALLOC(dst_bw->bandwidths[i]) < 0) - return -1; + dst_bw->bandwidths[i] =3D g_new0(unsigned int, 1); *dst_bw->bandwidths[i] =3D *src_bw->bandwidths[i]; } =20 @@ -2736,8 +2710,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monito= r, if (!(node_id =3D STRSKIP(node_id, "_"))) continue; =20 - if (VIR_ALLOC(stat) < 0) - goto cleanup; + stat =3D g_new0(virResctrlMonitorStats, 1); =20 /* The node ID number should be here, parsing it. */ if (virStrToLong_uip(node_id, NULL, 0, &stat->id) < 0) --=20 2.26.2 From nobody Sun May 5 22:43:59 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=1601920137; cv=none; d=zohomail.com; s=zohoarc; b=HUYZSqot/r0oeRerYM2Urew0A7p+ZpKUK7qFVjqLp9nNKw9tBjg7SzkXg0yPb2qrz/wrkcqdkSqCRiI0o3FC0jNBefGJnHk1dNmZkGisHIq3TPvfYAo0l7cSijYBV14xuyN6BjYWjBO/vjBqkvHl7oRPzlvuIiYMGybFAwrxQpQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920137; 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=x6LpRuPI13I0yCjBYoj/3lYBrb4xiESdfqha/MHXMaM=; b=CqDjz1AG/K1eqT8B5Ldbei1WdG45fm3Zl9KrZ8YK3b6xSz79hlCKkQsGZYiRKr1WTrxjp93ZjOEHunDCss4IpMYmY7z+OfUQUkrOZbDeXAQtXc96YPiPz6K7Cq81DrQWEeBGRVHY1EIJLEBN/INHtZvMeQnQWmvn1Sr4JFRcprk= 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 1601920137452268.7610554339034; Mon, 5 Oct 2020 10:48:57 -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-251-26kRMbV6O6ec0aCWd7gQng-1; Mon, 05 Oct 2020 13:48:51 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 687D8803F49; Mon, 5 Oct 2020 17:48:45 +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 43E321002C11; Mon, 5 Oct 2020 17:48:45 +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 11E9B44A6E; Mon, 5 Oct 2020 17:48:45 +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 095HmbgH015603 for ; Mon, 5 Oct 2020 13:48:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 07EB45C230; Mon, 5 Oct 2020 17:48:37 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83B545C225 for ; Mon, 5 Oct 2020 17:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920134; 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=x6LpRuPI13I0yCjBYoj/3lYBrb4xiESdfqha/MHXMaM=; b=YalL1/ih5beKgEg9kNGIagT6yKPa/gK2/ryGsrc2Rw4lqwc0ov7lBEWxOIY9RMJlNb31ru BCRtVc+6M88HGPc+v5tgynnTjsnh+dk4vLvk9+FwmWZgMKEWghkvLBC2TIMrBcmC9SB5J6 sXyrDT50W6k4v3LomynEoBZdDGajAho= X-MC-Unique: 26kRMbV6O6ec0aCWd7gQng-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 04/12] util: storagefile: use g_new0 Date: Mon, 5 Oct 2020 19:48:19 +0200 Message-Id: <6fa49906dbd515bca5ef9affedaafd4ce92647f0.1601920046.git.jtomko@redhat.com> 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.84 on 10.5.11.22 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/util/virstoragefile.c | 82 ++++++++++++--------------------------- 1 file changed, 25 insertions(+), 57 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 459a7be5e4..82388ae544 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -520,8 +520,7 @@ qcow2GetExtensions(const char *buf, if (!backingFormat) break; =20 - if (VIR_ALLOC_N(tmp, len + 1) < 0) - return -1; + tmp =3D g_new0(char, len + 1); memcpy(tmp, buf + offset, len); tmp[len] =3D '\0'; =20 @@ -575,8 +574,7 @@ qcowXGetBackingStore(char **res, return BACKING_STORE_INVALID; if (offset + size > buf_size || offset + size < offset) return BACKING_STORE_INVALID; - if (VIR_ALLOC_N(*res, size + 1) < 0) - return BACKING_STORE_ERROR; + *res =3D g_new0(char, size + 1); memcpy(*res, buf + offset, size); (*res)[size] =3D '\0'; =20 @@ -598,8 +596,7 @@ vmdk4GetBackingStore(char **res, size_t len; g_autofree char *desc =3D NULL; =20 - if (VIR_ALLOC_N(desc, VIR_STORAGE_MAX_HEADER) < 0) - return BACKING_STORE_ERROR; + desc =3D g_new0(char, VIR_STORAGE_MAX_HEADER); =20 *res =3D NULL; /* @@ -669,8 +666,7 @@ qedGetBackingStore(char **res, return BACKING_STORE_OK; if (offset + size > buf_size || offset + size < offset) return BACKING_STORE_INVALID; - if (VIR_ALLOC_N(*res, size + 1) < 0) - return BACKING_STORE_ERROR; + *res =3D g_new0(char, size + 1); memcpy(*res, buf + offset, size); (*res)[size] =3D '\0'; =20 @@ -959,9 +955,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr m= eta, buf, len)) { int expt_fmt =3D fileTypeInfo[meta->format].cryptInfo[i].f= ormat; if (!meta->encryption) { - if (VIR_ALLOC(meta->encryption) < 0) - return -1; - + meta->encryption =3D g_new0(virStorageEncryption, 1); meta->encryption->format =3D expt_fmt; } else { if (meta->encryption->format !=3D expt_fmt) { @@ -1735,8 +1729,7 @@ virStorageNetHostDefCopy(size_t nhosts, virStorageNetHostDefPtr ret =3D NULL; size_t i; =20 - if (VIR_ALLOC_N(ret, nhosts) < 0) - goto error; + ret =3D g_new0(virStorageNetHostDef, nhosts); =20 for (i =3D 0; i < nhosts; i++) { virStorageNetHostDefPtr src =3D &hosts[i]; @@ -1750,10 +1743,6 @@ virStorageNetHostDefCopy(size_t nhosts, } =20 return ret; - - error: - virStorageNetHostDefFree(nhosts, ret); - return NULL; } =20 =20 @@ -1775,8 +1764,7 @@ virStorageAuthDefCopy(const virStorageAuthDef *src) { g_autoptr(virStorageAuthDef) authdef =3D NULL; =20 - if (VIR_ALLOC(authdef) < 0) - return NULL; + authdef =3D g_new0(virStorageAuthDef, 1); =20 authdef->username =3D g_strdup(src->username); /* Not present for storage pool, but used for disk source */ @@ -1801,8 +1789,7 @@ virStorageAuthDefParse(xmlNodePtr node, =20 ctxt->node =3D node; =20 - if (VIR_ALLOC(authdef) < 0) - goto cleanup; + authdef =3D g_new0(virStorageAuthDef, 1); =20 if (!(authdef->username =3D virXPathString("string(./@username)", ctxt= ))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -1891,8 +1878,7 @@ virStoragePRDefParseXML(xmlXPathContextPtr ctxt) g_autofree char *path =3D NULL; g_autofree char *mode =3D NULL; =20 - if (VIR_ALLOC(prd) < 0) - return NULL; + prd =3D g_new0(virStoragePRDef, 1); =20 if (!(managed =3D virXPathString("string(./@managed)", ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -2020,8 +2006,7 @@ virStoragePRDefCopy(virStoragePRDefPtr src) virStoragePRDefPtr copy =3D NULL; virStoragePRDefPtr ret =3D NULL; =20 - if (VIR_ALLOC(copy) < 0) - return NULL; + copy =3D g_new0(virStoragePRDef, 1); =20 copy->managed =3D src->managed; =20 @@ -2129,8 +2114,7 @@ virStorageSourceSeclabelsCopy(virStorageSourcePtr to, if (from->nseclabels =3D=3D 0) return 0; =20 - if (VIR_ALLOC_N(to->seclabels, from->nseclabels) < 0) - return -1; + to->seclabels =3D g_new0(virSecurityDeviceLabelDefPtr, from->nseclabel= s); to->nseclabels =3D from->nseclabels; =20 for (i =3D 0; i < to->nseclabels; i++) { @@ -2280,8 +2264,7 @@ virStorageTimestampsCopy(const virStorageTimestamps *= src) { virStorageTimestampsPtr ret; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virStorageTimestamps, 1); =20 memcpy(ret, src, sizeof(*src)); =20 @@ -2294,8 +2277,7 @@ virStoragePermsCopy(const virStoragePerms *src) { virStoragePermsPtr ret; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virStoragePerms, 1); =20 ret->mode =3D src->mode; ret->uid =3D src->uid; @@ -2312,8 +2294,7 @@ virStorageSourcePoolDefCopy(const virStorageSourcePoo= lDef *src) { virStorageSourcePoolDefPtr ret; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virStorageSourcePoolDef, 1); =20 ret->voltype =3D src->voltype; ret->pooltype =3D src->pooltype; @@ -2806,9 +2787,7 @@ virStorageSourceParseBackingURI(virStorageSourcePtr s= rc, return -1; } =20 - if (VIR_ALLOC(src->hosts) < 0) - return -1; - + src->hosts =3D g_new0(virStorageNetHostDef, 1); src->nhosts =3D 1; =20 if (!(scheme =3D virStringSplit(uri->scheme, "+", 2))) @@ -3001,8 +2980,8 @@ virStorageSourceParseRBDColonString(const char *rbdst= r, _("duplicate 'id' found in '%s'"), src->pat= h); return -1; } - if (VIR_ALLOC(authdef) < 0) - return -1; + + authdef =3D g_new0(virStorageAuthDef, 1); =20 authdef->username =3D g_strdup(p + strlen("id=3D")); =20 @@ -3475,8 +3454,7 @@ virStorageSourceParseBackingJSONGluster(virStorageSou= rcePtr src, return -1; } =20 - if (VIR_ALLOC_N(src->hosts, nservers) < 0) - return -1; + src->hosts =3D g_new0(virStorageNetHostDef, nservers); src->nhosts =3D nservers; =20 for (i =3D 0; i < nservers; i++) { @@ -3513,9 +3491,7 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSourc= ePtr src, if (!lun) lun =3D "0"; =20 - if (VIR_ALLOC(src->hosts) < 0) - return -1; - + src->hosts =3D g_new0(virStorageNetHostDef, 1); src->nhosts =3D 1; =20 if (STRNEQ_NULLABLE(transport, "tcp")) { @@ -3583,8 +3559,7 @@ virStorageSourceParseBackingJSONNbd(virStorageSourceP= tr src, =20 src->path =3D g_strdup(export); =20 - if (VIR_ALLOC_N(src->hosts, 1) < 0) - return -1; + src->hosts =3D g_new0(virStorageNetHostDef, 1); src->nhosts =3D 1; =20 if (server) { @@ -3639,9 +3614,7 @@ virStorageSourceParseBackingJSONSheepdog(virStorageSo= urcePtr src, =20 src->path =3D g_strdup(vdi); =20 - if (VIR_ALLOC(src->hosts) < 0) - return -1; - + src->hosts =3D g_new0(virStorageNetHostDef, 1); src->nhosts =3D 1; =20 if (virStorageSourceParseBackingJSONSocketAddress(src->hosts, server) = < 0) @@ -3676,8 +3649,7 @@ virStorageSourceParseBackingJSONSSH(virStorageSourceP= tr src, =20 src->path =3D g_strdup(path); =20 - if (VIR_ALLOC_N(src->hosts, 1) < 0) - return -1; + src->hosts =3D g_new0(virStorageNetHostDef, 1); src->nhosts =3D 1; =20 if (server) { @@ -3738,9 +3710,7 @@ virStorageSourceParseBackingJSONRBD(virStorageSourceP= tr src, if (servers) { nservers =3D virJSONValueArraySize(servers); =20 - if (VIR_ALLOC_N(src->hosts, nservers) < 0) - return -1; - + src->hosts =3D g_new0(virStorageNetHostDef, nservers); src->nhosts =3D nservers; =20 for (i =3D 0; i < nservers; i++) { @@ -3814,8 +3784,7 @@ virStorageSourceParseBackingJSONVxHS(virStorageSource= Ptr src, =20 src->path =3D g_strdup(vdisk_id); =20 - if (VIR_ALLOC_N(src->hosts, 1) < 0) - return -1; + src->hosts =3D g_new0(virStorageNetHostDef, 1); src->nhosts =3D 1; =20 if (virStorageSourceParseBackingJSONInetSocketAddress(src->hosts, @@ -4887,8 +4856,7 @@ virStorageFileInitAs(virStorageSourcePtr src, uid_t uid, gid_t gid) { int actualType =3D virStorageSourceGetActualType(src); - if (VIR_ALLOC(src->drv) < 0) - return -1; + src->drv =3D g_new0(virStorageDriverData, 1); =20 if (uid =3D=3D (uid_t) -1) src->drv->uid =3D geteuid(); --=20 2.26.2 From nobody Sun May 5 22:43:59 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=1601920138; cv=none; d=zohomail.com; s=zohoarc; b=GFX/E5f7/iTK/X1tEUJfWVxF9ugiIUdYJc0xdWJfewbS+5EHfbeiTcNCYN4lZo8wkuYD7+PmJwTk1IzcQz4d2IiaFr2XdxVeca8WbMOR8GYn/AEW6khj+4fM5FumEGrNwLt4CgssEWXgJRnEmw09l0RExOQhzBzher4HP9fFggg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920138; 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=Okz8TgoyjCh4LIAL9wKWsdDZaMEg81wEckZFhceXcAI=; b=V2R66v7hYLWS8ao5LFYyp4wiJ6hracfodWnLuh8R/P04GWDfrO/IUamVZSNXxtaCzfrYaSzCf87VdzAAvBczlExPiK8GfoPU5es5usJHvrSdRo7VZJuTvvOXjewviu3Nol30IHqdqIEz59TBzcbOAdxaIRGzv8rRqgTIlg/dj0Y= 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 1601920138486781.8336823032423; Mon, 5 Oct 2020 10:48:58 -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-509-QXgv7qLjNAum9BrI7gvthQ-1; Mon, 05 Oct 2020 13:48:54 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2F1DBAE851; Mon, 5 Oct 2020 17:48:48 +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 0C6AC1002EF9; Mon, 5 Oct 2020 17:48: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 CD7C71826D32; Mon, 5 Oct 2020 17:48:47 +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 095Hmb7Y015613 for ; Mon, 5 Oct 2020 13:48:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id D09845C5AF; Mon, 5 Oct 2020 17:48:37 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 550465C225 for ; Mon, 5 Oct 2020 17:48:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920137; 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=Okz8TgoyjCh4LIAL9wKWsdDZaMEg81wEckZFhceXcAI=; b=C36gjTxoiqh+rOB55EQgObfxiKaXUV6UOYRm0iKWsjE5BC0yLYinVCDEJxDGHOwfV4bapQ BupUaVXwZ3hw/aPJmLvlJbvx26Y4jtfIa4eDX+1rLPsJMPtGjdPzFzZFVvJvqTxeq9lD1D q1Hf+tmxepeq4wIxVnEs85gCKPMP2NA= X-MC-Unique: QXgv7qLjNAum9BrI7gvthQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 05/12] util: sysinfo: use g_new0 Date: Mon, 5 Oct 2020 19:48:20 +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.84 on 10.5.11.22 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/util/virsysinfo.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 0e9b281caf..217f842a37 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -225,8 +225,7 @@ virSysinfoParsePPCSystem(const char *base, virSysinfoSy= stemDefPtr *sysdef) if ((cur =3D strstr(base, "platform")) =3D=3D NULL) return 0; =20 - if (VIR_ALLOC(def) < 0) - return ret; + def =3D g_new0(virSysinfoSystemDef, 1); =20 base =3D cur; /* Account for format 'platform : XXXX'*/ @@ -318,8 +317,7 @@ virSysinfoReadPPC(void) g_auto(virSysinfoDefPtr) ret =3D NULL; g_autofree char *outbuf =3D NULL; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virSysinfoDef, 1); =20 if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -350,8 +348,7 @@ virSysinfoParseARMSystem(const char *base, virSysinfoSy= stemDefPtr *sysdef) if ((cur =3D strstr(base, "platform")) =3D=3D NULL) return 0; =20 - if (VIR_ALLOC(def) < 0) - return ret; + def =3D g_new0(virSysinfoSystemDef, 1); =20 base =3D cur; /* Account for format 'platform : XXXX'*/ @@ -453,8 +450,7 @@ virSysinfoReadARM(void) /* Well, we've tried. Fall back to parsing cpuinfo */ virResetLastError(); =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virSysinfoDef, 1); =20 if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -507,8 +503,7 @@ virSysinfoParseS390System(const char *base, virSysinfoS= ystemDefPtr *sysdef) int ret =3D -1; virSysinfoSystemDefPtr def; =20 - if (VIR_ALLOC(def) < 0) - return ret; + def =3D g_new0(virSysinfoSystemDef, 1); =20 if (!virSysinfoParseS390Line(base, "Manufacturer", &def->manufacturer)) goto cleanup; @@ -612,8 +607,7 @@ virSysinfoReadS390(void) g_auto(virSysinfoDefPtr) ret =3D NULL; g_autofree char *outbuf =3D NULL; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virSysinfoDef, 1); =20 /* Gather info from /proc/cpuinfo */ if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) { @@ -653,8 +647,7 @@ virSysinfoParseBIOS(const char *base, virSysinfoBIOSDef= Ptr *bios) if ((cur =3D strstr(base, "BIOS Information")) =3D=3D NULL) return 0; =20 - if (VIR_ALLOC(def) < 0) - return ret; + def =3D g_new0(virSysinfoBIOSDef, 1); =20 base =3D cur; if ((cur =3D strstr(base, "Vendor: ")) !=3D NULL) { @@ -710,8 +703,7 @@ virSysinfoParseX86System(const char *base, virSysinfoSy= stemDefPtr *sysdef) if ((cur =3D strstr(base, "System Information")) =3D=3D NULL) return 0; =20 - if (VIR_ALLOC(def) < 0) - return ret; + def =3D g_new0(virSysinfoSystemDef, 1); =20 base =3D cur; if ((cur =3D strstr(base, "Manufacturer: ")) !=3D NULL) { @@ -877,8 +869,7 @@ virSysinfoParseX86Chassis(const char *base, if ((cur =3D strstr(base, "Chassis Information")) =3D=3D NULL) return 0; =20 - if (VIR_ALLOC(def) < 0) - return ret; + def =3D g_new0(virSysinfoChassisDef, 1); =20 base =3D cur; if ((cur =3D strstr(base, "Manufacturer: ")) !=3D NULL) { @@ -968,8 +959,7 @@ virSysinfoParseOEMStrings(const char *base, if (!(cur =3D strstr(base, "OEM Strings"))) return 0; =20 - if (VIR_ALLOC(strings) < 0) - return -1; + strings =3D g_new0(virSysinfoOEMStringsDef, 1); =20 while ((cur =3D strstr(cur, "String "))) { char *eol; @@ -1237,8 +1227,7 @@ virSysinfoReadDMI(void) if (virCommandRun(cmd, NULL) < 0) return NULL; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virSysinfoDef, 1); =20 ret->type =3D VIR_SYSINFO_SMBIOS; =20 --=20 2.26.2 From nobody Sun May 5 22:43:59 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=1601920141; cv=none; d=zohomail.com; s=zohoarc; b=TLgE3Rhx4jKrt7mIe/RSVwaOwFTV7ZwgKsWeJOABqmE3jDF9LbHEKNRfaSoQ3YuclZLb1YzFwCi5hVLjrGVdkWmEO1RE2KqAXeKgyFvebvHHIb8XHD6FyKsQLYGAkhOM9yOhSR6uiOVixMmaUPC7WiahjUlLss6FzqaWUYZXyQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920141; 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=6yxbEVmKLM4wYcgzaOPY0/3A5jkxwDhsyo+qzT4hlyM=; b=nPgWZUFPqRrhhdpenD0/F1IGoB2arxBp/RSTkx9UC5eIJhLWsUluowQmQJLN+k8A60IDwNW84yCPqmDskPZFXdonDa1+hyeuUMV9ghID7YD9kXKvKsSk3afOrJUsFaymC5eCIKZeehW3hikCuNm60S3dJAJ/CbTAFyzjTZMu0CA= 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 1601920141357292.89871800365484; Mon, 5 Oct 2020 10:49:01 -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-339-i9jKevo8N_OU931NF2gfVw-1; Mon, 05 Oct 2020 13:48:57 -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 718B6AE830; Mon, 5 Oct 2020 17:48:50 +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 5162078819; Mon, 5 Oct 2020 17:48:50 +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 03B701826D37; Mon, 5 Oct 2020 17:48:50 +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 095HmcM4015619 for ; Mon, 5 Oct 2020 13:48:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id A12DA5C1C4; Mon, 5 Oct 2020 17:48:38 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 28C9B5C1BD for ; Mon, 5 Oct 2020 17:48:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920140; 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=6yxbEVmKLM4wYcgzaOPY0/3A5jkxwDhsyo+qzT4hlyM=; b=ZHdFUGp6VzpeMRVCdY7wv7izHGw1uQvtdYkcb9raXg/STLb7F1wwT9LRfBSueyd0WwjLac TGfIucTvh6I32hyuVJIxBgE4k6eoljlhWhXxTFNwbh247jpH1u/STMU+Tr4lAHKPZZ2MM9 My7ZqEe1OIoQtrvuYGogxMYdXuPzIHs= X-MC-Unique: i9jKevo8N_OU931NF2gfVw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 06/12] util: command: use g_new0 Date: Mon, 5 Oct 2020 19:48:21 +0200 Message-Id: <002d196be41994c477ca47716c3d94a5ebd4bd08.1601920046.git.jtomko@redhat.com> 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.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) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/util/vircommand.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 8060cdfada..6350e77523 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -935,8 +935,7 @@ virCommandNewArgs(const char *const*args) { virCommandPtr cmd; =20 - if (VIR_ALLOC(cmd) < 0) - return NULL; + cmd =3D g_new0(virCommand, 1); =20 cmd->handshakeWait[0] =3D -1; cmd->handshakeWait[1] =3D -1; @@ -2183,21 +2182,18 @@ virCommandProcessIO(virCommandPtr cmd) if (cmd->outbuf) { outfd =3D cmd->outfd; VIR_FREE(*cmd->outbuf); - if (VIR_ALLOC_N(*cmd->outbuf, 1) < 0) - ret =3D -1; + *cmd->outbuf =3D g_new0(char, 1); } if (cmd->errbuf) { errfd =3D cmd->errfd; VIR_FREE(*cmd->errbuf); - if (VIR_ALLOC_N(*cmd->errbuf, 1) < 0) - ret =3D -1; + *cmd->errbuf =3D g_new0(char, 1); } if (ret =3D=3D -1) goto cleanup; ret =3D -1; =20 - if (VIR_ALLOC_N(fds, 3 + virCommandGetNumSendBuffers(cmd)) < 0) - goto cleanup; + fds =3D g_new0(struct pollfd, 3 + virCommandGetNumSendBuffers(cmd)); =20 for (;;) { size_t i; @@ -2636,8 +2632,7 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid) VIR_FORCE_CLOSE(cmd->infd); /* clear any error so we can catch if the helper thread reports on= e */ cmd->has_error =3D 0; - if (VIR_ALLOC(cmd->asyncioThread) < 0) - ret =3D -1; + cmd->asyncioThread =3D g_new0(virThread, 1); =20 if (virThreadCreateFull(cmd->asyncioThread, true, virCommandDoAsyncIOHelper, @@ -2854,10 +2849,7 @@ int virCommandHandshakeWait(virCommandPtr cmd) if (c !=3D '1') { g_autofree char *msg =3D NULL; ssize_t len; - if (VIR_ALLOC_N(msg, 1024) < 0) { - VIR_FORCE_CLOSE(cmd->handshakeWait[0]); - return -1; - } + msg =3D g_new0(char, 1024); /* Close the handshakeNotify fd before trying to read anything * further on the handshakeWait pipe; so that a child waiting * on our acknowledgment will die rather than deadlock. */ @@ -3193,8 +3185,7 @@ virCommandRunRegex(virCommandPtr cmd, int ret =3D -1; =20 /* Compile all regular expressions */ - if (VIR_ALLOC_N(reg, nregex) < 0) - return -1; + reg =3D g_new0(GRegex *, nregex); =20 for (i =3D 0; i < nregex; i++) { g_autoptr(GError) err =3D NULL; @@ -3212,8 +3203,7 @@ virCommandRunRegex(virCommandPtr cmd, } =20 /* Storage for matched variables */ - if (VIR_ALLOC_N(groups, totgroups) < 0) - goto cleanup; + groups =3D g_new0(char *, totgroups); =20 virCommandSetOutputBuffer(cmd, &outbuf); if (virCommandRun(cmd, exitstatus) < 0) @@ -3299,8 +3289,7 @@ virCommandRunNul(virCommandPtr cmd, if (n_columns =3D=3D 0) return -1; =20 - if (VIR_ALLOC_N(v, n_columns) < 0) - return -1; + v =3D g_new0(char *, n_columns); for (i =3D 0; i < n_columns; i++) v[i] =3D NULL; =20 --=20 2.26.2 From nobody Sun May 5 22:43:59 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=1601920143; cv=none; d=zohomail.com; s=zohoarc; b=SRxbAH2zEXQkKzMQ/t9V7xAjebp/GO7Ay8bzhR8hmQKA5+QOEtyly9fcDyaDRrC0GGAnfj24vPBz4dvSBAjDI/4KjCjpotnp1pBC2JQkeNRBi0jwo7X0PyaOr8SqzUq2AmP+XVT9UrXYtYugFezOh4kggcr0M9BxdZ72vBYJfeM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920143; 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=7Dc4OdVBt3RZU+smYP25PqHKOfU22IbMwsRChfggwqI=; b=j6r5FPbblYrV5u2SndE4eyfssp9q2MNFtksR9uGoMMxEOLJHvu2fJAPsiTrXmsQ55uRcozeBiJbWXsBn2NklWSIcpiik9SyGLX6RWCizZ8xkS1y2AiYOghmeEhHrsWaG6/w0s7GOtGMgLVEawuxM+CHVVOrrYoHXRkXknzfvES8= 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 1601920143014278.9443691636719; Mon, 5 Oct 2020 10:49:03 -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-543-YUVrly0_MfuW1t78-oFk9A-1; Mon, 05 Oct 2020 13:48:59 -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 DBC5781C478; Mon, 5 Oct 2020 17:48:52 +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 BB00A7368A; Mon, 5 Oct 2020 17:48: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 8856244A73; Mon, 5 Oct 2020 17:48:52 +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 095HmdAn015635 for ; Mon, 5 Oct 2020 13:48:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 73ACA5C1C4; Mon, 5 Oct 2020 17:48:39 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE7E55C225 for ; Mon, 5 Oct 2020 17:48:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920141; 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=7Dc4OdVBt3RZU+smYP25PqHKOfU22IbMwsRChfggwqI=; b=cglNZNDKQei8P5KZbLQpCe2VSYGRrLubHeDLK0h5vSBE5AAK+gv1Tw97cV+53tKn1iI/uk v63BPs+PVIWEkzFCSkPwpXzVJ+OrpB0PiTwzQmJQ3xxydz9I1AU0Yn21iWc0pZEIfLd+7U lzSaMecv1wjU0/1B0n3V482icTU2W6s= X-MC-Unique: YUVrly0_MfuW1t78-oFk9A-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 07/12] util: netdev: use g_new0 Date: Mon, 5 Oct 2020 19:48:22 +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: Erik Skultety --- src/util/virnetdev.c | 25 +++++++++---------------- src/util/virnetdevbandwidth.c | 22 ++++------------------ src/util/virnetdevip.c | 3 +-- src/util/virnetdevmacvlan.c | 6 ++---- src/util/virnetdevtap.c | 3 +-- src/util/virnetdevvlan.c | 4 +--- src/util/virnetdevvportprofile.c | 7 ++----- 7 files changed, 20 insertions(+), 50 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 76aeeba22a..e711a6dc8a 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1209,8 +1209,7 @@ virNetDevGetVirtualFunctions(const char *pfname, n_vfname, max_vfs) < 0) goto cleanup; =20 - if (VIR_ALLOC_N(*vfname, *n_vfname) < 0) - goto cleanup; + *vfname =3D g_new0(char *, *n_vfname); =20 for (i =3D 0; i < *n_vfname; i++) { g_autofree char *pciConfigAddr =3D NULL; @@ -2039,8 +2038,7 @@ virNetDevReadNetConfig(const char *linkdev, int vf, } =20 if (MACStr) { - if (VIR_ALLOC(*MAC) < 0) - goto cleanup; + *MAC =3D g_new0(virMacAddr, 1); =20 if (virMacAddrParse(MACStr, *MAC) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2051,8 +2049,7 @@ virNetDevReadNetConfig(const char *linkdev, int vf, } =20 if (adminMACStr) { - if (VIR_ALLOC(*adminMAC) < 0) - goto cleanup; + *adminMAC =3D g_new0(virMacAddr, 1); =20 if (virMacAddrParse(adminMACStr, *adminMAC) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2064,10 +2061,8 @@ virNetDevReadNetConfig(const char *linkdev, int vf, =20 if (vlanTag !=3D -1) { /* construct a simple virNetDevVlan object with a single tag */ - if (VIR_ALLOC(*vlan) < 0) - goto cleanup; - if (VIR_ALLOC((*vlan)->tag) < 0) - goto cleanup; + *vlan =3D g_new0(virNetDevVlan, 1); + (*vlan)->tag =3D g_new0(unsigned int, 1); (*vlan)->nTags =3D 1; (*vlan)->tag[0] =3D vlanTag; } @@ -2664,8 +2659,8 @@ static int virNetDevGetMcastList(const char *ifname, =20 cur =3D buf; while (cur) { - if (!entry && VIR_ALLOC(entry) < 0) - return -1; + if (!entry) + entry =3D g_new0(virNetDevMcastEntry, 1); =20 next =3D strchr(cur, '\n'); if (next) @@ -2709,8 +2704,7 @@ static int virNetDevGetMulticastTable(const char *ifn= ame, goto cleanup; =20 if (mcast.nentries > 0) { - if (VIR_ALLOC_N(filter->multicast.table, mcast.nentries) < 0) - goto cleanup; + filter->multicast.table =3D g_new0(virMacAddr, mcast.nentries); =20 for (i =3D 0; i < mcast.nentries; i++) { virMacAddrSet(&filter->multicast.table[i], @@ -2733,8 +2727,7 @@ virNetDevRxFilterNew(void) { virNetDevRxFilterPtr filter; =20 - if (VIR_ALLOC(filter) < 0) - return NULL; + filter =3D g_new0(virNetDevRxFilter, 1); return filter; } =20 diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c index 5fd7186760..c8eb5cfc79 100644 --- a/src/util/virnetdevbandwidth.c +++ b/src/util/virnetdevbandwidth.c @@ -442,39 +442,25 @@ int virNetDevBandwidthCopy(virNetDevBandwidthPtr *dest, const virNetDevBandwidth *src) { - int ret =3D -1; - *dest =3D NULL; if (!src) { /* nothing to be copied */ return 0; } =20 - if (VIR_ALLOC(*dest) < 0) - goto cleanup; + *dest =3D g_new0(virNetDevBandwidth, 1); =20 if (src->in) { - if (VIR_ALLOC((*dest)->in) < 0) - goto cleanup; + (*dest)->in =3D g_new0(virNetDevBandwidthRate, 1); memcpy((*dest)->in, src->in, sizeof(*src->in)); } =20 if (src->out) { - if (VIR_ALLOC((*dest)->out) < 0) { - VIR_FREE((*dest)->in); - goto cleanup; - } + (*dest)->out =3D g_new0(virNetDevBandwidthRate, 1); memcpy((*dest)->out, src->out, sizeof(*src->out)); } =20 - ret =3D 0; - - cleanup: - if (ret < 0) { - virNetDevBandwidthFree(*dest); - *dest =3D NULL; - } - return ret; + return 0; } =20 bool diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c index a69567da6f..fc7808cbaa 100644 --- a/src/util/virnetdevip.c +++ b/src/util/virnetdevip.c @@ -180,8 +180,7 @@ virNetDevIPAddrAdd(const char *ifname, if (VIR_SOCKET_ADDR_FAMILY(addr) =3D=3D AF_INET && !(peer && VIR_SOCKET_ADDR_VALID(peer))) { /* compute a broadcast address if this is IPv4 */ - if (VIR_ALLOC(broadcast) < 0) - return -1; + broadcast =3D g_new0(virSocketAddr, 1); =20 if (virSocketAddrBroadcastByPrefix(addr, prefix, broadcast) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index f301a9e96c..72f0d67086 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -726,11 +726,9 @@ virNetDevMacVLanVPortProfileRegisterCallback(const cha= r *ifname, virNetlinkCallbackDataPtr calld =3D NULL; =20 if (virtPortProfile && virNetlinkEventServiceIsRunning(NETLINK_ROUTE))= { - if (VIR_ALLOC(calld) < 0) - goto error; + calld =3D g_new0(struct virNetlinkCallbackData, 1); calld->cr_ifname =3D g_strdup(ifname); - if (VIR_ALLOC(calld->virtPortProfile) < 0) - goto error; + calld->virtPortProfile =3D g_new0(virNetDevVPortProfile, 1); memcpy(calld->virtPortProfile, virtPortProfile, sizeof(*virtPortPr= ofile)); virMacAddrSet(&calld->macaddress, macaddress); calld->linkdev =3D g_strdup(linkdev); diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 1738f48a5f..198607b5bb 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -165,8 +165,7 @@ virNetDevTapGetRealDeviceName(char *ifname G_GNUC_UNUSE= D) return NULL; } =20 - if (VIR_ALLOC_N(ret, len) < 0) - return NULL; + ret =3D g_new0(char, len); =20 if (sysctl(name, 6, ret, &len, 0, 0) < 0) { virReportSystemError(errno, diff --git a/src/util/virnetdevvlan.c b/src/util/virnetdevvlan.c index 2076cc48dc..154d92497c 100644 --- a/src/util/virnetdevvlan.c +++ b/src/util/virnetdevvlan.c @@ -83,9 +83,7 @@ virNetDevVlanCopy(virNetDevVlanPtr dst, const virNetDevVl= an *src) if (!src || src->nTags =3D=3D 0) return 0; =20 - if (VIR_ALLOC_N(dst->tag, src->nTags) < 0) - return -1; - + dst->tag =3D g_new0(unsigned int, src->nTags); dst->trunk =3D src->trunk; dst->nTags =3D src->nTags; dst->nativeMode =3D src->nativeMode; diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprof= ile.c index 5dae8aa57d..5d6c055b32 100644 --- a/src/util/virnetdevvportprofile.c +++ b/src/util/virnetdevvportprofile.c @@ -129,9 +129,7 @@ int virNetDevVPortProfileCopy(virNetDevVPortProfilePtr = *dst, const virNetDevVPor return 0; } =20 - if (VIR_ALLOC(*dst) < 0) - return -1; - + *dst =3D g_new0(virNetDevVPortProfile, 1); memcpy(*dst, src, sizeof(*src)); return 0; } @@ -431,8 +429,7 @@ int virNetDevVPortProfileMerge3(virNetDevVPortProfilePt= r *result, } =20 /* at least one of the source profiles is non-empty */ - if (VIR_ALLOC(*result) < 0) - return ret; + *result =3D g_new0(virNetDevVPortProfile, 1); =20 /* start with the interface's profile. There are no pointers in a * virtualPortProfile, so a shallow copy is sufficient. --=20 2.26.2 From nobody Sun May 5 22:43:59 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=1601920145; cv=none; d=zohomail.com; s=zohoarc; b=IjAnA1t8LEP/m2kmorRy+TE7AwVZSsD7fxGKytgfvRcn+J37A1DT4JwSF7/+J+uy9HogB2FluwwaY2KQThN17DNrZa2/bGBUJZ1oZ2Zq/B+Mr87sHRb8dk7MWEw+cO9G8iDhtcSqHRQf52K0OeLp96pvPmKcHFRP/UDyZctemZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920145; 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=br5IwSvBaDXtSmyQomc+e42Lyp+Whu/seiNCgEVXgI8=; b=f4f0mMy3clSjO7g4QYh7IMb5Pym8hUQ8YfyaofhHA87MRpeDtz+VkVZrR58tEMb+b/Nf1CNN8Pe3G7vTY16f7fjGODToITwgZcP1XvTsA++lGp1nc7abfqVvjXMk3hC0roHs8MkKr2HWdLllENsy9oyK96e1r7CwvnfDPNWHvoM= 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 1601920145367671.4976123345176; Mon, 5 Oct 2020 10:49:05 -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-337-bw2U27hSNhukeX_VffwNKA-1; Mon, 05 Oct 2020 13:49:00 -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 DC34F18C89CB; Mon, 5 Oct 2020 17:48:50 +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 BD44778800; Mon, 5 Oct 2020 17:48:50 +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 8620F44A71; Mon, 5 Oct 2020 17:48:50 +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 095HmeJt015640 for ; Mon, 5 Oct 2020 13:48:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 44A235C225; Mon, 5 Oct 2020 17:48:40 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0E6C5C1C4 for ; Mon, 5 Oct 2020 17:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920144; 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=br5IwSvBaDXtSmyQomc+e42Lyp+Whu/seiNCgEVXgI8=; b=ElZNbV0F7rfR4pix4NMgCym85yIuxOITtdClQtPBcVepJPEzLxyX9dCLDyqoxxoNbYF8N9 Leu8j8+bTVMksyqv2asYIHebPYP4SbqOhv7dyQ7123LDsAkZWCBgXrFMDU/G8rH5Xc0ceZ qBOvx4J2te3YExrWKArr6ru95pEG6L4= X-MC-Unique: bw2U27hSNhukeX_VffwNKA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 08/12] util: systemd: use g_new0 Date: Mon, 5 Oct 2020 19:48:23 +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.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) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/util/virsystemd.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index 8456085476..8373ee6509 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -364,8 +364,7 @@ int virSystemdCreateMachine(const char *name, if (g_atomic_int_get(&hasCreateWithNetwork)) { g_autoptr(virError) error =3D NULL; =20 - if (VIR_ALLOC(error) < 0) - return -1; + error =3D g_new0(virError, 1); =20 guuid =3D g_variant_new_fixed_array(G_VARIANT_TYPE("y"), uuid, 16, sizeof(unsigned char)); @@ -495,8 +494,7 @@ int virSystemdTerminateMachine(const char *name) if (!(conn =3D virGDBusGetSystemBus())) return -1; =20 - if (VIR_ALLOC(error) < 0) - return -1; + error =3D g_new0(virError, 1); =20 /* * The systemd DBus API we're invoking has the @@ -655,14 +653,8 @@ virSystemdActivationAddFD(virSystemdActivationPtr act, virSystemdActivationEntryPtr ent =3D virHashLookup(act->fds, name); =20 if (!ent) { - if (VIR_ALLOC(ent) < 0) - return -1; - - if (VIR_ALLOC_N(ent->fds, 1) < 0) { - virSystemdActivationEntryFree(ent); - return -1; - } - + ent =3D g_new0(virSystemdActivationEntry, 1); + ent->fds =3D g_new0(int, 1); ent->fds[ent->nfds++] =3D fd; =20 VIR_DEBUG("Record first FD %d with name %s", fd, name); @@ -902,8 +894,7 @@ virSystemdActivationNew(virSystemdActivationMap *map, const char *fdnames; =20 VIR_DEBUG("Activated with %d FDs", nfds); - if (VIR_ALLOC(act) < 0) - return NULL; + act =3D g_new0(virSystemdActivation, 1); =20 if (!(act->fds =3D virHashCreate(10, virSystemdActivationEntryFree))) goto error; --=20 2.26.2 From nobody Sun May 5 22:43:59 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=1601920134; cv=none; d=zohomail.com; s=zohoarc; b=Cz1KodD7WxWxnUip5O14IVZ5kHzNxeq/ZkPs55+oAt8haPGTvZIxpC++XsshNkv787cqL26iHClaDXubIHGTQ6wJvGqQlBnfm24vdUhED5AKpN06dZn1OYWxzFqcqzIXbUrmbZRnEiPdYETw47xa2hr31AL+H7GCOoMg22lMJ/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920134; 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=/JIpal2eNq8AjDEi2ORww2ickql3Nf3miOqXC9sBTu8=; b=NEoWWMzyNzev9xxDIXiOOfK3Y6jj7OkTP2NywIoqDW5fROJwimOVz9u8S9F2tZZ6F+kQFvJJJiw0S3QTOhsk83svhT6J9Z1XO9HS4vjiF2vSBQZF1ZvKS7XK0a4LwnDs5YHlabQ3OmsTy5kEdST9ot5tJ+NvYg8VQzYDFAcYEOM= 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 1601920134146933.3396847712422; Mon, 5 Oct 2020 10:48:54 -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-216-2kAQMWj-Np-pfVvoNZdCZQ-1; Mon, 05 Oct 2020 13:48:50 -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 1FF7310866A8; Mon, 5 Oct 2020 17:48:45 +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 F0B0E26344; Mon, 5 Oct 2020 17:48: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 BDE7B1826D2F; Mon, 5 Oct 2020 17:48:44 +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 095HmfIq015653 for ; Mon, 5 Oct 2020 13:48:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1593F5C225; Mon, 5 Oct 2020 17:48:41 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91FC05C1C4 for ; Mon, 5 Oct 2020 17:48:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920132; 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=/JIpal2eNq8AjDEi2ORww2ickql3Nf3miOqXC9sBTu8=; b=WODpQvRnFp0rWksViJY3zMjH/9OM62Gywggp0Sklh1Cl9xTw+jolMuU9Y5HeftEox4laHf 3wYEOAM8kzTRdA0PiBJCksCPDI/7sQ9TfAKcDeX8TRa5kgH713666bZgA3uzIlUTIiOq/y jFj0MPQmXeJTOoUpQZ70etVlrOOV6Bs= X-MC-Unique: 2kAQMWj-Np-pfVvoNZdCZQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 09/12] util: firewall: use g_new0 Date: Mon, 5 Oct 2020 19:48:24 +0200 Message-Id: <0b2d18a62314a074f237e57f4deff098585b27fb.1601920046.git.jtomko@redhat.com> 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.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/util/virfirewall.c | 9 +++------ src/util/virfirewalld.c | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 22e717bce4..f6a8beec95 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -211,8 +211,7 @@ virFirewallGroupNew(void) { virFirewallGroupPtr group; =20 - if (VIR_ALLOC(group) < 0) - return NULL; + group =3D g_new0(virFirewallGroup, 1); =20 return group; } @@ -235,8 +234,7 @@ virFirewallPtr virFirewallNew(void) if (virFirewallInitialize() < 0) return NULL; =20 - if (VIR_ALLOC(firewall) < 0) - return NULL; + firewall =3D g_new0(virFirewall, 1); =20 return firewall; } @@ -346,8 +344,7 @@ virFirewallAddRuleFullV(virFirewallPtr firewall, group =3D firewall->groups[firewall->currentGroup]; =20 =20 - if (VIR_ALLOC(rule) < 0) - goto no_memory; + rule =3D g_new0(virFirewallRule, 1); =20 rule->layer =3D layer; rule->queryCB =3D cb; diff --git a/src/util/virfirewalld.c b/src/util/virfirewalld.c index a94ac7c183..3178bf4b3d 100644 --- a/src/util/virfirewalld.c +++ b/src/util/virfirewalld.c @@ -139,8 +139,7 @@ virFirewallDGetBackend(void) if (!sysbus) return -1; =20 - if (VIR_ALLOC(error) < 0) - return -1; + error =3D g_new0(virError, 1); =20 message =3D g_variant_new("(ss)", "org.fedoraproject.FirewallD1.config", @@ -289,8 +288,7 @@ virFirewallDApplyRule(virFirewallLayer layer, return -1; } =20 - if (VIR_ALLOC(error) < 0) - return -1; + error =3D g_new0(virError, 1); =20 message =3D g_variant_new("(s@as)", ipv, --=20 2.26.2 From nobody Sun May 5 22:43:59 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=1601920139; cv=none; d=zohomail.com; s=zohoarc; b=gM+BRa/hZTjxVaK5jJZEsS+S8QpawSrS8/ODuTAC8urnwy0yMDUO+rzyhlr9uSmnWPAaETC+gKaMmuF7KX5xssRB/p5StEeGtS2NVb2a1b5TF/UlIupj7jDiIATQbqfjIBONBkPdQvhzJ6KXffujhVtCvJU6kzsdKoRMDZSLBGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920139; 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=fHSUvrC+NOsYQWsH9FfStAW+rioCM4vTz2IZBk9QE9k=; b=BscmJC2i0z5gY19+ZdougxFiHAhmpoQwdis3wR5qlZWlh4rWbGxyuDxR+4hKZHTtNeM/vM4XuOnhrOx95COHVWCmqbFLUGzT+wGQs3EjjRPKhgh2dKcpeEbtfL5/jTUBh2dsXq2KdlsmPd+bJZDTXbwPCiO0U+SHIZQpcUnxkRY= 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 1601920139793824.1244853567285; Mon, 5 Oct 2020 10:48:59 -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-75-cGoAwOgYNk6BA4K83sC97w-1; Mon, 05 Oct 2020 13:48:55 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC958807357; Mon, 5 Oct 2020 17:48:47 +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 B87A910001B3; Mon, 5 Oct 2020 17:48:47 +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 7D2501826D31; Mon, 5 Oct 2020 17:48:47 +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 095Hmfj4015665 for ; Mon, 5 Oct 2020 13:48:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id DA8DD5C1C4; Mon, 5 Oct 2020 17:48:41 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6316F5C22B for ; Mon, 5 Oct 2020 17:48:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920138; 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=fHSUvrC+NOsYQWsH9FfStAW+rioCM4vTz2IZBk9QE9k=; b=LZyRGBAy9qsVJBQXFM3RgNOCuZ3Kw4pJGN20zwcIGQmRUqdrBOMIyjL31Rsu18sEsb0B60 YRVnsc8aHN/9jN5/5e/6CKuNfnUuRtMQfSLtJlTvCcZh/hyt5tARW3bt1sF4A58R0mmuEm AfbBoUkAqrhMgR2Q+L6NdWGZAQuV5xY= X-MC-Unique: cGoAwOgYNk6BA4K83sC97w-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 10/12] util: conf: use g_new0 Date: Mon, 5 Oct 2020 19:48:25 +0200 Message-Id: <30c1c5fe747d3a0a34227f0497ca914653a908c5.1601920046.git.jtomko@redhat.com> 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.84 on 10.5.11.22 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/util/virconf.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/util/virconf.c b/src/util/virconf.c index 8575dd8849..e983a769ee 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -163,8 +163,7 @@ virConfNew(void) { virConfPtr ret; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virConf, 1); ret->filename =3D NULL; ret->flags =3D 0; =20 @@ -219,8 +218,7 @@ virConfAddEntry(virConfPtr conf, char *name, virConfVal= uePtr value, char *comm) if (name) VIR_DEBUG("Add entry %s %p", name, value); =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virConfEntry, 1); =20 ret->name =3D name; ret->value =3D value; @@ -522,11 +520,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt) virConfError(ctxt, VIR_ERR_CONF_SYNTAX, _("expecting a value")); return NULL; } - if (VIR_ALLOC(ret) < 0) { - virConfFreeList(lst); - VIR_FREE(str); - return NULL; - } + ret =3D g_new0(virConfValue, 1); ret->type =3D type; ret->l =3D l; ret->str =3D str; @@ -947,8 +941,7 @@ int virConfGetValueStringList(virConfPtr conf, } } =20 - if (VIR_ALLOC_N(*values, len + 1) < 0) - return -1; + *values =3D g_new0(char *, len + 1); =20 for (len =3D 0, eval =3D cval->list; eval; len++, eval =3D eval->n= ext) (*values)[len] =3D g_strdup(eval->str); @@ -956,8 +949,7 @@ int virConfGetValueStringList(virConfPtr conf, =20 case VIR_CONF_STRING: if (compatString) { - if (VIR_ALLOC_N(*values, cval->str ? 2 : 1) < 0) - return -1; + *values =3D g_new0(char *, cval->str ? 2 : 1); if (cval->str) (*values)[0] =3D g_strdup(cval->str); break; @@ -1356,10 +1348,7 @@ virConfSetValue(virConfPtr conf, } =20 if (!cur) { - if (VIR_ALLOC(cur) < 0) { - virConfFreeValue(value); - return -1; - } + cur =3D g_new0(virConfEntry, 1); cur->comment =3D NULL; cur->name =3D g_strdup(setting); cur->value =3D value; --=20 2.26.2 From nobody Sun May 5 22:43:59 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=1601920146; cv=none; d=zohomail.com; s=zohoarc; b=e+z027HD6tZfnPoUoyRLMavNIM9NTJxLOSDV+nZ+3uBjIKnmfLhlvRbha3ws6eXhF+FW85Ty0wsQo45ZMZwibOarVycSEQQv7sW9pgZb0ErS0Qm0hEirLOOnVK/BhG+l2htjLU5yjcmsc+oouOenec5avzWXMuuS6r/5iySxPeg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920146; 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=Sd5NI5Zpu6NrEAAyXn3Fhf57FwxoOkdF1EqI8U+t4X0=; b=idz6GcPax8lPxhuAsawT3NIB0HmC5zb/CSEZ2ofWlhFnukvgLroCiRJqbWIqrnF3v8dESjoUUciG6qhPzT11NPvZqweVA0LeWyZd0iUoK7wIdHwBX825cYvteemIHU+FTG5k7//cWvtofBGr77apG9yKuksjtYe1JY8WUYvDnFI= 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 1601920146404497.8856712892547; Mon, 5 Oct 2020 10:49:06 -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-17-qBayrdQ8PIugYFCrE4DFbA-1; Mon, 05 Oct 2020 13:49:01 -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 793BB85C705; Mon, 5 Oct 2020 17:48:55 +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 548495D9CC; Mon, 5 Oct 2020 17:48:55 +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 1B45844A6D; Mon, 5 Oct 2020 17:48:55 +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 095HmgCu015674 for ; Mon, 5 Oct 2020 13:48:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id D31145C1C4; Mon, 5 Oct 2020 17:48:42 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3425C5C1BD for ; Mon, 5 Oct 2020 17:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920145; 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=Sd5NI5Zpu6NrEAAyXn3Fhf57FwxoOkdF1EqI8U+t4X0=; b=gpMrHoHU+LGfLwnNenW0wNnxRtHrxxl0fLO7X3N82nxejV80EiQCz7BGih6DU3v7XqaQzq trolyRTXTqAJCj6SLK3pKXgbDeWD4YRpqYFa3rznqwqkWQ7Slo1asQH43SbNeIRJ6CM4pk 8iKKBY2k8FAWJnWeeAClMAnQV4YSjHc= X-MC-Unique: qBayrdQ8PIugYFCrE4DFbA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 11/12] util: a-n: use g_new0 Date: Mon, 5 Oct 2020 19:48:26 +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.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) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/util/iohelper.c | 3 +-- src/util/virarptable.c | 3 +-- src/util/virauthconfig.c | 6 ++---- src/util/virbitmap.c | 4 +--- src/util/vircgroup.c | 7 ++----- src/util/vircrypto.c | 6 ++---- src/util/virdnsmasq.c | 12 ++++-------- src/util/virebtables.c | 3 +-- src/util/virfile.c | 12 +++--------- src/util/virfirmware.c | 6 ++---- src/util/virhash.c | 8 ++------ src/util/virhostcpu.c | 9 +++------ src/util/virjson.c | 15 +++++---------- src/util/virlockspace.c | 17 +++++------------ src/util/virlog.c | 5 +---- src/util/virmdev.c | 6 ++---- src/util/virnetlink.c | 3 +-- src/util/virnuma.c | 7 ++----- 18 files changed, 40 insertions(+), 92 deletions(-) diff --git a/src/util/iohelper.c b/src/util/iohelper.c index c3eb6f8c54..49d939d290 100644 --- a/src/util/iohelper.c +++ b/src/util/iohelper.c @@ -63,8 +63,7 @@ runIO(const char *path, int fd, int oflags) } buf =3D base; #else - if (VIR_ALLOC_N(buf, buflen + alignMask) < 0) - goto cleanup; + buf =3D g_new0(char, buflen + alignMask); base =3D buf; buf =3D (char *) (((intptr_t) base + alignMask) & ~alignMask); #endif diff --git a/src/util/virarptable.c b/src/util/virarptable.c index c4b46604a9..01a27c0093 100644 --- a/src/util/virarptable.c +++ b/src/util/virarptable.c @@ -74,8 +74,7 @@ virArpTableGet(void) if (msglen < 0) return NULL; =20 - if (VIR_ALLOC(table) < 0) - return NULL; + table =3D g_new0(virArpTable, 1); =20 nh =3D (struct nlmsghdr*)nlData; =20 diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c index 2e50609531..6b5487c4b0 100644 --- a/src/util/virauthconfig.c +++ b/src/util/virauthconfig.c @@ -40,8 +40,7 @@ virAuthConfigPtr virAuthConfigNew(const char *path) { virAuthConfigPtr auth; =20 - if (VIR_ALLOC(auth) < 0) - goto error; + auth =3D g_new0(virAuthConfig, 1); =20 auth->path =3D g_strdup(path); =20 @@ -65,8 +64,7 @@ virAuthConfigPtr virAuthConfigNewData(const char *path, { virAuthConfigPtr auth; =20 - if (VIR_ALLOC(auth) < 0) - goto error; + auth =3D g_new0(virAuthConfig, 1); =20 auth->path =3D g_strdup(path); =20 diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 319bd7b7ce..4fde6f4fd2 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -704,9 +704,7 @@ virBitmapToData(virBitmapPtr bitmap, else len =3D (len + CHAR_BIT) / CHAR_BIT; =20 - if (VIR_ALLOC_N(*data, len) < 0) - return -1; - + *data =3D g_new0(unsigned char, len); *dataLen =3D len; =20 virBitmapToDataBuf(bitmap, *data, *dataLen); diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 08758b5306..5c0543c66a 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -664,10 +664,8 @@ virCgroupNew(pid_t pid, { VIR_DEBUG("pid=3D%lld path=3D%s parent=3D%p controllers=3D%d group=3D%= p", (long long) pid, path, parent, controllers, group); - *group =3D NULL; =20 - if (VIR_ALLOC((*group)) < 0) - goto error; + *group =3D g_new0(virCgroup, 1); =20 if (path[0] =3D=3D '/' || !parent) { (*group)->path =3D g_strdup(path); @@ -2170,8 +2168,7 @@ virCgroupGetPercpuStats(virCgroupPtr group, param_idx =3D 1; =20 if (guestvcpus && param_idx < nparams) { - if (VIR_ALLOC_N(sum_cpu_time, need_cpus) < 0) - goto cleanup; + sum_cpu_time =3D g_new0(unsigned long long, need_cpus); if (virCgroupGetPercpuVcpuSum(group, guestvcpus, sum_cpu_time, need_cpus, cpumap) < 0) goto cleanup; diff --git a/src/util/vircrypto.c b/src/util/vircrypto.c index 90aed32c53..c4874550af 100644 --- a/src/util/vircrypto.c +++ b/src/util/vircrypto.c @@ -88,8 +88,7 @@ virCryptoHashString(virCryptoHash hash, =20 hashstrlen =3D (rc * 2) + 1; =20 - if (VIR_ALLOC_N(*output, hashstrlen) < 0) - return -1; + *output =3D g_new0(char, hashstrlen); =20 for (i =3D 0; i < rc; i++) { (*output)[i * 2] =3D hex[(buf[i] >> 4) & 0xf]; @@ -167,8 +166,7 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t= gnutls_enc_alg, * data from non-padded data. Hence datalen + 1 */ ciphertextlen =3D VIR_ROUND_UP(datalen + 1, 16); - if (VIR_ALLOC_N(ciphertext, ciphertextlen) < 0) - return -1; + ciphertext =3D g_new0(uint8_t, ciphertextlen); memcpy(ciphertext, data, datalen); =20 /* Fill in the padding of the buffer with the size of the padding diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 44aa7ad95d..9030f9218a 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -109,8 +109,7 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile, goto error; =20 idx =3D addnhostsfile->nhosts; - if (VIR_ALLOC(addnhostsfile->hosts[idx].hostnames) < 0) - goto error; + addnhostsfile->hosts[idx].hostnames =3D g_new0(char *, 1); =20 addnhostsfile->hosts[idx].ip =3D g_strdup(ipstr); =20 @@ -141,8 +140,7 @@ addnhostsNew(const char *name, dnsmasqAddnHostsfile *addnhostsfile; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 - if (VIR_ALLOC(addnhostsfile) < 0) - return NULL; + addnhostsfile =3D g_new0(dnsmasqAddnHostsfile, 1); =20 addnhostsfile->hosts =3D NULL; addnhostsfile->nhosts =3D 0; @@ -343,8 +341,7 @@ hostsfileNew(const char *name, dnsmasqHostsfile *hostsfile; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 - if (VIR_ALLOC(hostsfile) < 0) - return NULL; + hostsfile =3D g_new0(dnsmasqHostsfile, 1); =20 hostsfile->hosts =3D NULL; hostsfile->nhosts =3D 0; @@ -444,8 +441,7 @@ dnsmasqContextNew(const char *network_name, { dnsmasqContext *ctx; =20 - if (VIR_ALLOC(ctx) < 0) - return NULL; + ctx =3D g_new0(dnsmasqContext, 1); =20 ctx->config_dir =3D g_strdup(config_dir); =20 diff --git a/src/util/virebtables.c b/src/util/virebtables.c index 1887d718a3..b23ce21ae9 100644 --- a/src/util/virebtables.c +++ b/src/util/virebtables.c @@ -55,8 +55,7 @@ ebtablesContextNew(const char *driver) { ebtablesContext *ctx =3D NULL; =20 - if (VIR_ALLOC(ctx) < 0) - return NULL; + ctx =3D g_new0(ebtablesContext, 1); =20 ctx->chain =3D g_strdup_printf("libvirt_%s_FORWARD", driver); =20 diff --git a/src/util/virfile.c b/src/util/virfile.c index e120d277d0..7d0a40b0fb 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -258,8 +258,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned= int flags) return NULL; } =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virFileWrapperFd, 1); =20 mode =3D fcntl(*fd, F_GETFL); =20 @@ -1178,11 +1177,7 @@ safezero_slow(int fd, off_t offset, off_t len) remain =3D len; bytes =3D MIN(1024 * 1024, len); =20 - r =3D VIR_ALLOC_N(buf, bytes); - if (r < 0) { - errno =3D ENOMEM; - return -1; - } + buf =3D g_new0(char, bytes); =20 while (remain) { if (bytes > remain) @@ -3160,8 +3155,7 @@ virFileOpenTty(int *ttyprimary, char **ttyName, int r= awmode) size_t len =3D 64; int rc; =20 - if (VIR_ALLOC_N(name, len) < 0) - goto cleanup; + name =3D g_new0(char, len); =20 while ((rc =3D ttyname_r(secondary, name, len)) =3D=3D ERANGE) { if (VIR_RESIZE_N(name, len, len, len) < 0) diff --git a/src/util/virfirmware.c b/src/util/virfirmware.c index 513ec56621..6b8a64eafa 100644 --- a/src/util/virfirmware.c +++ b/src/util/virfirmware.c @@ -112,15 +112,13 @@ virFirmwareParseList(const char *list, } =20 if (i) { - if (VIR_ALLOC_N(*firmwares, i / 2) < 0) - goto cleanup; + *firmwares =3D g_new0(virFirmwarePtr, i / 2); *nfirmwares =3D i / 2; =20 for (j =3D 0; j < i / 2; j++) { virFirmwarePtr *fws =3D *firmwares; =20 - if (VIR_ALLOC(fws[j]) < 0) - goto cleanup; + fws[j] =3D g_new0(virFirmware, 1); fws[j]->name =3D g_strdup(token[2 * j]); fws[j]->nvram =3D g_strdup(token[2 * j + 1]); } diff --git a/src/util/virhash.c b/src/util/virhash.c index abec757d99..4b503a0313 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -271,10 +271,7 @@ virHashGrow(virHashTablePtr table, size_t size) if (oldtable =3D=3D NULL) return -1; =20 - if (VIR_ALLOC_N(table->table, size) < 0) { - table->table =3D oldtable; - return -1; - } + table->table =3D g_new0(virHashEntryPtr, size); table->size =3D size; =20 for (i =3D 0; i < oldsize; i++) { @@ -792,8 +789,7 @@ virHashKeyValuePairPtr virHashGetItems(virHashTablePtr = table, if (numElems < 0) return NULL; =20 - if (VIR_ALLOC_N(iter.sortArray, numElems + 1)) - return NULL; + iter.sortArray =3D g_new0(virHashKeyValuePair, numElems + 1); =20 virHashForEach(table, virHashGetKeysIterator, &iter); =20 diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 28f032b972..4ae4dca067 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -145,8 +145,7 @@ virHostCPUGetStatsFreeBSD(int cpuNum, =20 cpu_times_size =3D sizeof(long) * cpu_times_num * CPUSTATES; =20 - if (VIR_ALLOC_N(cpu_times, cpu_times_num * CPUSTATES) < 0) - goto cleanup; + cpu_times =3D g_new0(long, cpu_times_num * CPUSTATES); =20 if (sysctlbyname(sysctl_name, cpu_times, &cpu_times_size, NULL, 0) < 0= ) { virReportSystemError(errno, @@ -366,8 +365,7 @@ virHostCPUParseNode(const char *node, sock_max++; =20 /* allocate cores maps for each socket */ - if (VIR_ALLOC_N(cores_maps, sock_max) < 0) - goto cleanup; + cores_maps =3D g_new0(virBitmapPtr, sock_max); =20 for (i =3D 0; i < sock_max; i++) cores_maps[i] =3D virBitmapNew(0); @@ -1385,8 +1383,7 @@ virHostCPUGetTscInfo(void) return NULL; } =20 - if (VIR_ALLOC(info) < 0) - return NULL; + info =3D g_new0(virHostCPUTscInfo, 1); =20 info->frequency =3D rc * 1000ULL; =20 diff --git a/src/util/virjson.c b/src/util/virjson.c index a4fc9e990e..3fa9a9ca24 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -438,8 +438,7 @@ virJSONValueNewString(const char *data) if (!data) return virJSONValueNewNull(); =20 - if (VIR_ALLOC(val) < 0) - return NULL; + val =3D g_new0(virJSONValue, 1); =20 val->type =3D VIR_JSON_TYPE_STRING; val->data.string =3D g_strdup(data); @@ -457,8 +456,7 @@ virJSONValueNewStringLen(const char *data, if (!data) return virJSONValueNewNull(); =20 - if (VIR_ALLOC(val) < 0) - return NULL; + val =3D g_new0(virJSONValue, 1); =20 val->type =3D VIR_JSON_TYPE_STRING; val->data.string =3D g_strndup(data, length); @@ -472,8 +470,7 @@ virJSONValueNewNumber(const char *data) { virJSONValuePtr val; =20 - if (VIR_ALLOC(val) < 0) - return NULL; + val =3D g_new0(virJSONValue, 1); =20 val->type =3D VIR_JSON_TYPE_NUMBER; val->data.number =3D g_strdup(data); @@ -533,8 +530,7 @@ virJSONValueNewBoolean(int boolean_) { virJSONValuePtr val; =20 - if (VIR_ALLOC(val) < 0) - return NULL; + val =3D g_new0(virJSONValue, 1); =20 val->type =3D VIR_JSON_TYPE_BOOLEAN; val->data.boolean =3D boolean_; @@ -548,8 +544,7 @@ virJSONValueNewNull(void) { virJSONValuePtr val; =20 - if (VIR_ALLOC(val) < 0) - return NULL; + val =3D g_new0(virJSONValue, 1); =20 val->type =3D VIR_JSON_TYPE_NULL; =20 diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index 9a54192cd1..ef370936a3 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -119,8 +119,7 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace, virLockSpaceResourcePtr res; bool shared =3D !!(flags & VIR_LOCK_SPACE_ACQUIRE_SHARED); =20 - if (VIR_ALLOC(res) < 0) - return NULL; + res =3D g_new0(virLockSpaceResource, 1); =20 res->fd =3D -1; res->flags =3D flags; @@ -241,8 +240,7 @@ virLockSpacePtr virLockSpaceNew(const char *directory) =20 VIR_DEBUG("directory=3D%s", NULLSTR(directory)); =20 - if (VIR_ALLOC(lockspace) < 0) - return NULL; + lockspace =3D g_new0(virLockSpace, 1); =20 if (virMutexInit(&lockspace->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -292,8 +290,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONV= aluePtr object) =20 VIR_DEBUG("object=3D%p", object); =20 - if (VIR_ALLOC(lockspace) < 0) - return NULL; + lockspace =3D g_new0(virLockSpace, 1); =20 if (virMutexInit(&lockspace->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -331,8 +328,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONV= aluePtr object) size_t j; size_t m; =20 - if (VIR_ALLOC(res) < 0) - goto error; + res =3D g_new0(virLockSpaceResource, 1); res->fd =3D -1; =20 if (!(tmp =3D virJSONValueObjectGetString(child, "name"))) { @@ -391,10 +387,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSON= ValuePtr object) } =20 m =3D virJSONValueArraySize(owners); - if (VIR_ALLOC_N(res->owners, res->nOwners) < 0) { - virLockSpaceResourceFree(res); - goto error; - } + res->owners =3D g_new0(pid_t, res->nOwners); res->nOwners =3D m; =20 for (j =3D 0; j < res->nOwners; j++) { diff --git a/src/util/virlog.c b/src/util/virlog.c index 285c130d36..6b7a4512e9 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1271,10 +1271,7 @@ virLogOutputNew(virLogOutputFunc f, ndup =3D g_strdup(name); } =20 - if (VIR_ALLOC(ret) < 0) { - VIR_FREE(ndup); - return NULL; - } + ret =3D g_new0(virLogOutput, 1); =20 ret->logInitMessage =3D true; ret->f =3D f; diff --git a/src/util/virmdev.c b/src/util/virmdev.c index 26cb8300ff..31994631ed 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -150,8 +150,7 @@ virMediatedDeviceNew(const char *uuidstr, virMediatedDe= viceModelType model) return NULL; } =20 - if (VIR_ALLOC(dev) < 0) - return NULL; + dev =3D g_new0(virMediatedDevice, 1); =20 dev->path =3D g_steal_pointer(&sysfspath); =20 @@ -494,8 +493,7 @@ virMediatedDeviceTypeReadAttrs(const char *sysfspath, } \ } while (0) =20 - if (VIR_ALLOC(tmp) < 0) - return -1; + tmp =3D g_new0(virMediatedDeviceType, 1); =20 tmp->id =3D g_path_get_basename(sysfspath); =20 diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index ea06db51ee..fdd3a6a4d0 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -1018,8 +1018,7 @@ virNetlinkEventServiceStart(unsigned int protocol, un= signed int groups) =20 VIR_INFO("starting netlink event service with protocol %d", protocol); =20 - if (VIR_ALLOC(srv) < 0) - return -1; + srv =3D g_new0(virNetlinkEventSrvPrivate, 1); =20 if (virMutexInit(&srv->lock) < 0) { VIR_FREE(srv); diff --git a/src/util/virnuma.c b/src/util/virnuma.c index 6728f62a87..5d40d13977 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -265,8 +265,7 @@ virNumaGetNodeCPUs(int node, return -2; } =20 - if (VIR_ALLOC_N(mask, mask_n_bytes / sizeof(*mask)) < 0) - return -1; + mask =3D g_new0(unsigned long, mask_n_bytes / sizeof(*mask)); =20 if (numa_node_to_cpus(node, mask, mask_n_bytes) < 0) { VIR_WARN("NUMA topology for cell %d is not available, ignoring", n= ode); @@ -477,9 +476,7 @@ virNumaGetDistances(int node, if ((max_node =3D virNumaGetMaxNode()) < 0) return -1; =20 - if (VIR_ALLOC_N(*distances, max_node + 1) < 0) - return -1; - + *distances =3D g_new0(int, max_node + 1); *ndistances =3D max_node + 1; =20 for (i =3D 0; i <=3D max_node; i++) { --=20 2.26.2 From nobody Sun May 5 22:43:59 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=1601920216; cv=none; d=zohomail.com; s=zohoarc; b=lSjJX4fAYgruAqSaAYJF0lze996d5WO8yGHmvsI2gCnfMoavxS2WFxu+ylhpcFWUpPiIgpkDMupRIj0IFZgyU7Atpp1pApunuYcuf8s8WqpdfScaurl4ASmPTHgfcAVnAnZVRqAFBOwNfI/EKPXHcii0CYtiUODtdoaVvxL0v7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920216; 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=iGpQ3z4jv/Bn2zTdBoNFc+JGXz9BjdQwIC8UZoqlW9E=; b=W0DpzL14MlZQq9EzAqQwXeikIE2w88FtPgX1K9GKcYlEYzoZLvQdKntGobXdwzYCIlUVScu1Mzwp8H9b2krFFWoc+iti9WQ57ULfHts/Li/sfyHFJrJOEoNXLyJU3x03rFBUBlPvzCKbDnJm7UNVnl0ChRLiLlwBMO461unBJYM= 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 1601920216752725.3589248881003; Mon, 5 Oct 2020 10:50:16 -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-341-5MsEt6MNMRKEVQAIjawJpA-1; Mon, 05 Oct 2020 13:49:04 -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 383BC18C89C7; Mon, 5 Oct 2020 17:48:58 +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 153BB5C225; Mon, 5 Oct 2020 17:48: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 D5EE71826D33; Mon, 5 Oct 2020 17:48:57 +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 095HmhL7015688 for ; Mon, 5 Oct 2020 13:48:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id A59105C1C4; Mon, 5 Oct 2020 17:48:43 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C9CB5C1BD for ; Mon, 5 Oct 2020 17:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920215; 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=iGpQ3z4jv/Bn2zTdBoNFc+JGXz9BjdQwIC8UZoqlW9E=; b=HFLI8awMC0tQCMr3ySYNuwfSSNTLCKLqsh6fb9BHbcz/4+K+iNF6P4A2UiWTOwN+9cVxKl 0hTDDopswUbFX8ZfpG/jhXmJ/FB83Qtmz/1VmXR/8ZJ9uKjjIYCiJ0mYDQNciDZgByK5tY r+zTSU2Bu4d1W3Li62WFfM2Fm7Uzyjc= X-MC-Unique: 5MsEt6MNMRKEVQAIjawJpA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 12/12] util: o-z: use g_new0 Date: Mon, 5 Oct 2020 19:48:27 +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.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/util/virpci.c | 12 ++++-------- src/util/virperf.c | 3 +-- src/util/virpolkit.c | 3 +-- src/util/virportallocator.c | 3 +-- src/util/virprocess.c | 3 +-- src/util/virrotatingfile.c | 15 +++++---------- src/util/virscsi.c | 6 ++---- src/util/virscsivhost.c | 3 +-- src/util/virseclabel.c | 13 +++---------- src/util/virstorageencryption.c | 16 +++++----------- src/util/virstring.c | 3 +-- src/util/virthreadpool.c | 9 +++------ src/util/virtime.c | 6 ++---- src/util/virtypedparam.c | 20 +++++++------------- src/util/viruri.c | 3 +-- src/util/virusb.c | 3 +-- src/util/virutil.c | 15 +++++---------- src/util/virxml.c | 7 ++----- 18 files changed, 46 insertions(+), 97 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index 47c671daa0..6fa8acd246 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1372,8 +1372,7 @@ virPCIDeviceNew(unsigned int domain, g_autofree char *vendor =3D NULL; g_autofree char *product =3D NULL; =20 - if (VIR_ALLOC(dev) < 0) - return NULL; + dev =3D g_new0(virPCIDevice, 1); =20 dev->address.domain =3D domain; dev->address.bus =3D bus; @@ -1422,8 +1421,7 @@ virPCIDeviceCopy(virPCIDevicePtr dev) { virPCIDevicePtr copy; =20 - if (VIR_ALLOC(copy) < 0) - return NULL; + copy =3D g_new0(virPCIDevice, 1); =20 /* shallow copy to take care of most attributes */ *copy =3D *dev; @@ -1871,8 +1869,7 @@ virPCIGetIOMMUGroupAddressesAddOne(virPCIDeviceAddres= sPtr newDevAddr, void *opaq virPCIDeviceAddressPtr copyAddr; =20 /* make a copy to insert onto the list */ - if (VIR_ALLOC(copyAddr) < 0) - goto cleanup; + copyAddr =3D g_new0(virPCIDeviceAddress, 1); =20 *copyAddr =3D *newDevAddr; =20 @@ -2204,8 +2201,7 @@ virPCIGetDeviceAddressFromSysfsLink(const char *devic= e_link) } =20 config_address =3D g_path_get_basename(device_path); - if (VIR_ALLOC(bdf) < 0) - return NULL; + bdf =3D g_new0(virPCIDeviceAddress, 1); =20 if (virPCIDeviceAddressParse(config_address, bdf) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/util/virperf.c b/src/util/virperf.c index 2e95509caf..7f260d2da6 100644 --- a/src/util/virperf.c +++ b/src/util/virperf.c @@ -368,8 +368,7 @@ virPerfNew(void) size_t i; virPerfPtr perf; =20 - if (VIR_ALLOC(perf) < 0) - return NULL; + perf =3D g_new0(virPerf, 1); =20 for (i =3D 0; i < VIR_PERF_EVENT_LAST; i++) { perf->events[i].fd =3D -1; diff --git a/src/util/virpolkit.c b/src/util/virpolkit.c index aad924a065..1d6be443f7 100644 --- a/src/util/virpolkit.c +++ b/src/util/virpolkit.c @@ -178,8 +178,7 @@ virPolkitAgentCreate(void) if (virPipe(pipe_fd) < 0) goto error; =20 - if (VIR_ALLOC(agent) < 0) - goto error; + agent =3D g_new0(virPolkitAgent, 1); =20 agent->cmd =3D virCommandNewArgList(PKTTYAGENT, "--process", NULL); =20 diff --git a/src/util/virportallocator.c b/src/util/virportallocator.c index f450740318..76c6e43726 100644 --- a/src/util/virportallocator.c +++ b/src/util/virportallocator.c @@ -102,8 +102,7 @@ virPortAllocatorRangeNew(const char *name, return NULL; } =20 - if (VIR_ALLOC(range) < 0) - return NULL; + range =3D g_new0(virPortAllocatorRange, 1); =20 range->start =3D start; range->end =3D end; diff --git a/src/util/virprocess.c b/src/util/virprocess.c index d379f7446f..9366f0630c 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1351,8 +1351,7 @@ virProcessNamespaceAvailable(unsigned int ns) /* Signal parent as soon as the child dies. RIP. */ flags |=3D SIGCHLD; =20 - if (VIR_ALLOC_N(stack, stacksize) < 0) - return -1; + stack =3D g_new0(char, stacksize); =20 childStack =3D stack + stacksize; =20 diff --git a/src/util/virrotatingfile.c b/src/util/virrotatingfile.c index b77e30dba7..a88c332cf4 100644 --- a/src/util/virrotatingfile.c +++ b/src/util/virrotatingfile.c @@ -105,8 +105,7 @@ virRotatingFileWriterEntryNew(const char *path, =20 VIR_DEBUG("Opening %s mode=3D0%02o", path, mode); =20 - if (VIR_ALLOC(entry) < 0) - return NULL; + entry =3D g_new0(virRotatingFileWriterEntry, 1); =20 if ((entry->fd =3D open(path, O_CREAT|O_APPEND|O_WRONLY|O_CLOEXEC, mod= e)) < 0) { virReportSystemError(errno, @@ -148,8 +147,7 @@ virRotatingFileReaderEntryNew(const char *path) =20 VIR_DEBUG("Opening %s", path); =20 - if (VIR_ALLOC(entry) < 0) - return NULL; + entry =3D g_new0(virRotatingFileReaderEntry, 1); =20 if ((entry->fd =3D open(path, O_RDONLY|O_CLOEXEC)) < 0) { if (errno !=3D ENOENT) { @@ -238,8 +236,7 @@ virRotatingFileWriterNew(const char *path, { virRotatingFileWriterPtr file; =20 - if (VIR_ALLOC(file) < 0) - goto error; + file =3D g_new0(virRotatingFileWriter, 1); =20 file->basepath =3D g_strdup(path); =20 @@ -288,8 +285,7 @@ virRotatingFileReaderNew(const char *path, virRotatingFileReaderPtr file; size_t i; =20 - if (VIR_ALLOC(file) < 0) - goto error; + file =3D g_new0(virRotatingFileReader, 1); =20 if (maxbackup > VIR_MAX_MAX_BACKUP) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -299,8 +295,7 @@ virRotatingFileReaderNew(const char *path, } =20 file->nentries =3D maxbackup + 1; - if (VIR_ALLOC_N(file->entries, file->nentries) < 0) - goto error; + file->entries =3D g_new0(virRotatingFileReaderEntryPtr, file->nentries= ); =20 if (!(file->entries[file->nentries - 1] =3D virRotatingFileReaderEntry= New(path))) goto error; diff --git a/src/util/virscsi.c b/src/util/virscsi.c index e3bd81b569..4dcd68d53a 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -186,8 +186,7 @@ virSCSIDeviceNew(const char *sysfs_prefix, g_autofree char *model =3D NULL; const char *prefix =3D sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICE= S; =20 - if (VIR_ALLOC(dev) < 0) - return NULL; + dev =3D g_new0(virSCSIDevice, 1); =20 dev->bus =3D bus; dev->target =3D target; @@ -263,8 +262,7 @@ virSCSIDeviceSetUsedBy(virSCSIDevicePtr dev, { g_autoptr(virUsedByInfo) copy =3D NULL; =20 - if (VIR_ALLOC(copy) < 0) - return -1; + copy =3D g_new0(virUsedByInfo, 1); copy->drvname =3D g_strdup(drvname); copy->domname =3D g_strdup(domname); =20 diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c index be1f57c6e2..a2bf9a446f 100644 --- a/src/util/virscsivhost.c +++ b/src/util/virscsivhost.c @@ -250,8 +250,7 @@ virSCSIVHostDeviceNew(const char *name) { g_autoptr(virSCSIVHostDevice) dev =3D NULL; =20 - if (VIR_ALLOC(dev) < 0) - return NULL; + dev =3D g_new0(virSCSIVHostDevice, 1); =20 dev->name =3D g_strdup(name); =20 diff --git a/src/util/virseclabel.c b/src/util/virseclabel.c index 2141d84210..174f344a8b 100644 --- a/src/util/virseclabel.c +++ b/src/util/virseclabel.c @@ -58,10 +58,7 @@ virSecurityLabelDefNew(const char *model) { virSecurityLabelDefPtr seclabel =3D NULL; =20 - if (VIR_ALLOC(seclabel) < 0) { - virSecurityLabelDefFree(seclabel); - return NULL; - } + seclabel =3D g_new0(virSecurityLabelDef, 1); =20 seclabel->model =3D g_strdup(model); =20 @@ -75,10 +72,7 @@ virSecurityDeviceLabelDefNew(const char *model) { virSecurityDeviceLabelDefPtr seclabel =3D NULL; =20 - if (VIR_ALLOC(seclabel) < 0) { - virSecurityDeviceLabelDefFree(seclabel); - return NULL; - } + seclabel =3D g_new0(virSecurityDeviceLabelDef, 1); =20 seclabel->model =3D g_strdup(model); =20 @@ -91,8 +85,7 @@ virSecurityDeviceLabelDefCopy(const virSecurityDeviceLabe= lDef *src) { virSecurityDeviceLabelDefPtr ret; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virSecurityDeviceLabelDef, 1); =20 ret->relabel =3D src->relabel; ret->labelskip =3D src->labelskip; diff --git a/src/util/virstorageencryption.c b/src/util/virstorageencryptio= n.c index 76958b3876..399c6926bd 100644 --- a/src/util/virstorageencryption.c +++ b/src/util/virstorageencryption.c @@ -115,12 +115,9 @@ virStorageEncryptionCopy(const virStorageEncryption *s= rc) virStorageEncryptionPtr ret; size_t i; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; - - if (VIR_ALLOC_N(ret->secrets, src->nsecrets) < 0) - goto error; + ret =3D g_new0(virStorageEncryption, 1); =20 + ret->secrets =3D g_new0(virStorageEncryptionSecretPtr, src->nsecrets); ret->nsecrets =3D src->nsecrets; ret->format =3D src->format; =20 @@ -147,8 +144,7 @@ virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt, virStorageEncryptionSecretPtr ret; char *type_str =3D NULL; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virStorageEncryptionSecret, 1); =20 ctxt->node =3D node; =20 @@ -247,8 +243,7 @@ virStorageEncryptionParseNode(xmlNodePtr node, =20 ctxt->node =3D node; =20 - if (VIR_ALLOC(encdef) < 0) - goto cleanup; + encdef =3D g_new0(virStorageEncryption, 1); =20 if (!(format_str =3D virXPathString("string(./@format)", ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -268,8 +263,7 @@ virStorageEncryptionParseNode(xmlNodePtr node, goto cleanup; =20 if (n > 0) { - if (VIR_ALLOC_N(encdef->secrets, n) < 0) - goto cleanup; + encdef->secrets =3D g_new0(virStorageEncryptionSecretPtr, n); encdef->nsecrets =3D n; =20 for (i =3D 0; i < n; i++) { diff --git a/src/util/virstring.c b/src/util/virstring.c index de2ef964f4..5c49b56f75 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -1222,8 +1222,7 @@ virStringToUpper(char **dst, const char *src) if (!src) return 0; =20 - if (VIR_ALLOC_N(cap, strlen(src) + 1) < 0) - return -1; + cap =3D g_new0(char, strlen(src) + 1); =20 for (i =3D 0; src[i]; i++) { cap[i] =3D g_ascii_toupper(src[i]); diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c index ca44f55c1b..3942633431 100644 --- a/src/util/virthreadpool.c +++ b/src/util/virthreadpool.c @@ -188,9 +188,8 @@ virThreadPoolExpand(virThreadPoolPtr pool, size_t gain,= bool priority) =20 for (i =3D 0; i < gain; i++) { g_autofree char *name =3D NULL; - if (VIR_ALLOC(data) < 0) - goto error; =20 + data =3D g_new0(struct virThreadPoolWorkerData, 1); data->pool =3D pool; data->cond =3D priority ? &pool->prioCond : &pool->cond; data->priority =3D priority; @@ -232,8 +231,7 @@ virThreadPoolNewFull(size_t minWorkers, if (minWorkers > maxWorkers) minWorkers =3D maxWorkers; =20 - if (VIR_ALLOC(pool) < 0) - return NULL; + pool =3D g_new0(virThreadPool, 1); =20 pool->jobList.tail =3D pool->jobList.head =3D NULL; =20 @@ -403,8 +401,7 @@ int virThreadPoolSendJob(virThreadPoolPtr pool, virThreadPoolExpand(pool, 1, false) < 0) goto error; =20 - if (VIR_ALLOC(job) < 0) - goto error; + job =3D g_new0(virThreadPoolJob, 1); =20 job->data =3D jobData; job->priority =3D priority; diff --git a/src/util/virtime.c b/src/util/virtime.c index 88f6f0a551..baf4ce5db7 100644 --- a/src/util/virtime.c +++ b/src/util/virtime.c @@ -257,8 +257,7 @@ char *virTimeStringNow(void) { char *ret; =20 - if (VIR_ALLOC_N(ret, VIR_TIME_STRING_BUFLEN) < 0) - return NULL; + ret =3D g_new0(char, VIR_TIME_STRING_BUFLEN); =20 if (virTimeStringNowRaw(ret) < 0) { virReportSystemError(errno, "%s", @@ -286,8 +285,7 @@ char *virTimeStringThen(unsigned long long when) { char *ret; =20 - if (VIR_ALLOC_N(ret, VIR_TIME_STRING_BUFLEN) < 0) - return NULL; + ret =3D g_new0(char, VIR_TIME_STRING_BUFLEN); =20 if (virTimeStringThenRaw(when, ret) < 0) { virReportSystemError(errno, "%s", diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index e4e50d837a..43af4a7c56 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -68,8 +68,7 @@ virTypedParamsValidate(virTypedParameterPtr params, int n= params, ...) =20 va_start(ap, nparams); =20 - if (VIR_ALLOC_N(sorted, nparams) < 0) - goto cleanup; + sorted =3D g_new0(virTypedParameter, nparams); =20 /* Here we intentionally don't copy values */ memcpy(sorted, params, sizeof(*params) * nparams); @@ -361,8 +360,7 @@ virTypedParamsCopy(virTypedParameterPtr *dst, if (!src || nparams <=3D 0) return 0; =20 - if (VIR_ALLOC_N(*dst, nparams) < 0) - return -1; + *dst =3D g_new0(virTypedParameter, nparams); =20 for (i =3D 0; i < nparams; i++) { ignore_value(virStrcpyStatic((*dst)[i].field, src[i].field)); @@ -399,8 +397,7 @@ virTypedParamsFilter(virTypedParameterPtr params, { size_t i, n =3D 0; =20 - if (VIR_ALLOC_N(*ret, nparams) < 0) - return -1; + *ret =3D g_new0(virTypedParameterPtr, nparams); =20 for (i =3D 0; i < nparams; i++) { if (STREQ(params[i].field, name)) { @@ -447,9 +444,8 @@ virTypedParamsGetStringList(virTypedParameterPtr params, if (nfiltered < 0) goto error; =20 - if (nfiltered && - VIR_ALLOC_N(*values, nfiltered) < 0) - goto error; + if (nfiltered) + *values =3D g_new0(const char *, nfiltered); =20 for (n =3D 0, i =3D 0; i < nfiltered; i++) { if (filtered[i]->type =3D=3D VIR_TYPED_PARAM_STRING) @@ -551,8 +547,7 @@ virTypedParamsDeserialize(virTypedParameterRemotePtr re= mote_params, goto cleanup; } } else { - if (VIR_ALLOC_N(*params, remote_params_len) < 0) - goto cleanup; + *params =3D g_new0(virTypedParameter, remote_params_len); } *nparams =3D remote_params_len; =20 @@ -662,8 +657,7 @@ virTypedParamsSerialize(virTypedParameterPtr params, goto cleanup; } =20 - if (VIR_ALLOC_N(params_val, nparams) < 0) - goto cleanup; + params_val =3D g_new0(struct _virTypedParameterRemote, nparams); =20 for (i =3D 0, j =3D 0; i < nparams; ++i) { virTypedParameterPtr param =3D params + i; diff --git a/src/util/viruri.c b/src/util/viruri.c index dd7559662b..11753a0aef 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -157,8 +157,7 @@ virURIParse(const char *uri) return NULL; } =20 - if (VIR_ALLOC(ret) < 0) - goto error; + ret =3D g_new0(virURI, 1); =20 ret->scheme =3D g_strdup(xmluri->scheme); ret->server =3D g_strdup(xmluri->server); diff --git a/src/util/virusb.c b/src/util/virusb.c index a28604c3f4..3e7e4281a3 100644 --- a/src/util/virusb.c +++ b/src/util/virusb.c @@ -312,8 +312,7 @@ virUSBDeviceNew(unsigned int bus, { virUSBDevicePtr dev; =20 - if (VIR_ALLOC(dev) < 0) - return NULL; + dev =3D g_new0(virUSBDevice, 1); =20 dev->bus =3D bus; dev->dev =3D devno; diff --git a/src/util/virutil.c b/src/util/virutil.c index 48b38c705b..708c3cf9ef 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -447,8 +447,7 @@ char *virIndexToDiskName(int idx, const char *prefix) =20 offset =3D strlen(prefix); =20 - if (VIR_ALLOC_N(name, offset + i + 1)) - return NULL; + name =3D g_new0(char, offset + i + 1); =20 strcpy(name, prefix); name[offset + i] =3D '\0'; @@ -618,8 +617,7 @@ virGetUserEnt(uid_t uid, char **name, gid_t *group, cha= r **dir, char **shell, bo if (val < 0) strbuflen =3D 1024; =20 - if (VIR_ALLOC_N(strbuf, strbuflen) < 0) - return -1; + strbuf =3D g_new0(char, strbuflen); =20 /* * From the manpage (terrifying but true): @@ -688,8 +686,7 @@ static char *virGetGroupEnt(gid_t gid) if (val < 0) strbuflen =3D 1024; =20 - if (VIR_ALLOC_N(strbuf, strbuflen) < 0) - return NULL; + strbuf =3D g_new0(char, strbuflen); =20 /* * From the manpage (terrifying but true): @@ -774,8 +771,7 @@ virGetUserIDByName(const char *name, uid_t *uid, bool m= issing_ok) if (val < 0) strbuflen =3D 1024; =20 - if (VIR_ALLOC_N(strbuf, strbuflen) < 0) - goto cleanup; + strbuf =3D g_new0(char, strbuflen); =20 while ((rc =3D getpwnam_r(name, &pwbuf, strbuf, strbuflen, &pw)) =3D= =3D ERANGE) { if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0) @@ -856,8 +852,7 @@ virGetGroupIDByName(const char *name, gid_t *gid, bool = missing_ok) if (val < 0) strbuflen =3D 1024; =20 - if (VIR_ALLOC_N(strbuf, strbuflen) < 0) - goto cleanup; + strbuf =3D g_new0(char, strbuflen); =20 while ((rc =3D getgrnam_r(name, &grbuf, strbuf, strbuflen, &gr)) =3D= =3D ERANGE) { if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0) diff --git a/src/util/virxml.c b/src/util/virxml.c index 1927ff490f..b4d6684560 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -672,9 +672,7 @@ virXPathNodeSet(const char *xpath, =20 ret =3D obj->nodesetval->nodeNr; if (list !=3D NULL && ret) { - if (VIR_ALLOC_N(*list, ret) < 0) - return -1; - + *list =3D g_new0(xmlNodePtr, ret); memcpy(*list, obj->nodesetval->nodeTab, ret * sizeof(xmlNodePtr)); } xmlXPathFreeObject(obj); @@ -1237,8 +1235,7 @@ virXMLValidatorInit(const char *schemafile) { virXMLValidatorPtr validator =3D NULL; =20 - if (VIR_ALLOC(validator) < 0) - return NULL; + validator =3D g_new0(virXMLValidator, 1); =20 validator->schemafile =3D g_strdup(schemafile); =20 --=20 2.26.2