From nobody Sun Apr 28 05:42:34 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=1627031167; cv=none; d=zohomail.com; s=zohoarc; b=MKwZRZJEYTtHfJQ9SiV0XXJJZijVEUPiE6sm+rVpxvegGSXpUBGG9sfxraonnBVrxAehoz7Ym8SP2zLwmDEyD1VwwhVaA7A3NTD18jo0fWSmBvMQCN/DMJ1PriZd9wmvWTbqckVvnFXG5dT53nWlv87BGF4gOUbqK6nRvD6dx8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627031167; 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=WSuB3qlzgEVJW/kxAaxjS/IRlovo2DKulC8P3iEJWwM=; b=H2jb7vZ+nvX1hr5vh/CcttV3DM7GW4Rkcxpo9Y+afNLUx6SexeLO/0OcyHnW5rgGVfMxUT6dvUHcrAXGEb6JyLIeJnCRkSiKjEDTcGP5MpGPRriCatmUwg1X7D7cpk8P9mvzCFSS+QKIajLOYd0S6eX1/uhtHflZoiU98Li+ftQ= 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) 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 1627031167574704.8793807562935; Fri, 23 Jul 2021 02:06:07 -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-45-cG4Es5utPmSO_q7dkbbEPA-1; Fri, 23 Jul 2021 05:06:04 -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 F0DB81853032; Fri, 23 Jul 2021 09:05: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 9E0103A47; Fri, 23 Jul 2021 09:05: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 5FFF4180BAB0; Fri, 23 Jul 2021 09:05:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16N95usZ019548 for ; Fri, 23 Jul 2021 05:05:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id E1B0760853; Fri, 23 Jul 2021 09:05:56 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 472D060862 for ; Fri, 23 Jul 2021 09:05:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627031166; 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=WSuB3qlzgEVJW/kxAaxjS/IRlovo2DKulC8P3iEJWwM=; b=Wg28V4h8oExxn9AEu29FmqmoV0K3rNF+C5X7dvd3YZKK+3oIgoZpKZMK2NttDkUbbAkeUa IHDCfslFglf6Q3+HRRDV/euTNiHvzUdjG9QdHq5KZW8Khaosyu2Ux8yGnVM8R+Q1JPvsAh /aw7z/Mm1F3EalwD1z2ggFOi9Fn+zaQ= X-MC-Unique: cG4Es5utPmSO_q7dkbbEPA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/7] virHashNew: Ensure return value is used Date: Fri, 23 Jul 2021 11:05:44 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1627032069756100001 Content-Type: text/plain; charset="utf-8" Declare the function with G_GNUC_WARN_UNUSED_RESULT as we always want to use the returned value. Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/util/virhash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virhash.h b/src/util/virhash.h index c2a0681317..426d835cfc 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -50,7 +50,7 @@ typedef int (*virHashSearcher) (const void *payload, cons= t char *name, /* * Constructor and destructor. */ -GHashTable *virHashNew(virHashDataFree dataFree); +GHashTable *virHashNew(virHashDataFree dataFree) G_GNUC_WARN_UNUSED_RESULT; virHashAtomic *virHashAtomicNew(virHashDataFree dataFree); void virHashFree(GHashTable *table); ssize_t virHashSize(GHashTable *table); --=20 2.31.1 From nobody Sun Apr 28 05:42:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1627031167; cv=none; d=zohomail.com; s=zohoarc; b=K6ibtkhEDbxQILLMODtlKxb/F6P1alsIUmwT/M9jvtU5hcKu91fLyYRi6f1tJVQTJgxpeeQ2R6k4ZiDXbRRX+WeQ8hR6//UXsJHJp3q7SU30pTAhnM2qltBRJPAQm1p3SJ9KsmqFTu/WBtBPgH9iO6gYtpGzjcs0l2j3cn40KZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627031167; 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=1aazHKJsdYJmWcrAKJXoCFXvTaMC5rA7yd/XwG9Adik=; b=GOc9K1Jpw53BF53yW7+90u1UjK+3WHxIKvfNm5ZZ2cDe0UXP/rHZMu9e/Xty8U8/QCZZbo+gkmug9c3imACWNZ2a7w9zMcZ2iSKv3mv+Y5sC5UfBYs0T3SxLqfv890Pop7rKMHgW6jKiG7wzCi4Bgn+OXtMU14khmdnDayVSkjs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1627031167235646.1492657506866; Fri, 23 Jul 2021 02:06:07 -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-202-gsuFdHyINMGKVn5tANqY3A-1; Fri, 23 Jul 2021 05:06:04 -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 CE74DEC1A8; Fri, 23 Jul 2021 09:05:59 +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 B306F6E0B7; Fri, 23 Jul 2021 09:05:59 +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 80C1D180BAB2; Fri, 23 Jul 2021 09:05:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16N95wdq019557 for ; Fri, 23 Jul 2021 05:05:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 00F1560853; Fri, 23 Jul 2021 09:05:58 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 614FE60862 for ; Fri, 23 Jul 2021 09:05:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627031166; 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=1aazHKJsdYJmWcrAKJXoCFXvTaMC5rA7yd/XwG9Adik=; b=SInB3YGamaN60mIq5htkSsdKW4WQYDPcNQNccv3jqheg9B+OxAfFFRE3WChlfYav3YS4xe aKuG9y0l6lZnOP9YtIRskV6nr6zbrVvDYKBsVmazkHBkY6D+Q6MRwdqbwL1rDVcWe4XjnR tZbElkVhGIeYbqIazAo92H2WxzN+/Zo= X-MC-Unique: gsuFdHyINMGKVn5tANqY3A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/7] hypervCreateEmbeddedParam: Don't count elements needlessly Date: Fri, 23 Jul 2021 11:05:45 +0200 Message-Id: <9c2fea654362e09b3ca517f95bc1b34b8a4eb965.1627031076.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1627031168738100001 Content-Type: text/plain; charset="utf-8" 'count' is not used after calculating it. Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/hyperv/hyperv_wmi.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index dc2c6471ab..e211fd5d80 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -274,16 +274,11 @@ GHashTable * hypervCreateEmbeddedParam(hypervWmiClassInfo *classInfo) { size_t i; - size_t count; g_autoptr(GHashTable) table =3D virHashNew(NULL); XmlSerializerInfo *typeinfo =3D NULL; typeinfo =3D classInfo->serializerInfo; - /* loop through the items to find out how many fields there are */ - for (count =3D 0; typeinfo[count].name !=3D NULL; count++) - ; - for (i =3D 0; typeinfo[i].name !=3D NULL; i++) { XmlSerializerInfo *item =3D &typeinfo[i]; --=20 2.31.1 From nobody Sun Apr 28 05:42:34 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=1627031232; cv=none; d=zohomail.com; s=zohoarc; b=fh6qJ7fDbc6VysY4q15GyeXgScpwddF4OB1tqfeSqkWVtr2sLsxS5tfwZk2KbTyDdm2SdjKoDvMhAMLRJTLMvTRvRRxi+Re4SpnaQX8pj5MHL6bPNd8k6XVXJ5zLdOOz0Fa00TFnqgoAqfbpC+qtXz4ABLJ/WmaE8vJ7ip4P2FU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627031232; 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=J0xg/dqCUlWCneBdci9dGh+JU22+TJg9zZRRjEq9Ck8=; b=LFVVUfcuutV8yWubtWg66t2OWCX5a2cqQOTgMrSSazHVGJTskukORJONDUjsgDClWk+9deBWZ5loahLdr3q0J5W9cRxPvuo9yvnZ3H4kItkFj08v1TmQGR2mHwON25RWwn3z3wMo0At+utCmcFnl44Opp5jcaSNKffrt9e5mcEo= 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) 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 1627031232415641.7765336248763; Fri, 23 Jul 2021 02:07:12 -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-379-nQCA5JnvOZmNHsEBZSPj_Q-1; Fri, 23 Jul 2021 05:06:11 -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 1927A185302E; Fri, 23 Jul 2021 09:06:03 +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 E7EB0101F965; Fri, 23 Jul 2021 09:06:02 +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 AF9144A7CA; Fri, 23 Jul 2021 09:06:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16N95xe7019566 for ; Fri, 23 Jul 2021 05:05:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0FF0F6F97F; Fri, 23 Jul 2021 09:05:59 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69BDC60853 for ; Fri, 23 Jul 2021 09:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627031231; 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=J0xg/dqCUlWCneBdci9dGh+JU22+TJg9zZRRjEq9Ck8=; b=RMaA89HeRdV7HPXfse/wcj98weDHATydCyN1qwN3biEGP3TgC0b/2CzH0HwkJYWM54ygfn hRqiF8oFLUPzsf6WPZpS4jGUfBenoaIqubnQrDKongvbDvf5yWj5kbMOqHbn9xUoSfP0bA 3QrMo2qWzf8evMyXNjTRt1o+e4DHurQ= X-MC-Unique: nQCA5JnvOZmNHsEBZSPj_Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/7] qemuBlockNodeNameGetBackingChain: Shuffle around variable initialization Date: Fri, 23 Jul 2021 11:05:46 +0200 Message-Id: <1775ee8f86edb194adf18acb1241c758c40feaeb.1627031076.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1627031233635100001 Content-Type: text/plain; charset="utf-8" Allocate the hash tables first so tat the 'data' struct can be directly initialized removing the need for a memset and two additional assignments. Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/qemu/qemu_block.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 8150241015..1bcf7fa4f1 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -230,20 +230,16 @@ GHashTable * qemuBlockNodeNameGetBackingChain(virJSONValue *namednodes, virJSONValue *blockstats) { - struct qemuBlockNodeNameGetBackingChainData data; g_autoptr(GHashTable) namednodestable =3D virHashNew(virJSONValueHashF= ree); g_autoptr(GHashTable) disks =3D virHashNew(qemuBlockNodeNameBackingCha= inDataHashEntryFree); - - memset(&data, 0, sizeof(data)); + struct qemuBlockNodeNameGetBackingChainData data =3D { .nodenamestable= =3D namednodestable, + .disks =3D disks = }; if (virJSONValueArrayForeachSteal(namednodes, qemuBlockNamedNodesArrayToHash, namednodestable) < 0) return NULL; - data.nodenamestable =3D namednodestable; - data.disks =3D disks; - if (virJSONValueArrayForeachSteal(blockstats, qemuBlockNodeNameGetBackingChainDisk, &data) < 0) --=20 2.31.1 From nobody Sun Apr 28 05:42:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1627031171; cv=none; d=zohomail.com; s=zohoarc; b=SdFFm/Q/kXGxLn9HNDGXRQysc75vzFzQhicf3OSxVQJ4ojvt3A4FKlDJu8W/bPBAqtU7PUIKf1pNrJGp5OVrwkFLmpkzvTkQ9Ciz8/Rq9c8hU0Cxqeu+hLRFGy69eKkV53sBweKFbqRmSzvzNYUoAhNHlX4cF97u+Khn09xybbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627031171; 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=22ipToYeUhwWm7nZwmt0bm88gNmeDQdy0vV4BknmaMg=; b=SwS+eVms2Vpk0v8gDDcvwA3gBg7XeWC6vV0k+RUygnSntnge3/JlQnjLMXCjM1MCPVzpbKzy0asJTqtgm1u+ALxToFke4jpivSfQcTtEho3GEbdrtOzkNgALXFL53Cs8mAlABgXPJ6+lvcCt94admQ3Pf3Ih2NeZCEE9i2QSKmQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1627031171646821.8674173012276; Fri, 23 Jul 2021 02:06:11 -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-582-sGrA-ChdMziPWhjG6S-JEA-1; Fri, 23 Jul 2021 05:06:08 -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 E39738799F3; Fri, 23 Jul 2021 09:06:02 +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 BBEE699BD; Fri, 23 Jul 2021 09:06:02 +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 8496B180BAD0; Fri, 23 Jul 2021 09:06:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16N960FS019571 for ; Fri, 23 Jul 2021 05:06:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1651260862; Fri, 23 Jul 2021 09:06:00 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78FBE60853 for ; Fri, 23 Jul 2021 09:05:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627031170; 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=22ipToYeUhwWm7nZwmt0bm88gNmeDQdy0vV4BknmaMg=; b=bGJywCC4vaCxRT72wW2sJbJVYItugNV+rpZUu9vsuWjjrBhSp9OX+wSJGC+fivmic9y5QO i4TxFXF6/Fh/VlMTvaxkkNSmsieR01b4ur6zkqL1qcTio5HL3uQxfRB1zZPj2GtqeX9BdV NPVXs2Yy5UN1JWvyYHm9i5M+hY7ozOI= X-MC-Unique: sGrA-ChdMziPWhjG6S-JEA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/7] virDomainDefValidateAliases: Refactor to avoid cleanup section Date: Fri, 23 Jul 2021 11:05:47 +0200 Message-Id: <247933d0620b9feb6ae9302af37dbceb450dc065.1627031076.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1627031172724100001 Content-Type: text/plain; charset="utf-8" Use a temporary auto-freed local variable to hold the hash table so that the cleanup section can be removed. Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/conf/domain_validate.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index aab377fbbd..a9e4519b1a 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1257,25 +1257,20 @@ static int virDomainDefValidateAliases(const virDomainDef *def, GHashTable **aliases) { - struct virDomainDefValidateAliasesData data; - int ret =3D -1; - /* We are not storing copies of aliases. Don't free them. */ - data.aliases =3D virHashNew(NULL); + g_autoptr(GHashTable) tmpaliases =3D virHashNew(NULL); + struct virDomainDefValidateAliasesData data =3D { .aliases =3D tmpalia= ses }; if (virDomainDeviceInfoIterateFlags((virDomainDef *) def, virDomainDeviceDefValidateAliasesI= terator, DOMAIN_DEVICE_ITERATE_ALL_CONSOLES, &data) < 0) - goto cleanup; + return -1; if (aliases) - *aliases =3D g_steal_pointer(&data.aliases); + *aliases =3D g_steal_pointer(&tmpaliases); - ret =3D 0; - cleanup: - virHashFree(data.aliases); - return ret; + return 0; } --=20 2.31.1 From nobody Sun Apr 28 05:42:34 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=1627031174; cv=none; d=zohomail.com; s=zohoarc; b=f+oq+BGftmnnzT26ux+HOWuMTG8x1hxQU6r1zBgpix4rbAzNpqZfh/ZivmExZ55sWfy957EgnWv3zc+gMGuHhMQ6DVSL/tGRzaURDBxJMvKFcFMjj/lYmm5ntpAqeUzO2AhCpEJMnTSX0rBW75vEuHY783qV++yfl4IWMF0VLe4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627031174; 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=lXbjhxDLMGKQmnwNI2pYIR8RmXCZvVB4abI6nqfbul4=; b=kRGe6LASyO7ZzTLJMz3wOEk9IYYpCcSzbVCf8uvNdxI+VFkjz0u60tTOF2a1QhdCCcayIz6m50QjBYzuHUkU/RUY3QzxCyj78HZ/4z4G9YGBdvUAc/SFzSXg0DyYCsSbcIMyjyngxzySGj8ooUm1SSUGQoj+aYePysyRxswLx+4= 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) 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 1627031174101738.4359007978017; Fri, 23 Jul 2021 02:06:14 -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-559-SxDZ-sAiONGXDNQ1VbQ_jg-1; Fri, 23 Jul 2021 05:06:11 -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 031C41084F5D; Fri, 23 Jul 2021 09:06:06 +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 D1FE35C23A; Fri, 23 Jul 2021 09:06:05 +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 91100180140E; Fri, 23 Jul 2021 09:06:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16N9615o019577 for ; Fri, 23 Jul 2021 05:06:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1E45960853; Fri, 23 Jul 2021 09:06:01 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76E7760862 for ; Fri, 23 Jul 2021 09:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627031173; 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=lXbjhxDLMGKQmnwNI2pYIR8RmXCZvVB4abI6nqfbul4=; b=iVCBP+epDJppJk0C8BO+i2wncgcNI7Ye9xZqUM5VvmMTlviNHwrtbgBx8hWIPak+ksk6Dq Q/q7htdDFQucGO6SH6VLhw3V0kWbakjddI9JbTwUD03ijQYFx4RUIa1PSK4UzIdMLOIGGe TdQXqLftPI4tTtyncUemWZuuRaY5GJU= X-MC-Unique: SxDZ-sAiONGXDNQ1VbQ_jg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/7] virNetworkObjNew: Remove impossible error handling Date: Fri, 23 Jul 2021 11:05:48 +0200 Message-Id: <0c508af20ad8afe089e38eafca5e4648f1dc445b.1627031076.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1627031174835100003 Content-Type: text/plain; charset="utf-8" 'obj->classIdMap' is a bitmap with size of '16', thus the first 3 bits are guaranteed to be available. Use 'virBitmapSetBit' instead of 'virBitmapSetBitExpand' since we don't need any expansion and ignore errors as they are impossible. Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/conf/virnetworkobj.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index ea021892c7..2a2d94dc98 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -112,21 +112,16 @@ virNetworkObjNew(void) obj->classIdMap =3D virBitmapNew(INIT_CLASS_ID_BITMAP_SIZE); - /* The first three class IDs are already taken */ - if (virBitmapSetBitExpand(obj->classIdMap, 0) < 0 || - virBitmapSetBitExpand(obj->classIdMap, 1) < 0 || - virBitmapSetBitExpand(obj->classIdMap, 2) < 0) - goto error; + /* The first three class IDs are already taken. */ + ignore_value(virBitmapSetBit(obj->classIdMap, 0)); + ignore_value(virBitmapSetBit(obj->classIdMap, 1)); + ignore_value(virBitmapSetBit(obj->classIdMap, 2)); obj->ports =3D virHashNew(virNetworkObjPortFree); virObjectLock(obj); return obj; - - error: - virObjectUnref(obj); - return NULL; } --=20 2.31.1 From nobody Sun Apr 28 05:42:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1627031225; cv=none; d=zohomail.com; s=zohoarc; b=HdE99bkL82OWEMlYpV9Q2mAT+xSOc9iUhipX4iTJnH3RqOcEkAfRkBwZkmVl88RiVxSSEKltMathBxMWhU0aixB+yKKFuWRM5vHoUlaAHU2wt4Ppd/hyPc44dbVSDjqbYOXBw5v1Q8iqT3hQ+9tb0rBPY65hSPrOKfHCDW7RhyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627031225; 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=nE1dch/z/0I0h/eUvlKMiMDsZvRhq2wDUQcAGEA0MPM=; b=ZuNYHVrhWSdottQTDIAlq4wVFxxHxxVSBZmTuqYIuEh3dIxseY1Xuvu7P7UuDntuCqAEFRuxKjAoMNiF3+Em17p2YpydWOn4PV/XVjTS36SROE+C5Cmf52i9EyW1fRby7zGA2rrNSLHAnXooJr+qLZF7H4d2iQveKrQBGH2RBtY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1627031225956976.2631500920244; Fri, 23 Jul 2021 02:07: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-439-vd65OiRJMMKvJXQUOTq-XQ-1; Fri, 23 Jul 2021 05:06:14 -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 198A6801AE3; Fri, 23 Jul 2021 09:06:09 +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 E98531A86F; Fri, 23 Jul 2021 09:06:08 +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 B3CE74A705; Fri, 23 Jul 2021 09:06:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16N962p9019582 for ; Fri, 23 Jul 2021 05:06:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 23B9C6A056; Fri, 23 Jul 2021 09:06:02 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86A9660853 for ; Fri, 23 Jul 2021 09:06:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627031224; 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=nE1dch/z/0I0h/eUvlKMiMDsZvRhq2wDUQcAGEA0MPM=; b=JTNpqBQ9dY0VI9WW4GP/SfFFvZPkDmACf/9RK+Y0OL8w7ljyYt2j3jdH1TVrt+N59y7ut8 56dJ4aopq/io5+4ao080I0voV27cjQGYyj1Rx7uVaAJuPk1gW1NuefJoJer2ffKffeuH04 GOCdA1KrMOFyGO2UguYMfNGDVS9BRk8= X-MC-Unique: vd65OiRJMMKvJXQUOTq-XQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/7] qemu: domain: Move qemuDomainObjPrivateAlloc after qemuDomainObjPrivateFree Date: Fri, 23 Jul 2021 11:05:49 +0200 Message-Id: <4450dbd0311da677eeb199f54ce80c48c588410d.1627031076.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1627031227115100001 Content-Type: text/plain; charset="utf-8" The freeing function will be needed to undo failures in allocation. Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/qemu/qemu_domain.c | 61 +++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b919da6eab..8d1ecc0140 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1772,36 +1772,6 @@ qemuDomainObjStopWorker(virDomainObj *dom) } -static void * -qemuDomainObjPrivateAlloc(void *opaque) -{ - qemuDomainObjPrivate *priv; - - priv =3D g_new0(qemuDomainObjPrivate, 1); - - if (qemuDomainObjInitJob(&priv->job, &qemuPrivateJobCallbacks) < 0) { - virReportSystemError(errno, "%s", - _("Unable to init qemu driver mutexes")); - goto error; - } - - if (!(priv->devs =3D virChrdevAlloc())) - goto error; - - priv->blockjobs =3D virHashNew(virObjectFreeHashData); - - /* agent commands block by default, user can choose different behavior= */ - priv->agentTimeout =3D VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK; - priv->migMaxBandwidth =3D QEMU_DOMAIN_MIG_BANDWIDTH_MAX; - priv->driver =3D opaque; - - return priv; - - error: - VIR_FREE(priv); - return NULL; -} - /** * qemuDomainObjPrivateDataClear: * @priv: domain private data @@ -1922,6 +1892,37 @@ qemuDomainObjPrivateFree(void *data) } +static void * +qemuDomainObjPrivateAlloc(void *opaque) +{ + qemuDomainObjPrivate *priv; + + priv =3D g_new0(qemuDomainObjPrivate, 1); + + if (qemuDomainObjInitJob(&priv->job, &qemuPrivateJobCallbacks) < 0) { + virReportSystemError(errno, "%s", + _("Unable to init qemu driver mutexes")); + goto error; + } + + if (!(priv->devs =3D virChrdevAlloc())) + goto error; + + priv->blockjobs =3D virHashNew(virObjectFreeHashData); + + /* agent commands block by default, user can choose different behavior= */ + priv->agentTimeout =3D VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK; + priv->migMaxBandwidth =3D QEMU_DOMAIN_MIG_BANDWIDTH_MAX; + priv->driver =3D opaque; + + return priv; + + error: + VIR_FREE(priv); + return NULL; +} + + static int qemuStorageSourcePrivateDataAssignSecinfo(qemuDomainSecretInfo **secinfo, char **alias) --=20 2.31.1 From nobody Sun Apr 28 05:42:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1627031175; cv=none; d=zohomail.com; s=zohoarc; b=fjCrYCUd2yXUR5NER6oMhj2Eo7tbGWLpUElomBrhAiO/3tp0SqzBL4r9FUcMn7blspanMnfAec8MoMBAClAz2ODVXbXsV6IRB1jmARyEH8RzkMAxnlvB/GHgC//kZeXOVYL0NQUTCQ0+XihyRuN58djwyJGc+ub2ka78wDacmbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627031175; 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=aHsi/z88XTX37BzBxPwB5xsGcVXCuUNAJX0dZpKD+mc=; b=SHugPWuy9HlwpqnFrDBHBsvQ4T9KR+PXkN3actUkMDOXSwBM+JRjyRHLCeGQ2EZrUvHXOxm1Xs3WaphEZXRjlV7wa907kEUSlqppWXSIbNm3IotWEmmCgXrHVhzPYSV53p++KQ14Wb163GKzwSJw0Vz57enRx0bLDoVNQXCziec= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 162703117596552.85702968442274; Fri, 23 Jul 2021 02:06:15 -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-570-IeDW0l4ePSW954dWngucLA-1; Fri, 23 Jul 2021 05:06:13 -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 B137C800EB8; Fri, 23 Jul 2021 09:06:07 +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 951A5604CC; Fri, 23 Jul 2021 09:06:07 +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 607C64A7CB; Fri, 23 Jul 2021 09:06:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16N963Zn019594 for ; Fri, 23 Jul 2021 05:06:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 27F7460939; Fri, 23 Jul 2021 09:06:03 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8364560853 for ; Fri, 23 Jul 2021 09:06:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627031175; 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=aHsi/z88XTX37BzBxPwB5xsGcVXCuUNAJX0dZpKD+mc=; b=cxZWp1jhZzZ9POOxcLUT2ha+JOHp1Jt0Qvt7Ce7Y+QVLJ3zpIrYn4AsDERHkhN4C9mQNqS Wdh7wrrIrgymeza0yohgYfnFzU2GNY/0S4HQeDwRYINrjwVw48EtxvnnxRFt2kxiYvyFuV FuMpTbRssE9iv8kMhT9Chf0gdLtqfhk= X-MC-Unique: IeDW0l4ePSW954dWngucLA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 7/7] qemuDomainObjPrivateAlloc: Fix unlikely memory leak Date: Fri, 23 Jul 2021 11:05:50 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1627031177186100001 Content-Type: text/plain; charset="utf-8" Additional cleanup paths add the possibility of not freeing earlier stuff. Add an AUTOPTR handler for qemuDomainObjPrivate and use it in qemuDomainObjPrivateAlloc Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/qemu/qemu_domain.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8d1ecc0140..7e2efc8168 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1891,22 +1891,22 @@ qemuDomainObjPrivateFree(void *data) g_free(priv); } +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuDomainObjPrivate, qemuDomainObjPrivateFr= ee); + static void * qemuDomainObjPrivateAlloc(void *opaque) { - qemuDomainObjPrivate *priv; - - priv =3D g_new0(qemuDomainObjPrivate, 1); + g_autoptr(qemuDomainObjPrivate) priv =3D g_new0(qemuDomainObjPrivate, = 1); if (qemuDomainObjInitJob(&priv->job, &qemuPrivateJobCallbacks) < 0) { virReportSystemError(errno, "%s", _("Unable to init qemu driver mutexes")); - goto error; + return NULL; } if (!(priv->devs =3D virChrdevAlloc())) - goto error; + return NULL; priv->blockjobs =3D virHashNew(virObjectFreeHashData); @@ -1915,11 +1915,7 @@ qemuDomainObjPrivateAlloc(void *opaque) priv->migMaxBandwidth =3D QEMU_DOMAIN_MIG_BANDWIDTH_MAX; priv->driver =3D opaque; - return priv; - - error: - VIR_FREE(priv); - return NULL; + return g_steal_pointer(&priv); } --=20 2.31.1