From patchwork Wed Dec 18 13:42:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 851685 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp922336wrq; Wed, 18 Dec 2024 05:44:26 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUIvOeXf6AIAFo+4iOL57kVNkmPT/1i1Pe2YU4/0810yTBayVSRZJkOfkb91eE/g+mlfw1rtQ==@linaro.org X-Google-Smtp-Source: AGHT+IGlOalqsruuy74Y3IFRios22HbG82tnbm4dzcKQBw8hLZ8lZ75l9VRaaCIYg2VFmnX3yAsN X-Received: by 2002:ad4:4ee7:0:b0:6d8:88f2:b4d9 with SMTP id 6a1803df08f44-6dd0918a444mr52743056d6.3.1734529466261; Wed, 18 Dec 2024 05:44:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734529466; cv=none; d=google.com; s=arc-20240605; b=LJq75yw1K8jAnSI/3gDS6hRxojYLFn+t3Uep6ibhgWWENI39Eng+Fvtl6XOPBWGIsF kv/fziocVKRwui1xjxmDr/BKSvBgz/P9dvOFuENKbZvxUrcWvk2F4O0027QdpWHcvl7k uyIam7S2ALElTtGTDr13m1DhytuWpEapyYU9VwfPd5e9D2XBDBQw9OKCrSyIi6snkjMg 5V9nLVHbG7HEJSt8zfSn4T4c7mTBgST0WSdI4Iri9yM/sy5sdJDT4cK+Rhrorgmj6GTX cugCkYXrNAuByLPff7x5bn9NwkcAajtS/339iZSaC4bxPiR9NUajGJu5Bz49ca13shMO KnBQ== 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=B3IR2BqpFJt9aWmYFdrw1drrXTVRXnm5WkItRBYentE=; fh=3mEp7FusppN5Drq2PN08R8D/9xXM9YdbtG5TkJxJBiE=; b=NtjugrXoA48MLYqlfLGKIjMJnZuWYYDhn9Iu7LntDIvorpUlIIRUc2wlByrnpPiqUY ezv/TVjbSXKPGEJFz4p9veOPoYYQ+r8IxMYcnadQGNYH8bMtkiJUGWq0FMXk7/3av1Ol bp1s4+ZiGWrBMfIbwL8glHCc1JTLajM1K8skEXYsnjBqHb4ueUss3wxeKM8Zqv7poyXF 7u/FFFvh05+xoirvnnGQGFoYuyR320VadTmiUwTzC0pjAaNV7p051SuJgliVROQCwR3x Ep7Nhmz+6XXSXGqADBCk2sM17IEaJyVBDZvT93H6L+6vO3YlJ/A3oBWnbJqbWEFCbo8U Nnug==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rX0GlPMo; 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 6a1803df08f44-6dccd34dec0si121323086d6.254.2024.12.18.05.44.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Dec 2024 05:44:26 -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=rX0GlPMo; 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 1tNuKz-0001tM-LG; Wed, 18 Dec 2024 08:43:42 -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 1tNuKg-0001QH-AD for qemu-devel@nongnu.org; Wed, 18 Dec 2024 08:43:25 -0500 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tNuKd-0005hk-V5 for qemu-devel@nongnu.org; Wed, 18 Dec 2024 08:43:21 -0500 Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-3eba347aa6fso3483028b6e.3 for ; Wed, 18 Dec 2024 05:43:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734529399; x=1735134199; 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=B3IR2BqpFJt9aWmYFdrw1drrXTVRXnm5WkItRBYentE=; b=rX0GlPMoqa+NUnZGJhUamwsKRuKb4p9IAskQfsVyucmTTN8rDSs1O2+hCZPp+jcHBi +oQlE2s+Qd+k5ZA+3ekluHu5fxovEyKPMN0YtQnzWYSGbwR4MmCcXIRWIYPzA5nayANA NswZa5ItpCuuqMVfyu1L2qZ6efh6qkjVsoGfPlyuzHb4bPipQpVRr7INBc6PiXN6Gt5A kQy3CxLsrc55rG2UEaGbG9MaRYjijdS6QXy2+qljtTf7fBiIaStGaLw66uibfCpx/EYO uUhmkAyx49dyxqjy5mnvQhmFaI0Ux71I8/kH+IJXm8VSmTN5CpGgnpFlI/EMtKGkYuLq IwkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734529399; x=1735134199; 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=B3IR2BqpFJt9aWmYFdrw1drrXTVRXnm5WkItRBYentE=; b=NO0FpzGAJGwNbKNPzZPxWoKpkGhpc+RkeQMZIkyCuMRUtX1V7wkteiqJ00GOvTtDNC 7dTCCM/5IrJ9lv7dFFM6ozSeXwMkX8ZbX47zPgAoB+sq9w2s/uYfD+m5wGo35kKe6JGd Cr9VzrIaafjUDrbjgrDldMaPk+eoneXvet9/f/5ZOxcA8FquKFIVw/DU3JDxhkYDxQKk tXXM6MySxF6GMzjT+x5rRe1OE8Ak1kuHDM+9RP1x7R1lekpTqA9wPEMH7d66vZ306MkO aLXHPhB5FOflxtvpzAXbpfvZ4xWSMZ3itjpf6XImGBVT9t0fsDRkhUyy/RSlrawN1/tA RvlQ== X-Gm-Message-State: AOJu0YzoQuNrIDzrFJoIxhzzsPzAOCE24uJ/KtsP98pJp63slqbgieYU AOdgqrBi+JImxPTPEMa0Hk1kdK+UJMfH2bOVAI+l+03huD+t6ULs/8xXA4Cq27CrRSQ+WElR6F7 KdeL8S4wN X-Gm-Gg: ASbGnctQWt1zP5j5L4v44x+XB0K8QFeA6NLqotTLwSs8KFM9s1edGw6HgA8vENgzqwl 5ioLJrv6VyZdvgj6y94oE5rt6K256VLfMrOH5f7q96ug4Q3/Mu2JIEomBUpuYWAF501l0+Rhggq Yan9aSyjSP5+6te5Se6kYEQ5ftsDvUpHNSZkK0+HQ78x02/bw06N5fP9b7gPXt9iP2O0ohos/Mi s04NJKgd9m4u7xhA8jz570VhMkNfqMY0smnp8FLg642iG1NA0fV8fAxgia2k9n8 X-Received: by 2002:a05:6808:1a02:b0:3ea:66c3:d066 with SMTP id 5614622812f47-3eccbf2e273mr1678231b6e.7.1734529398744; Wed, 18 Dec 2024 05:43:18 -0800 (PST) Received: from stoup.. ([187.217.227.247]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3ebb478a502sm2870951b6e.9.2024.12.18.05.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 05:43:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com Subject: [PATCH v2 18/24] hw/core: Remove device_class_set_props function Date: Wed, 18 Dec 2024 07:42:45 -0600 Message-ID: <20241218134251.4724-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218134251.4724-1-richard.henderson@linaro.org> References: <20241218134251.4724-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::232; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x232.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 All uses of device_class_set_props() are now using arrays. Validate this compile-time in the device_class_set_props macro and call device_class_set_props_n using the known size of the array. Signed-off-by: Richard Henderson --- include/hw/qdev-core.h | 16 ++++++---------- hw/core/qdev-properties.c | 16 ---------------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index e9b4891f55..fc13623d43 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -948,22 +948,18 @@ char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev); * To modify an inherited property you need to use???? * * Validate that @props has at least one Property plus the terminator. + * Validate that @props is an array via ARRAY_SIZE. * Validate that the array is terminated at compile-time (with -O2), * which requires the array to be const. */ -void device_class_set_props(DeviceClass *dc, const Property *props); - #define device_class_set_props(dc, props) \ do { \ - QEMU_BUILD_BUG_ON(sizeof(props) != sizeof(const Property *) && \ - sizeof(props) < 2 * sizeof(Property)); \ - if (sizeof(props) != sizeof(const Property *)) { \ - size_t props_count_ = sizeof(props) / sizeof(Property) - 1; \ - if ((props)[props_count_].name != NULL) { \ - qemu_build_not_reached(); \ - } \ + QEMU_BUILD_BUG_ON(sizeof(props) == 0); \ + size_t props_count_ = ARRAY_SIZE(props) - 1; \ + if ((props)[props_count_].name != NULL) { \ + qemu_build_not_reached(); \ } \ - (device_class_set_props)((dc), (props)); \ + device_class_set_props_n((dc), (props), props_count_); \ } while (0) /** diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 31e3072b55..a3d49e2020 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1058,22 +1058,6 @@ static void qdev_class_add_legacy_property(DeviceClass *dc, const Property *prop NULL, NULL, (Property *)prop); } -void (device_class_set_props)(DeviceClass *dc, const Property *props) -{ - const Property *prop; - size_t n; - - dc->props_ = props; - for (prop = props, n = 0; prop && prop->name; prop++, n++) { - qdev_class_add_legacy_property(dc, prop); - qdev_class_add_property(dc, prop->name, prop); - } - - /* We used a hole in DeviceClass because that's still a lot. */ - assert(n <= UINT16_MAX); - dc->props_count_ = n; -} - void device_class_set_props_n(DeviceClass *dc, const Property *props, size_t n) { /* We used a hole in DeviceClass because that's still a lot. */