From patchwork Thu Dec 19 08:32:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 852019 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp1365803wrq; Thu, 19 Dec 2024 00:33:47 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWuL0SotCi9KCb2vqEPQSQezw67UB+GNelfHsWwB1oLPSgEwCLp4bQRwPJHpb4uq12xY+U42A==@linaro.org X-Google-Smtp-Source: AGHT+IF03dUTEJRham+ZpQsO9Ye418uYGJxtGAnobo05E0u6VcZox5F5MHS8YBqHfXHNMvuDDTJB X-Received: by 2002:ad4:5bab:0:b0:6d8:850a:4d7d with SMTP id 6a1803df08f44-6dd0918f816mr115263406d6.2.1734597226960; Thu, 19 Dec 2024 00:33:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734597226; cv=none; d=google.com; s=arc-20240605; b=ChY0wuxWn6nhzVJyGidja5TGRQk6aRUc9aEI4tU+EWjdBCD9E1ZVSNABVh9Nraco4f rqgAZnSk9ZN/X0N6CyZ4tMzbzIPrb/a1TePlc1z9kSmaK6UwQVE2jm5p3D77vfuxGwzR w4g1Ahok+hAXTeNA4n4IfQPs4OUmPb8gmMgxiV5VePTTXhx5dfr8NB7izHUqXqXuHMPO TYvrHeFsQwfYOGmRMuLtn01gmnxW0Fc+9Y6QXwRtWi2X/lFd1uhNrgPkOskVyMJWlPA8 4eIc5qZPc7BK3togisjsJmQ1N3RRhSmBXIjkuk6tcBU1LuFOzZMHsBttj8ElGxfq9WMd wtGQ== 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=VfN/9GQVfhxdzR3tEbIrQoWnaMvt0ggSFeNUo7cpLhw=; fh=dUA3Fnng+AVBbFuA9xEg34BXK4GUp/FrJWdmKxuQxBI=; b=dFVlGPp0Y2J60FWq5mRfYKN/l9PwtvO+AXo7L838cJFIcLiwqxGYLbVv5CLcSfeT7P oRlbn+HWOSxp2njbwvugncCvsIUpMiEvDtBpEtCv5tTyisF7zG+/xdLIIk4ZZ8hpnxrF seOev4++4I7pZ70xQGYL7l836yaBOSMcmghfggli33grO3PB7juCYIX4mNxuMN8qvcwJ qlHlsyp2wIH7EhJdmMkOmUZDO1FjbOIvA2SCHFDL8nWDXN1fz+8hYOdU2hS4WZoesbSg Dzide3YJz8cz24Ip2IZyEUqAj3HS/enlvp07k265pWq3poZiVk4qZ2g/XfQRt30Oqvuk XbmQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AaAN+piW; 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 6a1803df08f44-6dd18366a3dsi10251676d6.484.2024.12.19.00.33.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Dec 2024 00:33:46 -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=AaAN+piW; 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 1tOBy4-0004aX-Nu; Thu, 19 Dec 2024 03:33:12 -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 1tOBy2-0004ZQ-St for qemu-devel@nongnu.org; Thu, 19 Dec 2024 03:33:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOBy0-000592-TX for qemu-devel@nongnu.org; Thu, 19 Dec 2024 03:33:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734597188; 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=VfN/9GQVfhxdzR3tEbIrQoWnaMvt0ggSFeNUo7cpLhw=; b=AaAN+piWo676q/qSFOGnbVABo5D2pCahVqd8jQfSOayBKn62f/1I0oFR0rprOgojAUlAof eW2cgJDWxYEPoaz//tcYzZNnlaxwj/2wyPSql8brq4JF5J7yTXBaJtUVBiT+yncFL56q+K sV6QzWKYtk8SKPyhcGvgzP9y7JGZgUE= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-173-nkFEBQSDNbqI8M91HITnnA-1; Thu, 19 Dec 2024 03:33:07 -0500 X-MC-Unique: nkFEBQSDNbqI8M91HITnnA-1 X-Mimecast-MFC-AGG-ID: nkFEBQSDNbqI8M91HITnnA Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-385e27c5949so347204f8f.3 for ; Thu, 19 Dec 2024 00:33:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734597185; x=1735201985; 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=VfN/9GQVfhxdzR3tEbIrQoWnaMvt0ggSFeNUo7cpLhw=; b=JnK11wIw1bBHk2lBSxbIo0k+2xfRuwNyFPoTX7x0ZqxaoKvVDU20dKMdjruaIbFzEb IzVjq6XpGDBt4TPcKGR9rLbkUjOU0Qavi9pE8Rc84mv9aQzNLMJn9qcOdf0CEuwUNcFV e7eBmtu0Dlm50ny3n00ZJ5RN0Rxl65B+nEU4/g5kYS821FuCrWH4Cyil6nvmpaL/Rfqa oFSQnkAOOYdqb5OyaGsQ8K2zpzcgNwbW9um0bZ6far9GE1CoNY2mzIZr/3XlauEdgtPM 8e2lQT/2pCnsK5cranYICZethLV8paklIzkK0NN3vMNInBsULMHF5DG8y9WDfei7QkE6 /kYw== X-Gm-Message-State: AOJu0YyrvBrcPTV70eKtDqjDLXqhF9lapsYCAjRpKBYn1yQZJKbTgC5U R0zhmNktc/624Jpn0tCxgqi+1z11MGCTs1ZSVBeOW+zZpojSpcKLQKLamYFtLpek5KWJHrZhkd3 TsG94FCIuK4KgOrm9juRJnlPg2/+ENndOPj2Ehq1EEMf1XeD0RzpattqH/A0fCo11yYwbMjVc7j CnrcvM0u0rJ65pB84k5Kwmj1zs3JdxrtPiR7FS X-Gm-Gg: ASbGncseQdM3EfSuwG7aeHg+7u4ZnPWtTZNhx9GGwOakr4KgZFDzSQZ5mRTyPG3xpS+ pYIXp8U80jvWS5Os8hdc+n1nZVFF8DoPXl3mu8RCz2Pnbz5iZpylHAUq0lWbJgI4wfkLKX3SHBR 4J0zhgPhwJlXgM66onp2qQSrSkVUbitmEfqt8u042Ieszv77kcTTadET11J0qkObZ7YTCPHtQrn /FVB1iqGlqlVuQOHdcdJlb2lBCjWFelQAM19vF46wl9trmrgPyfC8muCfPq X-Received: by 2002:a05:6000:4916:b0:386:37f5:99e7 with SMTP id ffacd0b85a97d-388e4d64938mr5959489f8f.33.1734597185072; Thu, 19 Dec 2024 00:33:05 -0800 (PST) X-Received: by 2002:a05:6000:4916:b0:386:37f5:99e7 with SMTP id ffacd0b85a97d-388e4d64938mr5959455f8f.33.1734597184659; Thu, 19 Dec 2024 00:33:04 -0800 (PST) Received: from [192.168.10.47] ([151.81.118.45]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8add5asm964519f8f.107.2024.12.19.00.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 00:33:02 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , qemu-rust@nongnu.org Subject: [PULL 17/41] rust/qemu-api: Use device_class_set_props_n Date: Thu, 19 Dec 2024 09:32:04 +0100 Message-ID: <20241219083228.363430-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241219083228.363430-1-pbonzini@redhat.com> References: <20241219083228.363430-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.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.116, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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 This means we can update declare_properties to drop the zero terminator at the end of the array as well. Cc: qemu-rust@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Paolo Bonzini Link: https://lore.kernel.org/r/20241216035109.3486070-18-richard.henderson@linaro.org Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/device_class.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_class.rs index 03d03feee83..c98f0b2c7da 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -7,7 +7,6 @@ use crate::{ bindings::{self, DeviceClass, DeviceState, Error, ObjectClass, Property, VMStateDescription}, prelude::*, - zeroable::Zeroable, }; /// Trait providing the contents of [`DeviceClass`]. @@ -31,7 +30,7 @@ pub trait DeviceImpl { /// device. Not a `const` because referencing statics in constants /// is unstable until Rust 1.83.0. fn properties() -> &'static [Property] { - &[Zeroable::ZERO; 1] + &[] } /// A `VMStateDescription` providing the migration format for the device @@ -87,7 +86,10 @@ fn vmsd() -> Option<&'static VMStateDescription> { if let Some(vmsd) = ::vmsd() { dc.vmsd = vmsd; } - bindings::device_class_set_props(dc, ::properties().as_ptr()); + let prop = ::properties(); + if !prop.is_empty() { + bindings::device_class_set_props_n(dc, prop.as_ptr(), prop.len()); + } } } @@ -134,7 +136,7 @@ macro_rules! define_property { macro_rules! declare_properties { ($ident:ident, $($prop:expr),*$(,)*) => { pub static $ident: [$crate::bindings::Property; { - let mut len = 1; + let mut len = 0; $({ _ = stringify!($prop); len += 1; @@ -142,7 +144,6 @@ macro_rules! declare_properties { len }] = [ $($prop),*, - $crate::zeroable::Zeroable::ZERO, ]; }; }