From nobody Sun Feb 8 17:36:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1576853993; cv=none; d=zohomail.com; s=zohoarc; b=dRVkmxb9pnzsjicBFXsFVvpXQAua0fIpTupm93a2Rq450ntnFEcA4oF9bLTIM4hslr7dwNDa+qMzIU4OgeEmt1ifoSgrhJc84Q2pPhsRKDk9KZGZb4nZ9vWj7Rf4fN9EsEoGfNYmLKteFF653E4q7tTVJ+vI1rZ38EsANGbykiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576853993; 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=DvUsGvLHu6tINuFiQJE2Ao3YhrMcjDoMcCOltD/TKOI=; b=JGBhtJiwnaN3nNriIkCpjSnnthPvSUkCqCkyQAE452h5ZeCG4i/oDOLL+l+UsQvTdlsr0ZKKP8zUpFe4ygkCY4M5JjJ8yOeomTLLep/Hb8hZnaBCzI4b/T2Bj/AyFjLSxStmzL14rZkx1wM9ab0OWi/2+AAL4PuF+yH9nnVueSM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1576853993785371.7329904271652; Fri, 20 Dec 2019 06:59:53 -0800 (PST) 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-186-T2RISlhjO5-yqQZ4c-pPYA-1; Fri, 20 Dec 2019 09:58:51 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 406672F2B; Fri, 20 Dec 2019 14:58:46 +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 1BD0960BF3; Fri, 20 Dec 2019 14:58:46 +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 C9A361808878; Fri, 20 Dec 2019 14:58:45 +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 xBKEwRUS032547 for ; Fri, 20 Dec 2019 09:58:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4BC446FDCE; Fri, 20 Dec 2019 14:58:27 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C805E6E41E for ; Fri, 20 Dec 2019 14:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576853992; 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=DvUsGvLHu6tINuFiQJE2Ao3YhrMcjDoMcCOltD/TKOI=; b=DSXSBG5/iOhp29TH3aavLxnnCKnxj1fvEbptsVdss8B0+kqpKpoIQRnmTOtPi1GTmdzgzV l2IjgMARuCOZfx1J/HSBlFt3SyIDahdTUHMs4NHwUZUJFNseQY4urzMnk+tpL+bZm/EppS lICMHDS67E72Wjo8LqvVKxk77U7DPC4= From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:58:10 +0100 Message-Id: <20191220145813.756206-9-ptoscano@redhat.com> In-Reply-To: <20191220145813.756206-1-ptoscano@redhat.com> References: <20191220145813.756206-1-ptoscano@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 08/11] esx: generator: fix free of elements in lists 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.12 X-MC-Unique: T2RISlhjO5-yqQZ4c-pPYA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When a list is freed, we iterate through all the items, invoking the free function for each; the actual free function called for each element is the function of the actual type of each element, and thus the @_next pointer in the element struct has the same type as the element itself. Currently, the free function gets the parent of the current element type, and invoke its free function to continue freeing the list. However, in case the hierarchy of the classes has more than 1 level (i.e. Class <- SubClass <- SubSubClass), the invoked free function is only the parent class' one, and not the actual base class of the hierarchy. To fix that, change the generator to get the ancestor of a class, and invoking that instead. Also, avoid to set the @_next back, as it is not needed. Fixes commits 5cff36e39ae691fbd7c40597df1732eecf294150 and f76c6dde2e33233566e886d96e76b5fe0c102d9a. Signed-off-by: Pino Toscano --- scripts/esx_vi_generator.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/esx_vi_generator.py b/scripts/esx_vi_generator.py index 048f5dde9e..9e3151943b 100755 --- a/scripts/esx_vi_generator.py +++ b/scripts/esx_vi_generator.py @@ -751,13 +751,13 @@ class Object(GenericObject): source +=3D "{\n" =20 if self.features & Object.FEATURE__LIST: - if self.extends is not None: + ancestor =3D get_ancestor(self) + if ancestor: # avoid "dereferencing type-punned pointer will break # strict-aliasing rules" warnings - source +=3D " esxVI_%s *next =3D (esxVI_%s *)item->_nex= t;\n\n" \ - % (self.extends, self.extends) - source +=3D " esxVI_%s_Free(&next);\n" % self.extends - source +=3D " item->_next =3D (esxVI_%s *)next;\n\n" % = self.name + source +=3D " esxVI_%s *baseNext =3D (esxVI_%s *)item->= _next;\n" \ + % (ancestor, ancestor) + source +=3D " esxVI_%s_Free(&baseNext);\n\n" % ancestor else: source +=3D " esxVI_%s_Free(&item->_next);\n\n" % self.= name =20 @@ -1250,6 +1250,21 @@ def is_known_type(type): type in enums_by_name) =20 =20 +def get_ancestor(obj): + if not obj.extends: + return None + ancestor =3D None + try: + ancestor =3D ancestor_by_name[obj.extends] + except KeyError: + parent =3D objects_by_name[obj.extends] + ancestor =3D get_ancestor(parent) + if not ancestor: + ancestor =3D parent.name + ancestor_by_name[name] =3D ancestor + return ancestor + + def open_and_print(filename): if filename.startswith("./"): print(" GEN " + filename[2:]) @@ -1346,6 +1361,7 @@ managed_objects_by_name =3D {} enums_by_name =3D {} methods_by_name =3D {} block =3D None +ancestor_by_name =3D {} =20 =20 # parse input file --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list