From patchwork Wed Feb 12 21:32:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 864495 Delivered-To: patch@linaro.org Received: by 2002:a5d:47a6:0:b0:38f:210b:807b with SMTP id 6csp138776wrb; Wed, 12 Feb 2025 13:37:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUsruyKOAzHk/9FlpS6fSYktwoOqYk8snOiuFhBxT6IQYOGpT6QshXzc7MKwq3rPuv09M8CCA==@linaro.org X-Google-Smtp-Source: AGHT+IHSS5aP5MI60YCA0lb7P7hgJi/Z6tZHBQKDLEUYygGPUM2aF+prabLQzyW0xilY723AgJq3 X-Received: by 2002:a05:620a:410a:b0:7b6:db05:1435 with SMTP id af79cd13be357-7c06fc56463mr711733685a.10.1739396261963; Wed, 12 Feb 2025 13:37:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739396261; cv=none; d=google.com; s=arc-20240605; b=GjHkaN35jP3EB/M81dd//ImlcGhlIiqtgCJ3ZzPM+Kovn6p5yBuWoqTvDwid8ukZM3 34/t3Uuc7TkgXFs9Sk+WFBylj+DMwwf4XMJBDi64571t7ti1VDT4YdZnP4WVnspFwqez cYd1sa2l/H/57Lg5+nTMQBylY3HaI1Lxb5keUJToA7pSfM+aYqLkkv/UhpygkOSBAN7z QuJ9TnIIC5JGp1C3vNjweKGQXD9nAJ/e23Ha0LNWmr6jjBBQyhP39bI5jHKUDDdsfdEx JyJ2hN5wevjBFRSMUQiGhmFOBKwgVE3lvGCzwdo5mFsvNTKiQbz7v3ZrlOaZQzd/ptmR 2OmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xO6SV4w4GEb/p1wdkem/NKWYVecHNr9NrkbEfMoLTPg=; fh=fz3DJMUXEzejNv0JWYQ+xa02BmrDN+/I7HIv5ot61VY=; b=OCd3p0Yj8Eho6JF8d+B+frD2RA7ISDmg1MTDTx6UtdevVa/oYAvqb44lQkFR2f7Uyp x4Tj9P18DR+4y7EBJWIGS+zC7WkUZsZ0PxOaSNtilMDs/RyswCNrTpWcs16MAcaGogNy IjV5qK7/qEMQ9X2DStdre895JnqkSqYCiD31y7s76zydWT6bY9i+2DPmfzKOGsRfdMNt /MKFI0mP/zbRcITHs8nIyw99yqIik3KUcW8Ubw5OB+pLIlBu8Zt2eGPG/8ZP/du18+3Z y3/i+fYEJJVzp3E6DEtJt/kuSe5D6E6hhQJ7YAq4ekSQbtkzm2vFGdeN73+UTurycCJH NZhQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WUn6rzUw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c07a622a4esi46061185a.562.2025.02.12.13.37.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Feb 2025 13:37:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WUn6rzUw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tiKN7-0004C3-3O; Wed, 12 Feb 2025 16:34:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tiKMz-0003rH-NB for qemu-devel@nongnu.org; Wed, 12 Feb 2025 16:34:11 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tiKMx-0000YS-Qx for qemu-devel@nongnu.org; Wed, 12 Feb 2025 16:34:09 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-43956e3863eso1887285e9.2 for ; Wed, 12 Feb 2025 13:34:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739396045; x=1740000845; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xO6SV4w4GEb/p1wdkem/NKWYVecHNr9NrkbEfMoLTPg=; b=WUn6rzUwepyyYHBsIIqaamu7YHpdS3EiGlZIt6HXU/WoqcjNBO9TQnipxF6V3DMN4e 1i/FFSvDhyxUF+bbSz1Vz6bOZrbx3tIaLm1DIy54z9ob+s2zwMptODPGKYKJmmtyiT7/ AoNUfkLDEYCzhUW9EU6tHW8bO4bYPz/oZ84m0hwhS6oCo662hj/raD4QpRn2P59VpR12 EC0KpnFQJy492cN9dWiT07o72HdSac6k14e1d+IiYiin/v2xz9mjXEctYMK9jITxj53L praqgdZODpyktK/d1wq/d0gDgc7eufsxBYftPjVsalZ54Clfavs9UDJU5bKvCPamw9jM aDyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739396045; x=1740000845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xO6SV4w4GEb/p1wdkem/NKWYVecHNr9NrkbEfMoLTPg=; b=Rb2aLN1hmdgY2aCtwL85Cw5J78nizCwqGkVsLrz2D3GpSd1+2PzrzzTci4xNwLcQEo d3tXWyx2mNqeWleG1XC2euqVGzI2nMxsnt6eUDt9D/Hd6uA0QbEGeKpmSGmHrwM4N8iX EcYdWRDY59NpNMb0I5D0C9jcvI0/9Hkrvue9C4cEi6dnGiAROgvfQbhQFoD6ap5aoxgY KOXchPMSCFkIvY2ji8uVoeBFgJdGiHmsuh9wQBy18mt84SIuoMipq9Co29isWE72S1tB AFWjMr+GP2qWIVguLDAv+S80D+TxhN4YzfFxmgeHuGUCk+Xv9b1p58BNt/202Fh8BbgW P6Qw== X-Gm-Message-State: AOJu0YwFp9XztGOQV5m/0Fv6vCFuO4ZHo2REV9BrfX6zXf25HApllTf7 1JYa4/Hvk5rkuRDDnLdXwwtfLQCEfldS955ORGHroMyRVDmV159AKk+xGJ7U+oultzinRLLzCkb mYgY= X-Gm-Gg: ASbGncuupjvBgkDMw7nz0fI7+foT244QoA0EGz37vN0XH5w/I1N1v+tBZ8ZF5QZvvJG EQsIgSqcWXTXilm/d1ivg8dYb66AqDBfbgF4kDNi1Ld935wknjcMU1efRzYxCTXpg9Ek+izMFFI IFypH9fuQvNrRcnxTOhNjA5sdTWKvaBYU1yS5M4xmjnfSDqKzMSbmt3AxRYqaBOTJ4QSrK5HzpQ GHyJgM5c74QsIvoEdZS5o/18dteaT+objdeqBpHBWIzRxwzQiIWTKTCzv48rxe106u8WTpL74OF 1PaZqmcJW2kdiAJweNjiAWVC/MnU8jM9pf/jZhf7aIOD145OaXtVKjX9+yZw+yA9NA== X-Received: by 2002:a05:600c:3b9a:b0:439:33dd:48ea with SMTP id 5b1f17b1804b1-4395815f6f3mr46065155e9.2.1739396045229; Wed, 12 Feb 2025 13:34:05 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4395a058930sm31109815e9.17.2025.02.12.13.34.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 12 Feb 2025 13:34:04 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH v3 14/19] hw/virtio/virtio-pci: Do not access base_type_info.name directly Date: Wed, 12 Feb 2025 22:32:44 +0100 Message-ID: <20250212213249.45574-15-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250212213249.45574-1-philmd@linaro.org> References: <20250212213249.45574-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org base_type_info.name is initialized to t->base_name, check that directly. Signed-off-by: Philippe Mathieu-Daudé --- hw/virtio/virtio-pci.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index ad1d164421d..9512590c936 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -2476,7 +2476,7 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t) ? g_strconcat(t->generic_name, "-base-type", NULL) : NULL; TypeInfo base_type_info = { - .name = t->base_name, + .name = t->base_name ?: base_name, .parent = t->parent ? t->parent : TYPE_VIRTIO_PCI, .instance_size = t->instance_size, .instance_init = t->instance_init, @@ -2487,7 +2487,7 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t) }; TypeInfo generic_type_info = { .name = t->generic_name, - .parent = base_type_info.name, + .parent = t->base_name, .class_init = virtio_pci_generic_class_init, .interfaces = (const InterfaceInfo[]) { { INTERFACE_PCIE_DEVICE }, @@ -2499,8 +2499,7 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t) assert(t->base_name || !t->non_transitional_name); assert(t->base_name || !t->transitional_name); - if (!base_type_info.name) { - base_type_info.name = base_name; + if (!t->base_name) { base_type_info.class_init = virtio_pci_generic_class_init; generic_type_info.parent = base_name; @@ -2519,7 +2518,7 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t) if (t->non_transitional_name) { const TypeInfo non_transitional_type_info = { .name = t->non_transitional_name, - .parent = base_type_info.name, + .parent = t->base_name ?: base_name, .instance_init = virtio_pci_non_transitional_instance_init, .interfaces = (const InterfaceInfo[]) { { INTERFACE_PCIE_DEVICE }, @@ -2533,7 +2532,7 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t) if (t->transitional_name) { const TypeInfo transitional_type_info = { .name = t->transitional_name, - .parent = base_type_info.name, + .parent = t->base_name ?: base_name, .instance_init = virtio_pci_transitional_instance_init, .interfaces = (const InterfaceInfo[]) { /*