From patchwork Fri Dec 20 14:34:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 852397 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp2084657wrq; Fri, 20 Dec 2024 06:35:39 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWQFavxuUEtv6qHlV1Wehu3k6xIpGbEkWmy1vzsOCh9Zm/POKvJLcA+ivY8nb9NZB41aTHfpA==@linaro.org X-Google-Smtp-Source: AGHT+IGEOKNttMAJjJvZJBBrfgqU08BtMWl/4ggen5MfeTIa/J6ZDafDF5UIgnNp7MLZnwZvSToh X-Received: by 2002:a05:6102:3f16:b0:4b2:48ba:9943 with SMTP id ada2fe7eead31-4b2cc48a411mr3314058137.24.1734705339176; Fri, 20 Dec 2024 06:35:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734705339; cv=none; d=google.com; s=arc-20240605; b=YalNlW6fuq1bP3FIVlbXQM/DkWGNE0nYTD27eVFTnNVfoGxPoaN1xRDeBYQqY6LOCQ Urci7ZRrXXX4EBWLCd8IEkisX8Zi4ZUn6yARqryta56wSPwBrMRw4UB/1zvWie24sUt2 0l6nyeAmuYEujXTmbt32F/IijZ/jMP3MJIjHKg/9+gg5NPMv8v9FC5q8HQ+TApQa3i7d 9rA/Dp242m5ccOGrMMJjPQMbNNp4JanJ7ifXKYNhP92gcfAglzRmOWPvNWHtZuCUJVRx ferGItQWVh5dcvFnOW+fR9q/CIkEShDaWt3oqHwMtjMPVd+0E7QY6qC1+QjToYc7S5I+ FtHA== 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=bfkTe0JNpLA7RGXcBkcS5J3fSCwSWyZnazMZm6jnkR0=; fh=A2+luDssAbW2wSe4ZGo8RRNSMqQCzoNHzRFxgdR0x2U=; b=lH/z+ywq2RqBS4KwcMJ7avalohr66lLdWV9V4DIrPAmPFF1BPYRLrCR3D32UcHls9w Ywhlpe0b+Kb/ExlIh1MT1mjdMn+dEvAn0uA2PSpm0GUTBl1YFo2ISbGSRhy0ijCqVgY0 bIYtvOj/jPuEzo3266uWxURJqaWFkaSociR5VV4xZDeGU3FhFlmF0BZL7Lhg525sgtSh rPEbj5sjO4QFvOdSUrMFlg7KN1jIkAkb//FiUCfq4PeB96ldVRG74YE/bl2tDLy0ucil nmiAgm8SWggfEu/YwC3DnIFDxsU6J2wChqxHh4YaudG5Advls2ROcuDS7kZKVRWqMhp+ 9RBw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NLFI6qiF; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4b2bfb1d97fsi1193187137.298.2024.12.20.06.35.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Dec 2024 06:35:39 -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=@redhat.com header.s=mimecast20190719 header.b=NLFI6qiF; 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=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOe5V-00047w-4x; Fri, 20 Dec 2024 09:34:45 -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 1tOe5U-00047e-B2 for qemu-devel@nongnu.org; Fri, 20 Dec 2024 09:34:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOe5R-0008AP-Oh for qemu-devel@nongnu.org; Fri, 20 Dec 2024 09:34:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734705281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bfkTe0JNpLA7RGXcBkcS5J3fSCwSWyZnazMZm6jnkR0=; b=NLFI6qiFjMy/r2xS89LMhyVtpxtyYGdcEi2++yZa+TrMAxzr4UwvTLNGhsaE30uBHaEAvC qLIISmiitkGgpe0bPMVHc3kDWGeGML0LNXA/q9jqjTpy3S/fH/8AydzPT3HrqEvh028BZD A56Jp/30qCHSpOf3magn6rEbJZjAdk8= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-620-n5dLZJfLN52-DNcn2jbGSw-1; Fri, 20 Dec 2024 09:34:39 -0500 X-MC-Unique: n5dLZJfLN52-DNcn2jbGSw-1 X-Mimecast-MFC-AGG-ID: n5dLZJfLN52-DNcn2jbGSw Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3862c67763dso958678f8f.3 for ; Fri, 20 Dec 2024 06:34:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734705277; x=1735310077; 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=bfkTe0JNpLA7RGXcBkcS5J3fSCwSWyZnazMZm6jnkR0=; b=EohaUmAewjf2XNMacXKyfFilpWm0g4UqmFiNI1LRwU7F4wkSYWiniyhdHEn9pb4iU8 uLFe8utuXSEPFFXcpWF1tMrVq+h1VIV5+TRfL1l1WDUyGhJ+0IP0g1YJ53LZUwELNdmz clif2AzzBefJdG6VdKCqrBGTjrg0+oDzOzkwLnt52IjI4EHxJdwcibybTDEl/D0wBjHI off6LedFbwbzO0VCt/ZbOcQwaBZRvBlyJ3gpj2esFyw9rg7HLod/a/G0SthMMDvuCKG/ Y2VWSWXV1vfybix+XtMwvYqkWJEXo5esqvfRAjumMxxLAiA0YyUOWFV+s6UUubIej0H1 qfmA== X-Gm-Message-State: AOJu0YzwSfx6g1aB+pSLc6TE1ZPkRAwHP125ZzMq8EaS6L7k4Y8pIh+s Z+CYyObrLSXjPFbwa8kEh7jmAXQk3T4TCQtgsvWK3aYL3X2yRUu/GahfjnDMDB4wzs/nMfkPiYH iGZb5qYthop0HqITOq3Dx/qXYO8y/DCnnx7mcTVuKp3xCYcdSPUM/C+8Zx9SwCadaZyHY4WpLwj kUm8FbTDmgZ6ydk8jZlOBmRlgrn5rTb8u9qH73 X-Gm-Gg: ASbGncsVrpotsKVO8JDMtqg+60LwTwu6DJlGkasE4VKuwoc5aWKRn6iETW5uHYEfTce r5dLxpFePHJH4h8qTsYTPgMWfOZKzU4EkUbPcfsu/zOn9zQoBH5qtmEORcH1i4P7cQWbnfjcH72 QHiTfQcD1ASrR81PngtV/VlfF4hi/46l4pSXTumSoqgW1Y7LpldOCOft6ST9mkOQNnNMO87jOrf IuY44YODkFMz6F+b//lvaY/k8OI3P53d5BqMqNTQjLj+mX4OwSz74S6rBXR X-Received: by 2002:a05:6000:480b:b0:385:fb34:d585 with SMTP id ffacd0b85a97d-38a221fa418mr3062472f8f.34.1734705277155; Fri, 20 Dec 2024 06:34:37 -0800 (PST) X-Received: by 2002:a05:6000:480b:b0:385:fb34:d585 with SMTP id ffacd0b85a97d-38a221fa418mr3062445f8f.34.1734705276758; Fri, 20 Dec 2024 06:34:36 -0800 (PST) Received: from [192.168.10.47] ([151.81.118.45]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b11aecsm80941745e9.23.2024.12.20.06.34.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 06:34:34 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Lei Yang Subject: [PULL 18/42] hw/core: Remove device_class_set_props function Date: Fri, 20 Dec 2024 15:34:30 +0100 Message-ID: <20241220143431.653644-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241220143431.653644-1-pbonzini@redhat.com> References: <20241220143431.653644-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1.129, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 From: Richard Henderson 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 Tested-by: Lei Yang Link: https://lore.kernel.org/r/20241218134251.4724-19-richard.henderson@linaro.org Signed-off-by: Paolo Bonzini --- 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 e9b4891f55a..afa667b68f3 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, not a pointer, 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 31e3072b559..a3d49e20202 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. */