From patchwork Mon Dec 16 03:51:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 851215 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp2657575wry; Sun, 15 Dec 2024 19:53:52 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXsZxk/1Sj5/zs0tP7/AB4eAzM8Fe8Jwsprh7TvIDlhK/FuUKkAxl86/n5xq1KC2kkXgUFInQ==@linaro.org X-Google-Smtp-Source: AGHT+IFKuUFGJj6YCZqajpXCTD6OHdtDSgps2Rm2Od9KzX+gQVey6Ig0B2NihqlS/MrtkWU+3Nfm X-Received: by 2002:a05:622a:2ca:b0:467:681a:69f4 with SMTP id d75a77b69052e-467a5839c08mr286393281cf.39.1734321232352; Sun, 15 Dec 2024 19:53:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734321232; cv=none; d=google.com; s=arc-20240605; b=NwnW7cyuVmZQlEr8IJ5oK2rd6VVdt0l+lnZP6ZH7+GWdoquHeXDw72lEy00sNxRxQh BV/hVey7WS3OwBycos6eNIInMJqM43O6QlpVole461EwwxrB1YWGoRSklF0gpM8UUtMo udixsJk0wDXpclpB+WXaE23Qd3tcfM/90ytFHXNq437Q3I6eCZ+X/S+u6cP/2crOon7Q Wdhe5y9RC/nl873TITrVVDZTN80vg2PZ1cYL+1d/AUVoIQMZ5FcDcR/P1qMwZUqH7T53 LX478xTMEOTvdp4cMaoPT6t4xzntL8pA8jZUo5JsbVA/nRYAyWlmKGHKOaRRz9lXI0Tm 4hrw== 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=LQ8DmbEliR36Gw9tzToNMCsxXQSyqG0+BCSp50GnSP8=; fh=Lo9PYzjEMeK3y1GfSLsw8hzaArxKUPiBJxRLj48IdAw=; b=cvmcbOsclL2oTTZXlTwm6uDa/+3ZfJDlj3KNIB7RXjYTUU+4Drtqq5XpYK5y9/HlvA ZFJF84ytlW+qrYI2skNiE//XNqf1mQ5SBjo3ufif9f5t5//XtflSllmDkZVW1z+v96Km bGOVlJZ0/bMBvVT8KMLFvX3jBmA6eb7H23ZCS8BapVA561Sq8/4quLoxvFryAQV7uEXl z25x2FgrZLjAaVWhBNWO86lNmpeEQjKwna9C5g4aDjWYNsO0WhWHJ9ZBNmmzknZERkOH smNEh61EsKLOKA+AZ5goaF0w28ILxXkhsgWOyVAWMOiX+yw7ERsCtcOQT6MKaeouIflc trJg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hIWlae6x; 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-7b7048fba4esi483534285a.697.2024.12.15.19.53.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 15 Dec 2024 19:53:52 -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=hIWlae6x; 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 1tN295-0007MX-D0; Sun, 15 Dec 2024 22:51:47 -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 1tN294-0007Lt-87 for qemu-devel@nongnu.org; Sun, 15 Dec 2024 22:51:46 -0500 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tN292-00060r-Pt for qemu-devel@nongnu.org; Sun, 15 Dec 2024 22:51:46 -0500 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3eb7e725aa0so1762471b6e.0 for ; Sun, 15 Dec 2024 19:51:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734321103; x=1734925903; 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=LQ8DmbEliR36Gw9tzToNMCsxXQSyqG0+BCSp50GnSP8=; b=hIWlae6xZoB2uA8InVyLjMKmQJfXzQhny6urf95sneeUQP1Pa6BmS5Bc49kyrSAwy8 xrxW1le3NDYE1S0kh6Md3i7PMt75MmFy64Dc32TgTMsDZkuLyQD5u8e3WQGfG/0Xr1Lf nAe2UMeAC0VebwdizhmSPZwF8N+ELobvUr/PWFjEoQYcbIV0GYjpjvEDa0QZDug+uSzb kzOA4+PM7tnQwTWvgDeTvFrI6XnM+2SdMuwjmEiFCW26LkAr/nCa3N6pIVSy4AzZuPK5 iHJ+woL+Z0SI/8RYmZElc6OeHsPqUmQCerDxCDhDf8LB1OJU10xMNnOe7CvlXzJBuJeA aCBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734321103; x=1734925903; 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=LQ8DmbEliR36Gw9tzToNMCsxXQSyqG0+BCSp50GnSP8=; b=pudVfF1kyATGgR82dALma4255upwuUDNKiNpC0ublQabu9QorrFv2Kg3nVHpiDsEYK LFbIrbQgVJ4quDLU4qSpwxEaLXlJihlrr7QfiZa4dzPOsUwwvGBl20N+0mNe0CtJSpvO A42dv1rkfXj5LWmPR/Zzo73q1uF1eFrC3E6TcaU/qI28b33veP/kCDIk6RoAg10og73+ JIwUBalGp8/czZ5wk5hylrVFVEBoTX0R35VLdwKSOMcS8VzV/FBnQHRIp7arbwedIscP E0k/yphvZq+gakay65bMzS2VNIn6bgxEYQ8I5hE4HsKBBHwL4vC+dTQ6oiLEWGhl9Vwn H4Qw== X-Gm-Message-State: AOJu0YyOGTo1BdFhCIeF8DIHHJUA/uqnZVwa8oLdeyYHqy849vfD4KdQ eO5Uy3pK0YhpRpuEiON2lz10WGRVFOccAfb0AMte/xW+O04zf8veufi+F7B/QhISoamGgeEw7yR 5PJrNIm4b X-Gm-Gg: ASbGncs9ZjsZzJ5nuupWqkHpZZhD+NF4LUfqds++sTzvEBugd32kkM9daqWjPV0Zoqo MX1Yuj/19p7gHby2Uh+Xh2i+0zrIUNOuUWa+TI1MDUx5AT84DA1txgSHs4VkLcXBisyfIk0pZUa bBAbImGkrPa31PD8qzUgDTaGo9pvwyDb24zgPBuleBu8BYa55+LyQgw06TnS4/RKJUQSR8ySCm+ VN/5eQy4O3LsGKbkDHxkDFNuDuEn9HosRM/FOZd9GaunY+E4AsraAMI6jKrmXwnGmf7KYdvH0+l ie/sKoGsBRiURcc1/gHML+CovaEsdHVajMr97rTJSx4= X-Received: by 2002:a05:6808:4488:b0:3eb:7399:29d3 with SMTP id 5614622812f47-3eba6955c77mr6097287b6e.43.1734321103632; Sun, 15 Dec 2024 19:51:43 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-143.totalplay.net. [187.189.51.143]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5f33a93a6d1sm1287493eaf.33.2024.12.15.19.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Dec 2024 19:51:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org Subject: [PATCH 17/24] rust/qemu-api: Use device_class_set_props_n Date: Sun, 15 Dec 2024 21:51:02 -0600 Message-ID: <20241216035109.3486070-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241216035109.3486070-1-richard.henderson@linaro.org> References: <20241216035109.3486070-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x236.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 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 --- 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 03d03feee8..cca51fe1a9 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.len() != 0 { + 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, ]; }; }