From nobody Fri Dec 19 20:51:15 2025 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFA13307494 for ; Wed, 15 Oct 2025 19:25:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556304; cv=none; b=lRNyi0yeIgIJPIIuA69e8s+WqKixQ77eqTJQwk/5l//8oTWFrKY+6RzNfcLO1kiJouL9YWMhFBLwFILik4fOtPYXYz+OTJUZdJXI0tblCXkhoJmhSb+XQscPcmrnk7B+znF4wsgWfUyYaKMF08XSqqAirVkB38FLF0pgDa/2vhE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556304; c=relaxed/simple; bh=2Vk6qFD+khvBWosYiPgnWwsc9w2ItSZw9y9K7Wf3lO0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OrYXRbSrJEMzZKmmgCZsMDBRdKUt4uwTZKhaR3ywf8+KBBfTae4NDJxtkOa32AIpzbn0P7R0y+x8oMRiVdXIHBhhfXVz86ELX9pzZS46DLl0JVh74+6rZqYzQTl/pAeghrkK/n1MsfyhEhy9i0zNz8H58uSbmvtv87wcVkFbZrc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nlhWDi91; arc=none smtp.client-ip=209.85.219.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nlhWDi91" Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-87a092251eeso23819616d6.0 for ; Wed, 15 Oct 2025 12:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760556302; x=1761161102; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yjPhqOIsQnP5icf3xI8+fTWI6demrBvMGeJug28QAmc=; b=nlhWDi91qOdTS06ilTTWQqtxrya8sKOBO4uYooo3tAkXgmoaZAAQpqclmG+Qemtj5n XMrGgYVkjdysr0wizWs3RX7uQ0cAhIJBRxoGnSF7I1F4HnmBMxUqzckCOU12ahfm0BNb IDJINVcC+rXwHuD7BRtZQhSnP9MBxaeGzZkDoketIXMWAGvXnOSulJvfcB2/5quP6vlq wEDRUny+HsPm3CogvL48V6a2JzeQ+6Is/FxZpweOdc4YWyVu71H1V0FegJmi7/j9hkG/ O/R+eq/fgpI6w1hE4q/iXU6MxKUDViYudjtsn1hw0IaC03q7OTS0jwrTrmKzmqbreEQo lulg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760556302; x=1761161102; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yjPhqOIsQnP5icf3xI8+fTWI6demrBvMGeJug28QAmc=; b=cQorNVwNNHyQJ4XeFIm7a1ABnAJbqU/quiGouAn0ZyXf7m6pa3qcplCWb/GscUvRFG +1FUpF3/kna/3hc7MCD57yfXbKo0VHy2gfc/OM6O6/Cg7p2GSCGOSXzL5XVGyipAfxfa VQ8LkLPXEUq9MFpZmaY+XuoJ4HdQmmPi+9ZcsMdLtZTKzrzgISGgKSua5BOPe2mh5XHt YgFHDjTUWM5mxPIPbZNYc1jZS+23kBRim53o2klly7V2sA/AD64vBsu8Xxcx+z3L7ohl T7kAQTcgqeBnyJ/rM+t9SgQdm+PNCLfS6WTFUTTJzZupD7fkKl2pWPht7ewIB464pbHq HLig== X-Forwarded-Encrypted: i=1; AJvYcCU7+cC5e4tztdrOxFyTj5lENA3qMdQnwdD6koL6pven9i8EDPVwlPrzyHZkS1kE/9wWom6Z5X0VvOSd36o=@vger.kernel.org X-Gm-Message-State: AOJu0YznLUrbDigDga9EDaZIIRytoofM+Ld48SDfLXNAlEIgiThDCvtE uAP6e+jmEEKANye1BXGAYZ1aybLgxM7mheEXSOhucrlEKyVTlDT6Z4X8 X-Gm-Gg: ASbGncs7C3h5kkA5gWfvvTm8pOmRtOSGa/8xzFcyWVXLEJN4jPvLCk/0rgoPSVSb3hE 1ecvXxl5cKXhaT21x6sz5YutyG1Af2s3WbHUndRVgTAf0cmAGi/GsG9g5JBHNWBPI77cOyhk/E3 bbroGLKoVw1D04rin/rsh5Yi1Y5b0D2KRloCZZiLUP+JYTgrKKNIQfgfgOdyTP9l2tpdVrtvjTB n4GDO5XzuWX42CV7fvp0cLXXfWHLNCrtbdZ25paHuwKHxAHMQ7GWB7t53Bq5G7mBmIimT5s8Kgr r0REHCNUfhpMHZxR8vWK8sXMIfQGkxFHIskU+RNN0EptZFgvAdHhC0VnqO/1tv5kVhoI1Zq/KIF 78UA04mWgNz0dBCnu0zhTiXo/9dU2hwUpSih1JQMYxki3aIpfPcjQmQzVgC92YufuklpF+q5zFB 5DLkpyvwQWfqbI4TYssvaOrcUvZjzqHbKlfNWWB9fUr/U035Mvbon0rIaCGYvDisGRdD5l3dzQp SBP3gXbcbzBun3OFxuGTFRbXmDVFo4k5fqpy1SxIoaZK9pJnMdbQY6V2NL0AzI= X-Google-Smtp-Source: AGHT+IE/6/93cmzALh4Jmouh/MLI95PCde1EljHLkZKlJY4iPwz/j8r/4JCLGlbGVcRLXtlHwQc0sw== X-Received: by 2002:ad4:596f:0:b0:783:f54f:418a with SMTP id 6a1803df08f44-87c0c8131a5mr22292536d6.15.1760556301319; Wed, 15 Oct 2025 12:25:01 -0700 (PDT) Received: from 136.1.168.192.in-addr.arpa ([2600:4808:6353:5c00:8573:f4c5:e7a9:9cd9]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87c012b165asm24076996d6.59.2025.10.15.12.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Oct 2025 12:25:00 -0700 (PDT) From: Tamir Duberstein Date: Wed, 15 Oct 2025 15:24:31 -0400 Subject: [PATCH v17 01/11] samples: rust: platform: remove trailing commas Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251015-cstr-core-v17-1-dc5e7aec870d@gmail.com> References: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> In-Reply-To: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" , Luis Chamberlain , Russ Weight , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Christian Brauner , Alexander Viro , Jan Kara , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760556295; l=1642; i=tamird@gmail.com; h=from:subject:message-id; bh=2Vk6qFD+khvBWosYiPgnWwsc9w2ItSZw9y9K7Wf3lO0=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QKJ1BUAmPVQjuKlRlHXyE7o0qpMUW2qdVnOqngFN6VFfXZIKKvKAJg9piKZPdbhI25H2DhoqGoP iQgwB+DS24Aw= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc This prepares for a later commit in which we introduce a custom formatting macro; that macro doesn't handle trailing commas so just remove them. Acked-by: Danilo Krummrich Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- samples/rust/rust_driver_platform.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/rust/rust_driver_platform.rs b/samples/rust/rust_drive= r_platform.rs index 6473baf4f120..8a82e251820f 100644 --- a/samples/rust/rust_driver_platform.rs +++ b/samples/rust/rust_driver_platform.rs @@ -146,7 +146,7 @@ fn properties_parse(dev: &device::Device) -> Result { =20 let name =3D c_str!("test,u32-optional-prop"); let prop =3D fwnode.property_read::(name).or(0x12); - dev_info!(dev, "'{name}'=3D'{prop:#x}' (default =3D 0x12)\n",); + dev_info!(dev, "'{name}'=3D'{prop:#x}' (default =3D 0x12)\n"); =20 // A missing required property will print an error. Discard the er= ror to // prevent properties_parse from failing in that case. @@ -161,7 +161,7 @@ fn properties_parse(dev: &device::Device) -> Result { let prop: [i16; 4] =3D fwnode.property_read(name).required_by(dev)= ?; dev_info!(dev, "'{name}'=3D'{prop:?}'\n"); let len =3D fwnode.property_count_elem::(name)?; - dev_info!(dev, "'{name}' length is {len}\n",); + dev_info!(dev, "'{name}' length is {len}\n"); =20 let name =3D c_str!("test,i16-array"); let prop: KVec =3D fwnode.property_read_array_vec(name, 4)?.r= equired_by(dev)?; --=20 2.51.0 From nobody Fri Dec 19 20:51:15 2025 Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0934030CDAA for ; Wed, 15 Oct 2025 19:25:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556307; cv=none; b=PQVVcxgZGqeAvYhn3tQgzkabYn9TZjJf82jafV2QfORoijDkTY5QV2P31juRmsm34+gXlg4XR3XlTW6Bdqutumx0kLiXpTcWRFxZ/qIlJiB6vfFEE2yE5E0jNNjn3ObiOmoBKOPCmtMGQ/u/memVVSrjzYdzYcVn3x3a92i1IS0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556307; c=relaxed/simple; bh=/6FAAPliz9JMtIVhSN5WM1U6uwaxaWrmdWOweTW7QYA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XK20j7xmVd4YOCxK62VuQAmSGp0ijimljIyWkHK2x/ERqfVUhIFOOrHIjUrIs5IDEyntWm8slhSa7vcWFI1dPxNFaw3SdEUn8/9/bAfKQakxazkhFB1TI1sR97+Vh95kClNKoPVjactDwhuRamBzJCbkAiQMrKc+hmwVZnKrL8Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JbCdb+fM; arc=none smtp.client-ip=209.85.219.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JbCdb+fM" Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-78febbe521cso94968056d6.2 for ; Wed, 15 Oct 2025 12:25:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760556304; x=1761161104; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=e+cfNHruMdPBuLxqLR3jBeCuq6DohSxciPX7+EKAG2M=; b=JbCdb+fM+OVabHRFA0Q4ek4JESF0QVGj+1Y+55BDVoMky/bZJokq4LiZQoOYNJo+6+ 7DXUahkxmMERzwdWQZZs0E3KcR3RoK9s/8h0Ro47K8vtrh75OjVFVQAJyl9PdUQBRLlj eYJ2bxdgv/4W8p/VXKBJS/lc8Yfrt4CAAWHvxgzjEGm1nCS36OGdoDXpkNW7EQmDMLbt r4kuh0925ie7RHRpBJJg+q9zIL+DH58iQIoxaZhmC9Ov7bIgBvUYv6/YoumwSZImbTjb cda9nCeWjILwA/5qrqhY/1Q/tGQs6JlncqJi0o0Y/N0marbQ/O0MGe9fiqmkEhmPQ1P7 i9sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760556304; x=1761161104; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e+cfNHruMdPBuLxqLR3jBeCuq6DohSxciPX7+EKAG2M=; b=KHyNnp+6H5IPe9EHbNbQWe3oge0EKYEeg36Rt9JwoXo3wIPWtA8QNewdoD2LknWAkE zuCyrCXdaUdSAJhvgAzfRw+O79T1YKXDSRTODbWUqspJ8pa7H5h7GQ+qZCTH4pWXqIcH dzl4GZoVqyRLO8MHI9e2xjW+iWyRAu1w8TeBTQSNUDlqKS//sUfaf2kTRKvL0zgEAOzA 8enuX+LgApl6N+PlEgGZVj1/I1CYnQuidt32dDA18R5FRoRv3Mar/Kr0gdF/urK+OWvn urChxnucBC22rCuVjsS9SzwX4h6uw/6xoDf4aSdBDcQIAh0p5sZoWObMwyAba7cXnZYQ +hkg== X-Forwarded-Encrypted: i=1; AJvYcCWgQD9lgkv26D5rwlr4+3Q/v0Wr9iAHLH6H1hBPUFQyR7j2MGOQEKjZ4xraNAvu1o6vE7SaxwTXK/lOtlU=@vger.kernel.org X-Gm-Message-State: AOJu0YxZfIeNzhzYHNhXZsUmJ8U7qycTvvwCzKVz5Ui420UdYViIWkUY 1Cyh2SZ2xdKKtAQxNwQiOaBFjv4chxR7SwiI8yhuArgV61aP7RMNXFx1 X-Gm-Gg: ASbGncvbKEeyQxoa8zTQWPAlH42XvKAT49hjxGkp73FhKcGbCd3kucX0riWEiwV2wd0 DmLZ9HH/4oQ/L+y39tGDxpPQtuc8xBSXjJ11CvCYtJi5BHdLMNvkgKdp4DebZNs0uwgDq8Ls7Ux w/c1DZzZGKTIFwfR3AWaesU+v+h1M1OV7m3B78wp4gd/XpXmYOtfeFew4nz9c9zP7sg70m0T7aP 1ekjEOwdZTERErbD0aZ6KA0w8dqeTeYDTQrRmLs/ezHVmP1xizA7Fabk/G2e7dF8pZNqKYcEPhT rl/j2WzQhANqenaH7bO3EGc1CzaGyFzoGPU7cF+LmO0MsZ0z9NK5nb20tyHRT0BSXi7g/zCoRTk 5J7RHHT6wb+3qysaC+p4TBcc0yQSEvDm1Yyas1CZbZIzw0yJiYkLtnadfkBxg70wVJMAld8Wfmu S79ZixyPT5SHRUuEmTNsxG1RDsZiBfaw+/mvoUKfnnd9Fc2aoiMK82oQcuss7e3aEfXhVM4Zqb9 tuxM1/cNBzWhhPvenMNo4twg8VH X-Google-Smtp-Source: AGHT+IEX9u1kD253LkrUXYqr3dEKSTO5L1DiyQsTG96pQUi26l2qBcGyddQYo91Es/OcoCoyz3pFyw== X-Received: by 2002:a05:6214:2b0e:b0:87c:115e:47c6 with SMTP id 6a1803df08f44-87c115e4a3cmr1082086d6.60.1760556303575; Wed, 15 Oct 2025 12:25:03 -0700 (PDT) Received: from 136.1.168.192.in-addr.arpa ([2600:4808:6353:5c00:8573:f4c5:e7a9:9cd9]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87c012b165asm24076996d6.59.2025.10.15.12.25.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Oct 2025 12:25:03 -0700 (PDT) From: Tamir Duberstein Date: Wed, 15 Oct 2025 15:24:32 -0400 Subject: [PATCH v17 02/11] rust_binder: remove trailing comma Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251015-cstr-core-v17-2-dc5e7aec870d@gmail.com> References: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> In-Reply-To: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" , Luis Chamberlain , Russ Weight , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Christian Brauner , Alexander Viro , Jan Kara , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760556295; l=933; i=tamird@gmail.com; h=from:subject:message-id; bh=/6FAAPliz9JMtIVhSN5WM1U6uwaxaWrmdWOweTW7QYA=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QH7AeKnZyD8ngl4+hPz+8Rz7zx2cNxYrkgP+Fzg1nzu/J1gZ5lAhrwaQqIaNPJOGnMwEnAQZVmN mf304LMVVag4= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc This prepares for a later commit in which we introduce a custom formatting macro; that macro doesn't handle trailing commas so just remove this one. Signed-off-by: Tamir Duberstein Reviewed-by: Alice Ryhl --- drivers/android/binder/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/pro= cess.rs index f13a747e784c..d8111c990f21 100644 --- a/drivers/android/binder/process.rs +++ b/drivers/android/binder/process.rs @@ -596,7 +596,7 @@ pub(crate) fn debug_print(&self, m: &SeqFile, ctx: &Con= text, print_all: bool) -> " ref {}: desc {} {}node {debug_id} s {strong} w {wea= k}", r.debug_id, r.handle, - if dead { "dead " } else { "" }, + if dead { "dead " } else { "" } ); } } --=20 2.51.0 From nobody Fri Dec 19 20:51:15 2025 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1196305E04 for ; Wed, 15 Oct 2025 19:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556311; cv=none; b=XESt3Boiv0gMS2NpOyb/OgSjMTx4qW9jpvJM3/OrPW33iOkBirjDvEVu9SJgWs3isE5vaKdhIQWQ6xiwdQkJs7NhPDb1h+K/Fyvn/T30NittpbGHhtRAio+93LB8rP4aybU/wsVKFUhSNhpIL81tPxzu7nhZ/G0BFfDXIJ5Cjxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556311; c=relaxed/simple; bh=Qn1W1cp+yTwc3WIdXx1edrK3W/vliJQWYr2kDZAgGBI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DIRnnr5MDuw584oed45lf6/EWWUlrWuc55s+Qsu2va+F0s8X06vPUk/frkzKdE6xkl0fdagvFdgrBxbRqnAMv0+cdu0+ypmv4NbZDxJDF9E7mh2PaWmBCt353Fw3jO24inzCP8yHNZAmMwmHGAeEIQLESGb/M9nmw6PMdUuQxdI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dQvM5R3/; arc=none smtp.client-ip=209.85.219.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dQvM5R3/" Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-87bf3d1e7faso47864466d6.3 for ; Wed, 15 Oct 2025 12:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760556307; x=1761161107; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=/z0UoCENjvPOzaJ7c22Y9TSWGsGdKl3uaGJR5NzjspE=; b=dQvM5R3/bTVeAHIbUhXqCyhCYZcU2V479ToP4Mb6X3gow/0QaV5XGpAwgYWc0SY7u1 IYhjuFgyGlvae9b4GXv8CiXg0suQgSx2kZebwo4xpH0erARZy2n59Wi6ymlCm0tDOy0E FHEYKI5uQbt9WDEsqLKjaH9dH6vGzbHaATSNsXUCkzUfUplquBZNekAEM88lEJontwlH iVTxhLG9ogDBPN6jQO3d2fmWzzOC/86D53uLmLHMtC8imgpScq62ximwgdmzobps7DHN 8Ol9VPg7wWJjldHLmBJmMT/P+OQRBuvNKCpye01ADsqKD0g1HV7dzO4zOyTIDpZJjOup Gy9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760556307; x=1761161107; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/z0UoCENjvPOzaJ7c22Y9TSWGsGdKl3uaGJR5NzjspE=; b=UB6rshU+bNeCDyIh4tZR18mhRecXEVNZv4Lg1oj7EV7s6CyD/WhqyBy1K7waLwVGw+ urWlsYZo/usR98HnSnc+S93aChkAbamk7f6foZRFwZUYS2YZN1v82sm/ufC8yulNzx8G h9XMPha8/pSQBAfv2wFaeh4LZiEsl4AdNKN08HOXi/kxr64vriYDkfOMSA6o+JJghRc5 kdChJtomEv/P3ZXKm72pX3mXFgPDr2ZWH91ZGKYyEoabu3kbJn/nziR2gQ1WBRudfm/U DFLsemX6UZ+i215rm/hFwVAAmwZcyx4JACYgg/u5snOTBLmCYIqA4p8s7zq4iFlu3J0S it8g== X-Forwarded-Encrypted: i=1; AJvYcCXsXtcagVNbJea+hVi6SZPiF7NIhlgZdasFDwBqNT2S0SE6V68VazQ2++bl12nen7BKjM3DXRJtaVwfk/Y=@vger.kernel.org X-Gm-Message-State: AOJu0YxLXIkVDgbAqbqUNbs66digkMj/N7C3iXJ+exRpgMcvt0JdC3a3 AP89trqSfpCIhsG4JLrSey2IgZ5L6J/Aj1ao89qPQ/JPjWv+VG/1r0Ci X-Gm-Gg: ASbGncvoxBqdhB2iPC1rxw3mcXF/v6cvgz7bNUNP6jyF8pAldhHyNZGJcoKO4YCLrCi 7oVc8cn8I0HmiaL2WtUm/8nedBEm/d9ugrPd2CoeYYjuZfsZYksY6V68s8ksY9D61oFSm9VCoL9 S2Yr66sC8gCs8cOZ8OvgiDqb0zwNGAcDmPq/beBrQabJq5vlBINLNstMLbJ1BwZIryWsjvBUuqn S/+4lOZxRB51J43UfSh9wicjvXC0MOQw84StgGvCmgWIVhhl04Mq0CHwX2BvMbAnO4JOqnHMJDl +bWtO44I0qqiY3YHmcNh0w/RIyaKbjWg/7g/NmPbmhQlDa/LTLVDbpvEeenI3go/xdiwxt7xUKS Uq9xvaFuJG/H35qKqdOVXHfqrpFZcf9lhum8mAYJE325cP1aUESHn/QhrlZnct0ceqGxUnsdBJe Bz4vnNEhOU+j1dKq9yRBZMnzk91TrmSNl0KD1OhyjlFY0eSjUCUTnOPD1TvEmgp1HZidv3etFoD YOzKvYx5NhsdVBlyEfcm/1G7pXs6VccSeUHlBjv64U88stH5wYvnwDCvsvi1nuYM2MmDcZnPQ== X-Google-Smtp-Source: AGHT+IG2tULJ6h6PVvWUIOB2ZFPRQKa/V9qgfB8TRjULEb+0DCRZ6eO1hx3aZgOim3FIHrolDm9d/Q== X-Received: by 2002:a05:6214:27e9:b0:803:3b8e:e9a5 with SMTP id 6a1803df08f44-87b2efc2c78mr410404166d6.36.1760556305773; Wed, 15 Oct 2025 12:25:05 -0700 (PDT) Received: from 136.1.168.192.in-addr.arpa ([2600:4808:6353:5c00:8573:f4c5:e7a9:9cd9]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87c012b165asm24076996d6.59.2025.10.15.12.25.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Oct 2025 12:25:05 -0700 (PDT) From: Tamir Duberstein Date: Wed, 15 Oct 2025 15:24:33 -0400 Subject: [PATCH v17 03/11] rust_binder: use `kernel::fmt` Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251015-cstr-core-v17-3-dc5e7aec870d@gmail.com> References: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> In-Reply-To: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" , Luis Chamberlain , Russ Weight , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Christian Brauner , Alexander Viro , Jan Kara , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760556295; l=1147; i=tamird@gmail.com; h=from:subject:message-id; bh=Qn1W1cp+yTwc3WIdXx1edrK3W/vliJQWYr2kDZAgGBI=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QPq4IgijUUTbPqcb/sFKSMvqN+uNEx3DeWVE1av3DAj4osSldGBCYfq78JujAqGy30VkSuPwWuG OpXoXaJlyWQ8= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc Reduce coupling to implementation details of the formatting machinery by avoiding direct use for `core`'s formatting traits and macros. This backslid in commit eafedbc7c050 ("rust_binder: add Rust Binder driver"). Signed-off-by: Tamir Duberstein Reviewed-by: Alice Ryhl --- drivers/android/binder/error.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/android/binder/error.rs b/drivers/android/binder/error= .rs index 9921827267d0..b24497cfa292 100644 --- a/drivers/android/binder/error.rs +++ b/drivers/android/binder/error.rs @@ -2,6 +2,7 @@ =20 // Copyright (C) 2025 Google LLC. =20 +use kernel::fmt; use kernel::prelude::*; =20 use crate::defs::*; @@ -76,8 +77,8 @@ fn from(_: kernel::alloc::AllocError) -> Self { } } =20 -impl core::fmt::Debug for BinderError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl fmt::Debug for BinderError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.reply { BR_FAILED_REPLY =3D> match self.source.as_ref() { Some(source) =3D> f --=20 2.51.0 From nobody Fri Dec 19 20:51:15 2025 Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 713CB30EF64 for ; Wed, 15 Oct 2025 19:25:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556312; cv=none; b=QyM2T7rzBXovBi2AQFR6deC2FIOpg7rb0kle/ShrHCYx3Ta4tom+2n1ZM2Q15y4EfyyxDeoRPZHuYpjOiF7VFM5RKRW49aIeMNxmXpFyBXpkSVMBogvicus9UjnW9BZD9HEo9pFrtjPlNbBk/91xJECX0lXqN+aN4QcJU8rPxLw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556312; c=relaxed/simple; bh=2D3oEpmQYcHuLZnWIpYHzvkvUja5YWzKptv7Pd2qprM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SjoeLHzjEz3i0OXy3Ne8lnd4tt9DyQxCRYtlGL5i7vBs3bcGZFClzV7XkdywLoGUjjKO8EW8Spyw8ezzdsHMQTeqvFVBy6/MHOjwNncBtYZ0frRVewczd9cq0jFxaWXDS8ZvVvjkbFnwfT2K1A3+ludqqC3AIA568YA8qggGXRw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cA0e42Ho; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cA0e42Ho" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-856cbf74c4aso1330144585a.2 for ; Wed, 15 Oct 2025 12:25:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760556308; x=1761161108; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=eY/3IsdbfI0mC9DM0+1rrUO6mTTZQIEYJMq8pO85TCM=; b=cA0e42HoUfvW3gVGL6iILHQaTVyX/2HEor6DEKhjyaVcB7FRSv5qHA29OksEfPZqjS t7wxBGLxx8ApRZpqC5v1ILhA8EUiN84/+tYTfRCIyIPr8IfGo/63h5x2P/edOFmMYS8/ DOOP49a1itunEXOlj78PLdKB2Gph4vdk9gmT2h3J5xmtwC9ga6OrGRNf/VCZeMf4rUtV lBO1IpexRrtiZLemfbk+Vods/Cq+LpvJFTJtIGTPVuONUhXgCq5pucfQ9ZBqjHklOUBL j9pbyGLmAVVWDd7lMM20z18ms32goqE2sMBByxyyuNXPuTGpygfAx0M2mgM9fH5JDkm2 xCeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760556308; x=1761161108; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eY/3IsdbfI0mC9DM0+1rrUO6mTTZQIEYJMq8pO85TCM=; b=fBxVVzVjCkffmMjew+NMmDHKSv+6JQGFSinbZ1PxHQF60/iJA90tlPN4ohl9vipaIC uHubQ+P/s7m9XUm9+tcs91YGAPpY4FOHNvUESsJFGeLV88t7v3iKf0+TGkEdJzCLC+3G hwFk3QXNuMSIWMbnwK+rFyFKdnxzHw3CNvTcKxlQFeKO/o3GKJUPnVQb0J49IrU+n8Yx yEft0mGuk3hS/+6KoI4pk4NXJ7Wx85A60geYVtumCcrdoACmQvEzfCr9nRPzt4EqdwSu ASjod34FxYSrzlgyJ6F3XFUerNQf1zxQfmrhPdHlCEaOoIGfrMBOy15KYqbeiT0ePPnY kRFg== X-Forwarded-Encrypted: i=1; AJvYcCVPuyEeddkIdDIywMquSLYlwH9AlbLeGD4qIFgZDihdMrCt7gf7vxhL4bjsEjxBicFxzn6G6hpkpd2J+mY=@vger.kernel.org X-Gm-Message-State: AOJu0YwHQnlt7EuWMwOqNzcx5GWO69E/h8g85OYLSR7/fZKaK5nGw7WS gVEbS9Ovn7k3TakvGVxqzJ5M/6Y7cgZjIbefM8A66Fv37LoubbcphXXM X-Gm-Gg: ASbGncv5cMO0Sia0OLJtOfQ7UcpbKR6czvCnqwJwnm5yNi1Z1klRhnN3cwO0IWs+uQl +8stUXYmUJaiw1DdP1AqmyVLtAvTMsj725RXvjeRt5++RW7jkHK3JfHKHmhyR6P+THrGX1D1g06 rm82M140CbmlYp6dA3HROjC8Fx/8NRa1dXxjVTI1hZ01xnKbXZurGBPbKaJMcTqE4umvFdrQibO rjF4DM35iWgnWkS8jYnXyX4oo08wT1vmINf0ByElo+/KnzlhxzMNmFNPYiQi4OJ2lTUY2MgpEsG +i16bfYxrzawCa8eM7C/PBqOTIx+L2z3MNRaZIApgleT9TSHOXotbIWonpwL0r3HJ+n+Td8UX+W EvFqr5nW0zzw/pLPNRKKtjDGFuBAmwZRjoVR0Zce5Jt+AnUYxTimGj/D6NlqijHdLM7DlQiVRQn TdaxuvrMzbPvZj13qdu+TJjMmr5loHBvYPegZ2trQMU1Z1qO4TJZn92vZUFOeA8RfAZ7EElaozm huOkHA5UfKm4iBEa96BeckYrml9 X-Google-Smtp-Source: AGHT+IF/CUBVvLt2dkQCDA5YZrHOn4tHGJzgB3mXHJTBxXrUXPaXJyBN4wC5HBKmPT8DqAH/ADgWzg== X-Received: by 2002:ac8:7f8f:0:b0:4db:aeb0:b624 with SMTP id d75a77b69052e-4e6eaceb3e7mr380441741cf.30.1760556307886; Wed, 15 Oct 2025 12:25:07 -0700 (PDT) Received: from 136.1.168.192.in-addr.arpa ([2600:4808:6353:5c00:8573:f4c5:e7a9:9cd9]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87c012b165asm24076996d6.59.2025.10.15.12.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Oct 2025 12:25:07 -0700 (PDT) From: Tamir Duberstein Date: Wed, 15 Oct 2025 15:24:34 -0400 Subject: [PATCH v17 04/11] rust_binder: use `core::ffi::CStr` method names Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251015-cstr-core-v17-4-dc5e7aec870d@gmail.com> References: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> In-Reply-To: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" , Luis Chamberlain , Russ Weight , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Christian Brauner , Alexander Viro , Jan Kara , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760556295; l=1790; i=tamird@gmail.com; h=from:subject:message-id; bh=2D3oEpmQYcHuLZnWIpYHzvkvUja5YWzKptv7Pd2qprM=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QLuOpLGTfFQjBZXdio1nayh5dtiHoR1n54dLy3fgkauJkhueXEntNbGxy1JTge4mrx8nVKiNy+z 1vw2Aya3HWws= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc Prepare for `core::ffi::CStr` taking the place of `kernel::str::CStr` by avoiding methods that only exist on the latter. This backslid in commit eafedbc7c050 ("rust_binder: add Rust Binder driver"). Signed-off-by: Tamir Duberstein Reviewed-by: Alice Ryhl --- drivers/android/binder/stats.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/android/binder/stats.rs b/drivers/android/binder/stats= .rs index a83ec111d2cb..10c43679d5c3 100644 --- a/drivers/android/binder/stats.rs +++ b/drivers/android/binder/stats.rs @@ -72,7 +72,7 @@ pub(super) fn command_string(i: usize) -> &'static str { // SAFETY: Accessing `binder_command_strings` is always safe. let c_str_ptr =3D unsafe { binder_command_strings[i] }; // SAFETY: The `binder_command_strings` array only contains nul-te= rminated strings. - let bytes =3D unsafe { CStr::from_char_ptr(c_str_ptr) }.as_bytes(); + let bytes =3D unsafe { CStr::from_char_ptr(c_str_ptr) }.to_bytes(); // SAFETY: The `binder_command_strings` array only contains string= s with ascii-chars. unsafe { from_utf8_unchecked(bytes) } } @@ -81,7 +81,7 @@ pub(super) fn return_string(i: usize) -> &'static str { // SAFETY: Accessing `binder_return_strings` is always safe. let c_str_ptr =3D unsafe { binder_return_strings[i] }; // SAFETY: The `binder_command_strings` array only contains nul-te= rminated strings. - let bytes =3D unsafe { CStr::from_char_ptr(c_str_ptr) }.as_bytes(); + let bytes =3D unsafe { CStr::from_char_ptr(c_str_ptr) }.to_bytes(); // SAFETY: The `binder_command_strings` array only contains string= s with ascii-chars. unsafe { from_utf8_unchecked(bytes) } } --=20 2.51.0 From nobody Fri Dec 19 20:51:15 2025 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BDA730F527 for ; Wed, 15 Oct 2025 19:25:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556313; cv=none; b=jlP3tgdA6qDtXkALyKPqXCb+RNES3qhUV7hSceWjVIhKswghW2P39rWAHI9vthc5vZkQnV6gpCATZZ42mWIVrUwp6OMKmROwA7fnGKb26Sill29J+r/K7v2gkWjeF6WOYqckm44FmV0HBKGKAejp0vPp1fVXOTqyFJQG/MO0ucY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556313; c=relaxed/simple; bh=KlspLvr521ZswwzUDPIsBp2B9Wg66z4eaz2g1WzaBxk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BjGZnPradYJUmhPp1STmCUmVaD7El6oOgStyrqr3Q4NXQRJGhl5ukrF0Ey+BkIps9K2bgiqoTyBLA4FHm+9EMPMw9+xfky6am54xngtQVobXnOf1rv/3wnvDcdyDli9SJRFOyoccYvaxcAXCnP5XLF6+i1e6zcjiV1phc4VpP0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dqqtQJJ7; arc=none smtp.client-ip=209.85.219.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dqqtQJJ7" Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-87c11268b97so787996d6.3 for ; Wed, 15 Oct 2025 12:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760556310; x=1761161110; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=MlH2K2eTZ1PSArwqcAz1RbXMF6sxizBGN/Y8PHlK+Wc=; b=dqqtQJJ7q2mvoF1LmHDRpIvCUFDiczBljqWAcANZB8KY4/h8tV7bQLloX5+Kdr65Af N6dXvuuOqFQejwyS0Tld87zQlzCCaCP4TpQh95i79NcTCOeVvUtf3n4otaYCe+Mamiur Q9dBCP2DJNBDbe4iWAjyK8C4vTuGdugwxLrJF3y/Jl6Fb0jAjYu703tDrylIVIHqYlLH jJwCQPGnXK4GbQNimztnjj2sflq+0ND9/UcPFeH9S7pZr+cMU26498qRT+PheMiJGHmX NtJY+qVn0bZ2pZpshFREMi2hTUeUF8qxUJAdkinoObmGHZ6GIW68lrTRl66eOlelHMzN heYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760556310; x=1761161110; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MlH2K2eTZ1PSArwqcAz1RbXMF6sxizBGN/Y8PHlK+Wc=; b=CmgAtRttV9IfyO8o1Kzs8Zmgw1setw3XWVAEONIdkrI5nc4GYndmbyfcH0P12vLsOF w7WmUFexjCeaUt7VVpjmnhdlD8/RFc649o2gY5KQI/s1kpstoMMJq+i2OwmDAPaRBN/V TvPoseWKCdscUxTWpcbXuEfUme7mAAFPtRCUAa3B5pQgohCw1eT8TQPqq38sDU4scTW3 89NMDx9wvIl62GSJBELo5F4XYEDYl7SCC5BNsLTievkjkDJ58PN2+arvfuLoXIKAwkEA bvqre74p0MgT1B5df41jcptcCQeDGmYWk6qHddkaww3EEkmg4AnIHAayset/XUuaDy98 BWAQ== X-Forwarded-Encrypted: i=1; AJvYcCXGp9XBf9wgzjN6Mqun9qLY4EHfwbs+GpxvdnkzRV+EYn/CpVfGFDHzzciDYM4AzyziqePbUh/Spuy4S4E=@vger.kernel.org X-Gm-Message-State: AOJu0Yyfj4jMDEDAyt7+clYqW76eEA0r5oE2vxQ48/YmCK6U375/657e p7YbfJJxvLbNnk/f7XCcU8bgbfoiyDdrIkaak56l0dYlQ8W23f2BOTMW X-Gm-Gg: ASbGncsJWEveiDWj/ShL32j92iASfHQuYrJyfBujLqvurSiDKng8ZaDI9DZZuvPA3V4 afiF4PIAA+s3qxtOIYBBzX/68krBrJhnn98ntv5HUkwngV7d3svQ449mLv9blru0qpGt/pwKN38 FdD4ZgFeif5AxkKef2fNQoIXzv4Fl74IMKVAEGBmg+hYHSHpOdNpbGHbC3otryrtmlxvK5ufNb1 y9XEd7vwlagU6HoregzPmT0HgsssuUSEkv2mWlolK+7mN1OYbRyyiZmhASeS4IyQfnYRrNTd7nJ v6Ml5zBpU3+bCy9b4CyZrJ4d7/8GA+v3HfSsd/1h6F2o42oWu1FG7NA7KBIpV1wP8g4Psk69Ng2 ZbCOutaV9pR8Q30FQ9UhfLgs5V6dyhW/+aL1lJTEmOCAN4cPDkiBA2OjLWrDUU9cP4k0vf6JAzC QNmrsMGoP5l6ze7wejIyQpHjU2t9WLEqdjpJQIk4yHLaf36dy1vj61zrf/fXAmdh8hPUQXIKCOx 5adWvo6Mlp1KlJNJEcTUDaB/7nQ X-Google-Smtp-Source: AGHT+IGPF1xrploY4yyf3/qJv7Wa6m7LEZDAuiBlGyAxIyb2xiX2HjjGqOaaPv9jGE8ttZXyV/gqwg== X-Received: by 2002:ad4:5e8a:0:b0:81a:236c:c846 with SMTP id 6a1803df08f44-87b2ef6c9c9mr354624946d6.33.1760556310156; Wed, 15 Oct 2025 12:25:10 -0700 (PDT) Received: from 136.1.168.192.in-addr.arpa ([2600:4808:6353:5c00:8573:f4c5:e7a9:9cd9]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87c012b165asm24076996d6.59.2025.10.15.12.25.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Oct 2025 12:25:09 -0700 (PDT) From: Tamir Duberstein Date: Wed, 15 Oct 2025 15:24:35 -0400 Subject: [PATCH v17 05/11] rnull: use `kernel::fmt` Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251015-cstr-core-v17-5-dc5e7aec870d@gmail.com> References: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> In-Reply-To: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" , Luis Chamberlain , Russ Weight , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Christian Brauner , Alexander Viro , Jan Kara , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760556295; l=1516; i=tamird@gmail.com; h=from:subject:message-id; bh=KlspLvr521ZswwzUDPIsBp2B9Wg66z4eaz2g1WzaBxk=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QHxMXWDjPc4JHWDJF+k+dKHv7GUEw5MjBiz/HrOQDc00FLmk5b2RTxkdaw7ylNTACU7Exa4g7kq NOXZk/P8Bewk= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc Reduce coupling to implementation details of the formatting machinery by avoiding direct use for `core`'s formatting traits and macros. This backslid in commit d969d504bc13 ("rnull: enable configuration via `configfs`") and commit 34585dc649fb ("rnull: add soft-irq completion support"). Signed-off-by: Tamir Duberstein Acked-by: Andreas Hindborg --- drivers/block/rnull/configfs.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/block/rnull/configfs.rs b/drivers/block/rnull/configfs= .rs index 8498e9bae6fd..6713a6d92391 100644 --- a/drivers/block/rnull/configfs.rs +++ b/drivers/block/rnull/configfs.rs @@ -1,12 +1,13 @@ // SPDX-License-Identifier: GPL-2.0 =20 use super::{NullBlkDevice, THIS_MODULE}; -use core::fmt::{Display, Write}; use kernel::{ block::mq::gen_disk::{GenDisk, GenDiskBuilder}, c_str, configfs::{self, AttributeOperations}, - configfs_attrs, new_mutex, + configfs_attrs, + fmt::{self, Write as _}, + new_mutex, page::PAGE_SIZE, prelude::*, str::{kstrtobool_bytes, CString}, @@ -99,8 +100,8 @@ fn try_from(value: u8) -> Result { } } =20 -impl Display for IRQMode { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl fmt::Display for IRQMode { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::None =3D> f.write_str("0")?, Self::Soft =3D> f.write_str("1")?, --=20 2.51.0 From nobody Fri Dec 19 20:51:15 2025 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A55F30FC2B for ; Wed, 15 Oct 2025 19:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556317; cv=none; b=sFJhoq4x9IgfxPLDZK4hAE9HiumI2gts+UshEMRDrRrftKoZ3I+UcEYvwdfu9CaN2fHpJO87tE6Rv8rx0s+p7n07nfQDqAsC3xEBBvHwiKPAeitihFQGUx0Cyx/VbNFK4cssqn6AXyGJExGhjd6UdgDJbJVa6obr/FvYnzpJ6GI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556317; c=relaxed/simple; bh=1C7R0OlcDfzCrDNlHP23bsVD6WxFN5roYyk953BnBNs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=okyjQeSWJDbJVsAAsrU6qOMvT98eyPZ1rZs+CCymDjOryxMR1sMjlUS4Q4b4aqVnc5qz58orcZiuL82j2DBxrYDlUk/0u683omxfJNFstErD2Inc81fO7LUQN1P/VOoEZdCBhRmOqxCiizIma7Sg8bJgzippI9g4lonyUaKwMPg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LvURDB2b; arc=none smtp.client-ip=209.85.219.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LvURDB2b" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-78f58f4230cso80725856d6.1 for ; Wed, 15 Oct 2025 12:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760556313; x=1761161113; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gZKdkbczThzjFB/XasmnId0cLwQ4C+67cjGeOTOncUU=; b=LvURDB2bWmzmqc3ssvxSZ5e41cSaG+FYiEbdcfC9cY184Iz7xDLZ2mw3gltSKQZ6lt Gb8i4g746WVUeM/u5dyezFGSPw1rFoXL14Q5oDlX7uU6fkq1637nSqsSYL6PhKV+4Fb5 C7jZ2hBCCUC7DqzxJL+TtR7wO0b4MS0C3O8r8NW1qVBPjaP8aePXqbEXCaW75xJ8XJRY 4+Yk/GVU24t25jo3GQ3Im4KSPqtg+3pHWmCjVvktEnpWEuHY+NT3WiXN9H+vAukTqkTw EhC1pibdM7mdZGBixA6HOy4B3TKHjcSOBgPSHuHjwhoOEeXIVeB9f+BQ5AP5SBAWmR64 vIKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760556313; x=1761161113; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gZKdkbczThzjFB/XasmnId0cLwQ4C+67cjGeOTOncUU=; b=uKL/aoEjaveOIaBQ8AYtcgIOTWNMEAAg1s9Ft9zElsGoqNKxK5L7NZX1ovqv9rFX64 V+sAp8XSttQFcFAcWl25L950OGrXfc+Qtw6gGnRRr72PgKeDbulZtw0YreQk+ilBK2JO KmW4wfeCZdidonovcUsKZu97sMRXu/LAkpqYJRANVENT7yKmklEGnhjP1JoIrp5rmTen 68q+BmXiMJcqkIJJb9kl+PO0p/5mKTNfmmmkpdIe7/u6eTehBS3MTKViws94hANklt4x Tp3d9hZlzozETlTvNW/sSD6VIT6siQB3jJIM6/kXPlG4d5kZ7Y+583zdGkOpp/uFFcM2 mvuQ== X-Forwarded-Encrypted: i=1; AJvYcCVBYuEq2eHcJa3cpXX0rNLK0ib3TsANsz/ykFtEDXb38ti9pT3AeFlq4PCbCCtqxPcjDfz10bQ4DQgZAAM=@vger.kernel.org X-Gm-Message-State: AOJu0YwwNXnZGWlL/kD8GHGjY0Ae0tZfMpVDNzygG6w1ipYQvNqySEBp o1GJNj2ed3XR7xrck9sB2pShlSVzrAJNpHGqhyGafuMimNZi5PxUgO7p X-Gm-Gg: ASbGncvfCtKNtImcaJgVQU9W7DntGFpVibiE6vf//jLZ2M7KVelqdOse0GjKS7t7drD RU6OnItoAbj+btNFFLFhs+0EitLC+bNY5bfxEd4qcXpMfD6M7XCpTC9kTk64FQ/n3hwjMb1nv84 /SnXOl66OhZL+lY+QSa0z8ax8VMUn2mdy7tR3IfMVUT8F8yMur82hSAmNjD12aKiIw4sViKvICp cI+PFhjbPlgUepLp7rcsBUssSgvS0luj9PhR1XDNmOTATcXp8FpcconuZbadwsuVkjp/oDDyCFZ yDBeT67nIfqUJXwslW43h1UdjHXWyV9quDXnlAxhEUYTb66ORrDW0/8kU6i3yhETi2zTOU3Ncic W2qLS+EF7TwDUDXHAmAmRpruNDcr+/Dj8PbCxUgB3tsEm4VMXfJBcvp/k7SV8N0FzoW3R8dvHjx SDN1rZLlJ/B9yEs/1A8RLC1JD233+i6q8KA0KbAb6FnowbVEwSFyjkXIZTE79sAcpKfJD8ABcNo tslCPghUnyB4p70cTQz7dMGc1iZKd4Sw4ukvO+dwVyMSN1Q2UnnIE4djiaUPVc= X-Google-Smtp-Source: AGHT+IG7liVg/dFGAXjOyaKmVuQjChyGkmShQ9JV9oLbo6kDusjiP3kvxzCrSASqCG/bT3aBHrC7KQ== X-Received: by 2002:a05:6214:da5:b0:81c:b934:a01 with SMTP id 6a1803df08f44-87b2efb9b5fmr472291556d6.31.1760556312957; Wed, 15 Oct 2025 12:25:12 -0700 (PDT) Received: from 136.1.168.192.in-addr.arpa ([2600:4808:6353:5c00:8573:f4c5:e7a9:9cd9]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87c012b165asm24076996d6.59.2025.10.15.12.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Oct 2025 12:25:12 -0700 (PDT) From: Tamir Duberstein Date: Wed, 15 Oct 2025 15:24:36 -0400 Subject: [PATCH v17 06/11] rust: alloc: use `kernel::fmt` Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251015-cstr-core-v17-6-dc5e7aec870d@gmail.com> References: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> In-Reply-To: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" , Luis Chamberlain , Russ Weight , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Christian Brauner , Alexander Viro , Jan Kara , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760556295; l=1945; i=tamird@gmail.com; h=from:subject:message-id; bh=1C7R0OlcDfzCrDNlHP23bsVD6WxFN5roYyk953BnBNs=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QDAN3p325daLL4ZjhjcTgzqClyBuzpHB1y4m1///5j/K+30qaqRH3Sgm2aqLHXCgT2ZR6uF5mJU hkiaomJhEowg= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc Reduce coupling to implementation details of the formatting machinery by avoiding direct use for `core`'s formatting traits and macros. This backslid in commit 9def0d0a2a1c ("rust: alloc: add Vec::push_within_capacity"). Signed-off-by: Tamir Duberstein Acked-by: Danilo Krummrich Reviewed-by: Alice Ryhl --- rust/kernel/alloc/kvec/errors.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rust/kernel/alloc/kvec/errors.rs b/rust/kernel/alloc/kvec/erro= rs.rs index 21a920a4b09b..e7de5049ee47 100644 --- a/rust/kernel/alloc/kvec/errors.rs +++ b/rust/kernel/alloc/kvec/errors.rs @@ -2,14 +2,14 @@ =20 //! Errors for the [`Vec`] type. =20 -use kernel::fmt::{self, Debug, Formatter}; +use kernel::fmt; use kernel::prelude::*; =20 /// Error type for [`Vec::push_within_capacity`]. pub struct PushError(pub T); =20 -impl Debug for PushError { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Debug for PushError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Not enough capacity") } } @@ -25,8 +25,8 @@ fn from(_: PushError) -> Error { /// Error type for [`Vec::remove`]. pub struct RemoveError; =20 -impl Debug for RemoveError { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Debug for RemoveError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Index out of bounds") } } @@ -45,8 +45,8 @@ pub enum InsertError { OutOfCapacity(T), } =20 -impl Debug for InsertError { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Debug for InsertError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { InsertError::IndexOutOfBounds(_) =3D> write!(f, "Index out of = bounds"), InsertError::OutOfCapacity(_) =3D> write!(f, "Not enough capac= ity"), --=20 2.51.0 From nobody Fri Dec 19 20:51:15 2025 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA3E930FF21 for ; Wed, 15 Oct 2025 19:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556319; cv=none; b=upkJTDwUe1R/IxqTYJSCfeXeWSpRxGG7MKiR8zIvtf+kMydpJjNz+l+c5gNA7/CHwKsCulF+FAF+EJWsvytPjQXzOhooBkyvvA4PWpClGsdSnxQBhz4cmCsDyEqYyoQ2qYdEwxSUUJ0wv5VfC3HbBgrBLJfnKpVG46SMDMufwVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556319; c=relaxed/simple; bh=dVZb5Pcu1XHbZt2SW9FpYlV89iSmsSjiuXxsiQfQLK4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pW/7M11vR0GidYmwB8ieqIBIjABK1tTmr6Octq2AIefAinyqI4Se3ybhSV2FgypooNeu4r13LtDne4E0nXCwHYsWrSJtScN0Q9ZW/y9g7odgS4YUzVLDlZZNHbuIZZDgQltiDboar4RjYRjsoYvtnSBj/YJHUk7DnnlT5MO0dbw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=A7LPK/2Z; arc=none smtp.client-ip=209.85.219.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A7LPK/2Z" Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-78f15d58576so16571416d6.0 for ; Wed, 15 Oct 2025 12:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760556316; x=1761161116; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ZcA+z8eYaRvOgVrZmY/xhbxjfSBJr0w9ghrKai5yQJ0=; b=A7LPK/2ZcjAQL7xVWJxRF0OckSL4EAYosmXjxRhaDABPim0FoifmCoQ8mQAampIf5B 4jZRg5pwl75YHnlKyC22D8S2So9lb0zOgShysSwArYVYsW82bUXfh1iDgY2pnEsVr/8Z yGS12//9A2cCPi1raUg+rJ7IQt/YzJN2wImtSdvLw8XY0/dXHaxQpTgDOTnqDcxWcute QJdQTwwWMH/ibrbT6cTbKqeXJX10RMUqBS0OFXREuYLGgSdo6qfFC0oZJENulhbLbgA4 Fig9gTCGtlIkaxrlmVrBJRi3bX6HkJQ0OXJidjO03JftgSDUsKJg+hV5Z3bcSA4r2ESd epuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760556316; x=1761161116; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZcA+z8eYaRvOgVrZmY/xhbxjfSBJr0w9ghrKai5yQJ0=; b=CF5/IuyNBePP4bjTindzepMO5jvYGFE9MewUxskHgOzf4O8hqoQoprIOpifvjlGigB LxmlNpbyC3n6GDOsLNIOx5OVBvdIlEIUO6RyI0YI4y3aW0yU8GDUAJsajmXkr/MC3eiE gxnZWZJqaHvYeq0zvTs99mLhFlKvCiNL4sHzH54vMIhm+S2JgrVp/QI4sOFtxGdV6Uu3 P6c6bzbMZqqs3E1tiTgZALpIwrFEK+ZQAgOlEwRfpgh2h4uoFR/E/aTipKWXnYHcZNHW Ez8koNmnzGyHj047xHL14orZzm5O2to3XbWC1LgRlB3Vyvk6KzTh86no64YybUrNnjMN L43g== X-Forwarded-Encrypted: i=1; AJvYcCWa3G7rqxXTN5Rz+jZv1xDcPqCt2qfFx+zgJUTlMXQ7pfwi9qB7/5jsvkh70a9bRAaXrqv5IFXSmwOqRIk=@vger.kernel.org X-Gm-Message-State: AOJu0Yytk9TJnjw/MrdumSOni0tWkxF9kAztu/KTs35hcsxeZ3sVpXvc F9flblZPVONlHBzqkPcVMyiy6nm6mHoeeSjfyydTDrI0/c9xO2Hofggv X-Gm-Gg: ASbGnctASF/1oDMup3hPNUgJ5KXQNDLKhsbuo3DvMWTWdvGkrN+720alYZnTWvTCtjb 6JlfhzKmMOAx8MYEcPs5NMgqii8NXEuwMO3W6IX633jEOCiimTgbwDQoQvpmoL3pd5Bqg0927jE 6lf/Jz3o29jtHNC8MjkKrIPvDC1+4IsiGlC7XmUHZ+FvLUhHGmo9fe1jFneuWhn8wpH3BvLc405 bNECrj58/MtesiUjuz8XeaSuwt3SHnzPyDeudnQyAqUKGvkWN5cyAnV9sNBNauEUG4Cz68arnmP NkS/oQU5vQu8mkVbA4HCqS36m0F8kzwkcyi190DXbD2aJ1G37ZdJtYsbzyqhFV5yk6NTRE5nAuE UlC5U+LvrAoKcZCfmethPUWCLr3Movddw2gNCIUVcoWJadMyhAcJ4NYuz2GBZcNa0KTuRDjfihE 7BwGR70ZcflfcWDkr2KJz46vR2ZnV4IxqHmKSNa6tGwNmluBmMlWlQIy+xp0TmeL+/ofnOtn4Rl tM9lB35o3A9qkI3oGpwwdAAGJUPCrzigNvFCxAPEQCFwC2vZj+WjHplDLYYwy4= X-Google-Smtp-Source: AGHT+IGtrSTY0FUSiNdgbPyhOIH/YvdyU5sl8fvg654fDJk8BbKW5z4ao5A5UXUjIURMYSPijzmsPA== X-Received: by 2002:a05:6214:48f:b0:78e:f6cd:4704 with SMTP id 6a1803df08f44-87c0c5cd3aemr17462466d6.5.1760556315435; Wed, 15 Oct 2025 12:25:15 -0700 (PDT) Received: from 136.1.168.192.in-addr.arpa ([2600:4808:6353:5c00:8573:f4c5:e7a9:9cd9]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87c012b165asm24076996d6.59.2025.10.15.12.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Oct 2025 12:25:14 -0700 (PDT) From: Tamir Duberstein Date: Wed, 15 Oct 2025 15:24:37 -0400 Subject: [PATCH v17 07/11] rust: debugfs: use `kernel::fmt` Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251015-cstr-core-v17-7-dc5e7aec870d@gmail.com> References: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> In-Reply-To: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" , Luis Chamberlain , Russ Weight , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Christian Brauner , Alexander Viro , Jan Kara , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760556295; l=4568; i=tamird@gmail.com; h=from:subject:message-id; bh=dVZb5Pcu1XHbZt2SW9FpYlV89iSmsSjiuXxsiQfQLK4=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QIygDVPZERtANioDtpZsLIsIx6DMuRfppWFXkHaK3hI5+YEfWJFA0uNjCcv/4Z25JqUAs3bOoMG 11/p3YDZDuQA= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc Reduce coupling to implementation details of the formatting machinery by avoiding direct use for `core`'s formatting traits and macros. This backslid in commit 40ecc49466c8 ("rust: debugfs: Add support for callback-based files") and commit 5e40b591cb46 ("rust: debugfs: Add support for read-only files"). Signed-off-by: Tamir Duberstein Acked-by: Danilo Krummrich Reviewed-by: Matthew Maurer --- rust/kernel/debugfs.rs | 2 +- rust/kernel/debugfs/callback_adapters.rs | 7 +++---- rust/kernel/debugfs/file_ops.rs | 6 +++--- rust/kernel/debugfs/traits.rs | 10 +++++----- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/rust/kernel/debugfs.rs b/rust/kernel/debugfs.rs index 381c23b3dd83..8c35d032acfe 100644 --- a/rust/kernel/debugfs.rs +++ b/rust/kernel/debugfs.rs @@ -8,12 +8,12 @@ // When DebugFS is disabled, many parameters are dead. Linting for this is= n't helpful. #![cfg_attr(not(CONFIG_DEBUG_FS), allow(unused_variables))] =20 +use crate::fmt; use crate::prelude::*; use crate::str::CStr; #[cfg(CONFIG_DEBUG_FS)] use crate::sync::Arc; use crate::uaccess::UserSliceReader; -use core::fmt; use core::marker::PhantomData; use core::marker::PhantomPinned; #[cfg(CONFIG_DEBUG_FS)] diff --git a/rust/kernel/debugfs/callback_adapters.rs b/rust/kernel/debugfs= /callback_adapters.rs index 6c024230f676..a260d8dee051 100644 --- a/rust/kernel/debugfs/callback_adapters.rs +++ b/rust/kernel/debugfs/callback_adapters.rs @@ -5,10 +5,9 @@ //! than a trait implementation. If provided, it will override the trait i= mplementation. =20 use super::{Reader, Writer}; +use crate::fmt; use crate::prelude::*; use crate::uaccess::UserSliceReader; -use core::fmt; -use core::fmt::Formatter; use core::marker::PhantomData; use core::ops::Deref; =20 @@ -76,9 +75,9 @@ fn deref(&self) -> &D { =20 impl Writer for FormatAdapter where - F: Fn(&D, &mut Formatter<'_>) -> fmt::Result + 'static, + F: Fn(&D, &mut fmt::Formatter<'_>) -> fmt::Result + 'static, { - fn write(&self, fmt: &mut Formatter<'_>) -> fmt::Result { + fn write(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { // SAFETY: FormatAdapter<_, F> can only be constructed if F is inh= abited let f: &F =3D unsafe { materialize_zst() }; f(&self.inner, fmt) diff --git a/rust/kernel/debugfs/file_ops.rs b/rust/kernel/debugfs/file_ops= .rs index 50fead17b6f3..9ad5e3fa6f69 100644 --- a/rust/kernel/debugfs/file_ops.rs +++ b/rust/kernel/debugfs/file_ops.rs @@ -3,11 +3,11 @@ =20 use super::{Reader, Writer}; use crate::debugfs::callback_adapters::Adapter; +use crate::fmt; use crate::prelude::*; use crate::seq_file::SeqFile; use crate::seq_print; use crate::uaccess::UserSlice; -use core::fmt::{Display, Formatter, Result}; use core::marker::PhantomData; =20 #[cfg(CONFIG_DEBUG_FS)] @@ -65,8 +65,8 @@ fn deref(&self) -> &Self::Target { =20 struct WriterAdapter(T); =20 -impl<'a, T: Writer> Display for WriterAdapter<&'a T> { - fn fmt(&self, f: &mut Formatter<'_>) -> Result { +impl<'a, T: Writer> fmt::Display for WriterAdapter<&'a T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.write(f) } } diff --git a/rust/kernel/debugfs/traits.rs b/rust/kernel/debugfs/traits.rs index ab009eb254b3..ad33bfbc7669 100644 --- a/rust/kernel/debugfs/traits.rs +++ b/rust/kernel/debugfs/traits.rs @@ -3,10 +3,10 @@ =20 //! Traits for rendering or updating values exported to DebugFS. =20 +use crate::fmt; use crate::prelude::*; use crate::sync::Mutex; use crate::uaccess::UserSliceReader; -use core::fmt::{self, Debug, Formatter}; use core::str::FromStr; use core::sync::atomic::{ AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicIsize, AtomicU16, Ato= micU32, AtomicU64, @@ -24,17 +24,17 @@ /// explicitly instead. pub trait Writer { /// Formats the value using the given formatter. - fn write(&self, f: &mut Formatter<'_>) -> fmt::Result; + fn write(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result; } =20 impl Writer for Mutex { - fn write(&self, f: &mut Formatter<'_>) -> fmt::Result { + fn write(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.lock().write(f) } } =20 -impl Writer for T { - fn write(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl Writer for T { + fn write(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!(f, "{self:?}") } } --=20 2.51.0 From nobody Fri Dec 19 20:51:15 2025 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 214EB31062D for ; Wed, 15 Oct 2025 19:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556321; cv=none; b=YPyyE8YmaT3YCSsD6So3SQRt+XBTQrJXjGAs3UZe7duTefVoPXIJlbAo/6lgUrBVrl5PbUvoFstehTELyJSTnluw3mPpnIFTmAxiqEUSQQNzJwnSL0GNTJ3sjsVwDE2SWovPVBuB16HL4rlHoMA5OGZSricSQ9SG7BspS/A9K7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556321; c=relaxed/simple; bh=Kd0EzPTdfyblnmo1RxE7jLLbIDYVUJvE5DzKX0nK5ME=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Vf0Zyfzg98Z8jorSnZ68dUS79EpYFlpgR270GoIT3VAzx1bP3NsmP49TsNKHiLT4lwPFP1qNF+SDfRd3obR1v5Qxg8KEFLmiZr2PnPFxHxVVsGlrZ7/KefJ2MrM7wO+9nPhtRHBMC9lpK80Wh1dQ7RopTl75WrhSinN2Vff0PSI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LMrVogHc; arc=none smtp.client-ip=209.85.219.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LMrVogHc" Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-7970e8d1cfeso125520336d6.1 for ; Wed, 15 Oct 2025 12:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760556318; x=1761161118; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=pfKLoaIE6m6YAqIlpySfZ0ebyLDDrsoOWfky8dWsuu8=; b=LMrVogHcGeDeNnUmoDhp1Krga++idOt61PfnQ8nq+3PdvwKyUiws7bhrvpk0b7CDP/ PHSIjY1iJksa2BhauBRnYMKCa/I280ce7stALHOIvdRk7qWx2SRUowDi73acVUB79S57 jXzRMkCYivEYnL4oIcVDkJQCHs6urxlAPDI6XW5+axPqan+BaSEWETFfUi6H3qhRt1yL nFIUNQsOGG6H5jScPpkkE8gsB7aa9iMYt48RqBk61JvTtRMKlmjyAMjOADtOdURgh/Jb MEdxYcMfUMLIsqE690ypLxJYdc0KzEHJO3mwynr6D55fwU/gMyPjgnwHZrslFLR05mIP InnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760556318; x=1761161118; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pfKLoaIE6m6YAqIlpySfZ0ebyLDDrsoOWfky8dWsuu8=; b=CM35Qmo8tEvarlra/aroV6XkKSDJrMHPBTq1tj0qEe6Q4unCSwV7SU+fOY2BtKBW23 uGeaLMv2xrOIWZENFh4InToMi9Jua8UqJoj6QR+3ecDECya1NqgL4GVoyju+vDR+XP47 9OO5WitfltrynuRtibMZRZ16ZEeGvMfrAtkFyJk8Hha7mRA04vWiIeZKALRFyMv/U7Qr yK0EqzoacRIjM7lfV6cc+nU73O7intqbQ6cmU5kLJtdoItqbuNL/Kr+1SYa1GeorGg1n RHD2zVVhqdzqhSvqmygC6dBNPa81X6VB1Oo/F2iyN2ijVggHZNiUq1nLhow/9cMOHtmy MUaw== X-Forwarded-Encrypted: i=1; AJvYcCWOOtTIuY7hzfoIw+vZTn1bWVUbX/zPCvE4WUAPb7LV07WTd/4+J8uij5eHcX6+uchw/z/U5wpFSSk3oVk=@vger.kernel.org X-Gm-Message-State: AOJu0YzmpBbl3LX2jx+5nM6zXA1D0E+n/+S8CE3WDsUlPELyfO/MuPHn dYZKb8PEFnuRJfL+WDzBTvM6VeYAfVqA5st8JE/ZsybvYIUSknqp29EC X-Gm-Gg: ASbGnct5ta4Imdp+hBA7aEG8W0xvqNGgD/LTPJ5QhGCG8GEb9SaxcF6F/RFh6Nj0+Gm 4TPVGUgTeL+D6SmDN8dReCHnCHZdlCAUATOlhCSs1nIF9MkWAC6IBxGmXHSW/CxcbtaE1Fw6Fbx FrkZsETFHdL/0JjVc6MdneaNvmGNrP4rLYjnEWeBUzz49hNv5edvTAxd1YqWuFVYPi0HgS1+LmO WD2+GTIAV1OELAVueu0HoRumR7KNmqeguNn2g6z17dZKMwhwncpTqxLf2Vto6rRdZmUK9nmkd1G EIrABhb/rZ2U1Mi5nK8sJm8Z7sLA5Bou0jpA3xMU0nm7up/Jj1XWUEOOATLBfcioAArst6J51Yk 3b4PRIn0F9AZCWO/5arVUL0mxl4WTWb8+Q7GVqGdU+RGc/zhEeQPgs5ORtdxEDsMkuyQmK3lq5n N2D1sLo9uK8ghwnlcjB5YKmcz0KvrGQvoQiBvkRJ62Sr+KJDMk0kdFZiTEOaLPfT5p85iipwGVK 1LD4W1Od/APdE2AwpyMD87Kl8RBw8OzahzOyx2CETD+1sFYC/kE X-Google-Smtp-Source: AGHT+IEyJ4wXPRNVHomX6M4YCh9mUoGoZWRpoOJh8NtSqhKRuXmvyAnybqGcRN9E15RRAuo/qFdyWw== X-Received: by 2002:a05:622a:5809:b0:4dd:8dcc:17f5 with SMTP id d75a77b69052e-4e6ead15d7dmr389497071cf.28.1760556317628; Wed, 15 Oct 2025 12:25:17 -0700 (PDT) Received: from 136.1.168.192.in-addr.arpa ([2600:4808:6353:5c00:8573:f4c5:e7a9:9cd9]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87c012b165asm24076996d6.59.2025.10.15.12.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Oct 2025 12:25:17 -0700 (PDT) From: Tamir Duberstein Date: Wed, 15 Oct 2025 15:24:38 -0400 Subject: [PATCH v17 08/11] rust: pci: use `kernel::fmt` Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251015-cstr-core-v17-8-dc5e7aec870d@gmail.com> References: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> In-Reply-To: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" , Luis Chamberlain , Russ Weight , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Christian Brauner , Alexander Viro , Jan Kara , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760556296; l=872; i=tamird@gmail.com; h=from:subject:message-id; bh=Kd0EzPTdfyblnmo1RxE7jLLbIDYVUJvE5DzKX0nK5ME=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QEhfQevpl/RzFxxXnpbY5oPfpzKL1+vKftdtwGLN29QKlCkDGEX76xd9UdrJV0rHFhQ062F1yi6 DHt74TqCP1g4= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc Reduce coupling to implementation details of the formatting machinery by avoiding direct use for `core`'s formatting traits and macros. This backslid in commit ed78a01887e2 ("rust: pci: provide access to PCI Class and Class-related items"). Signed-off-by: Tamir Duberstein Acked-by: Danilo Krummrich --- rust/kernel/pci/id.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rust/kernel/pci/id.rs b/rust/kernel/pci/id.rs index 7f2a7f57507f..5f5d59ff49fc 100644 --- a/rust/kernel/pci/id.rs +++ b/rust/kernel/pci/id.rs @@ -4,8 +4,7 @@ //! //! This module contains PCI class codes, Vendor IDs, and supporting types. =20 -use crate::{bindings, error::code::EINVAL, error::Error, prelude::*}; -use core::fmt; +use crate::{bindings, error::code::EINVAL, error::Error, fmt, prelude::*}; =20 /// PCI device class codes. /// --=20 2.51.0 From nobody Fri Dec 19 20:51:15 2025 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54CDF3112DA for ; Wed, 15 Oct 2025 19:25:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556324; cv=none; b=eXP2eOoR8bXYbrkR8psUdzDe0WEaFnG2GjvqeokIRmoYjxTVUjW8qougAHmIsOTw8x/VcpKMqxbRtWjlCvjlcqwD34+rpbf71pDaoa/5CCr/DR+GTmMVSrGsQec++UUw5fBSwWDWjDFZNomKliSL5FAWB18w+6aVfulld4iQjrc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556324; c=relaxed/simple; bh=5hkdJMBXvyM5ROn0CqVVfhpYPBMFyjtfSpETEaraIms=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N331qd7h5ctR9xJmeMhf5mfBYpijpnCOJZtGDaWuVXUSFH68JyVyXxgjZaqbLfxknfpNPQvgIFeb0YmZR4W8cO8sSVJ2+dC32hLo8N/h/Uy40l2lddP9EPGymjZ+ugy8yPvAkpHx8MOzY7XlQ2Kj2dNN1Yo0Re8SSKW/BMs61W8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EAWmy3km; arc=none smtp.client-ip=209.85.219.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EAWmy3km" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-8738c6fdbe8so22082736d6.1 for ; Wed, 15 Oct 2025 12:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760556320; x=1761161120; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Zfr+jg9qjRBK3esGQQzBD5L0g4VK44y370TXRFAq7lU=; b=EAWmy3kml5F4+VbSFVMMwmSbTG1JPrXc25HIJ7wTREx+dvdcv925LAr+3H/MK2yo8J 3b9T0AX5Ziu4paKrSgcqxGTenO1PwPrhrzkoNEbyIxoWWF+Aq3cWbc+5V2kh4UQ7AA8E VQsfzcDkX92HSyd5p5oao9KAr6R1RVTKp7/itf1AdXmq07NlGuakb3PvyX35cHUwmxC2 6fjYPFDV97+fr4if6sLN4cmCN0hWUKM1L9CBEYXRKwNeu9kOCNzsg2+6Ek2mJsUJ0RPP OkPwUg+mIY2Pch+B8q08Kn7Z3MuD/FVy14virXSGtKUv+g0ES3E3mh0HVDExPtD2Wfh/ SO+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760556320; x=1761161120; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Zfr+jg9qjRBK3esGQQzBD5L0g4VK44y370TXRFAq7lU=; b=TZNn6DDWz5D8+PEDDNvoeOHC5nEI9pjk1pgYkVgwh5bm1bCZL1KBDjEab3x7BvAQs1 vQm4HshSv1I2uamFdEwLJJxIAJjmVu6LYb4YidG41HBJ9TyzZk5qmHtEEduGqzzMSayK v/f/62wwxYMg8/xHQ42KfNfuruORwNrj14LBYpxAG4oHRaIfGXH8jtqWgYecvlnC+yrn HcIUD5H0P0UEUnO4u2jmtDqA17iP7QdNZZO0eBgEfss5JSe5IeVkRkbJyxfJ7W53Zbkk mX1LCm8PTvv6sUfsONWQ3KsXZAaL9o6DjnJhYdZaP76Vz3CrW0xLbkKXRO97VFchvl3t 7EXg== X-Forwarded-Encrypted: i=1; AJvYcCUqqcLUdneyZ75X+ZfEv7vxa6aju7WlRglRNzoVvkex6LwDVB88sen4LUzbl1vIXD2LVDCUmB5W0MTu3IM=@vger.kernel.org X-Gm-Message-State: AOJu0YxGMPLTFSClo6HJQCcPIaYKYgZ08j46RZryeUu8ZICw3H3KoaI2 C5Y5Yg2qLUwwP8MBtGFyERffJUTJh0Tz5n8bgMlrczMMYXLT3giiWX43 X-Gm-Gg: ASbGncvGnnThP09IwC7Mknb2+rkdUp1XGv+yoTcyD30xlTryPvQXB9WN6AfIoVdT0E/ C8CbN+rRloL18vVLyy7BCCLLXC/UeUaWGnUGY75ol/mhs5f2P14Hhdec2zD0jO7VKatmIqsCcs3 dhjoan9dk8lQA7qJbpI5UuRs9tyVaACTLU+NmE4tBK6vpRzBgW0SeYqg2XzY2qEV6Tn2Tni34/Z ertidhH6gmfqVlx6YOLTPP32nkjgz7weMgSAaJ3dK2xaVv3P7ZkElwEP2viHMPDApm/KiPyrRlJ tBU/fA/gNQzYByJU1oLUMLn0nh5QgsKzYxLMdsPRllIJQ9A9s66lr4yEK5xJj/4FE+ybV8Ktahn qa96jU1TxRMJhopqkwO5rUgBi8tST6MXSOR23PzyrDRqB7Nst9bdSfg6E3U0VyfVJdytaULWExT PseFmQUxgKh9kxA7G0Yu1dtm5y+FZL9CeXeQVehCHaC0pZIU5LV1CS2BZZALpAE+mLMGUq+fAJ9 A/CXbK413TXjxFTnhaGnSO12PjblwXuKIBY4q6NyZgdai4NJFOP0fXGiivN7Rs= X-Google-Smtp-Source: AGHT+IEDOgFM0nazGEEfzHtKDS647mvDkfCfJSWTYyfnR0K2d3p2LPiGQli6GsrPQ32Cigz0HxquCQ== X-Received: by 2002:ad4:5fc5:0:b0:787:f736:bc66 with SMTP id 6a1803df08f44-87c0c5cb92fmr20009666d6.1.1760556320049; Wed, 15 Oct 2025 12:25:20 -0700 (PDT) Received: from 136.1.168.192.in-addr.arpa ([2600:4808:6353:5c00:8573:f4c5:e7a9:9cd9]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87c012b165asm24076996d6.59.2025.10.15.12.25.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Oct 2025 12:25:19 -0700 (PDT) From: Tamir Duberstein Date: Wed, 15 Oct 2025 15:24:39 -0400 Subject: [PATCH v17 09/11] rust: remove spurious `use core::fmt::Debug` Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251015-cstr-core-v17-9-dc5e7aec870d@gmail.com> References: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> In-Reply-To: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" , Luis Chamberlain , Russ Weight , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Christian Brauner , Alexander Viro , Jan Kara , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760556296; l=620; i=tamird@gmail.com; h=from:subject:message-id; bh=5hkdJMBXvyM5ROn0CqVVfhpYPBMFyjtfSpETEaraIms=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QA49f7ifUr2XwLcazgyI6X2saN5gtmXaaA6IvRCW2zqJXH2aWsvrcTeWwyt5IimaZuePXX9+Xm5 hOtGKK/bcVgE= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc We want folks to use `kernel::fmt` but this is only used for `derive` so can be removed entirely. This backslid in commit ea60cea07d8c ("rust: add `Alignment` type"). Signed-off-by: Tamir Duberstein Reviewed-by: Alice Ryhl --- rust/kernel/ptr.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/rust/kernel/ptr.rs b/rust/kernel/ptr.rs index 2e5e2a090480..e3893ed04049 100644 --- a/rust/kernel/ptr.rs +++ b/rust/kernel/ptr.rs @@ -2,7 +2,6 @@ =20 //! Types and functions to work with pointers and addresses. =20 -use core::fmt::Debug; use core::mem::align_of; use core::num::NonZero; =20 --=20 2.51.0 From nobody Fri Dec 19 20:51:15 2025 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8ED331194A for ; Wed, 15 Oct 2025 19:25:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556327; cv=none; b=bGUS76SaIUrBl/J+k8539GdVzJ4ESrEVGPMNdsX16WxRVDezzcUKYTI81dIDr3BGFPkjpsOo3frOvhVgx/1baVYAPU7bMMgIdHOLGBT/iUWTphEIMAsPZJa2c554JZKx8kOyA0UPl7OALb3dZA7ZqDSGkDQ7rxPq6mPciQVi4sE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556327; c=relaxed/simple; bh=56qk4oXZToDCRjUenEK2FztuuA7wWME8i0VRUMgg2i0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tvxLeEvxZgUjTOg3BB2p8vyVsfMUOQxzSQHwlmh5/6h9PNqabdczi+Hnx77AaaXY1s2/kebDGGD5xH9vRZWbVp1LP8tuT2PCOjR2z+7ImEZ09banGnq8WHHjX0XUTSHtO0Ma/cHNbXWAlnYFOoBP7FV+ldYQTCcerxThBoLfvW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aJKfS4+r; arc=none smtp.client-ip=209.85.219.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aJKfS4+r" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-8738c6fdbe8so22083376d6.1 for ; Wed, 15 Oct 2025 12:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760556323; x=1761161123; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HiEqMd3xsyy/ksNexRFAfYvN9OsAs0xxvpBCNib+PpM=; b=aJKfS4+r8JBaaDfMiyH0Jys+JShqPPEVAYbpK3QIdz9AzsJlnj1Lyc/18i2xsdrDoG +2DY4EsAA8sP+breQ9fI4CFig4QYBVZFaYN6BXXPRZ1dSm42rShuchmO5ry2+kCr3Dez dc/W01KGJVaPcRwtKbMPUNETLZPSjDSfxbQRTQxuQ448fWWMybIuXuvwpWf6dM6GYMGT /gQa3i1MW6TC+ykI1Nad9QC/u9AahxYqtL8VGRyP0Q8VTOt7TwQVJOCrK2Zd9CEsJ4AE ZAve20Bc4r7IsxTWu01NdPAV5GuZE0miixEFqE4eMG9rjJyYZXQvd0YpSBmFdTkytyRl mmEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760556323; x=1761161123; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HiEqMd3xsyy/ksNexRFAfYvN9OsAs0xxvpBCNib+PpM=; b=UCf1kCp3/O9Ib49ynq/iJ7oIKXqZQPHNRdTw3uko3zsTboLwJfa/b4ogEARWmEdbpR rVJ04+2kZLEpXsG/WH/r0vTSkHKEZIkjtUUh3UlzmgaTDPmwX3e0FDnnzgsAl1/QO4gV sgqiFxK9FHVGrrxfGjaYNNGV5/VHW3DuFgYf4TvxgVKo6Cd7JRHbROcCJ05H5loF/uju DPVon6ywrEyb61m1ezDRbTQGO/lEfwDczZshg6Fvnx9pAfHPivf5TctnqZbxK9SSmGVw 8p7rPuM9nN2ffLHJ9fa4ye1BCuBP3btoSV4BdnHIJ88G2l2aLsMVCvdQEHWydMzfUZlg CtOA== X-Forwarded-Encrypted: i=1; AJvYcCUXZ/uIYwKK0RjtAglgklKLlRJg4xKX/EQfN90yPY7e6LH5mPn0q4Shi7OyBGmojb5p5jcqrk2LW9rmZZQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxQmk/UEFeYt5o0khjoTG/jUawiG3Njxe2hoPbI/MYPn0brP0Ej 66E9JJRbvN1zoQ/pxKuJfUI8UQxaHICOj6r5vKHo2K4TgYO6UdNmn3f7 X-Gm-Gg: ASbGnct63fs2e/jiYmj1slivCiDy8qi/GRTERk9vEYWQq/NI3gRBvzXWjY+/ujJP/Jg MthEGNp6Q1a9qVSizin9rjGX9HNFtumUhsqXkqYTTZHmx+7BTRZpbDlMegZzsbHH5r72RT1JVe1 /IPoHAylfmbS0onUlkaKr5uiFw1q1waXaSLN5luDp1uZxnNx07a97ty0V7W7e6vfaPaF55S3NnL fzeN+YyG/R8/D/xEaDUauJcxPUdNRLLuuf4LDYrhIe+0fknHs0TajQqR/ZaM8ME6eKxOl0Ntc/y EGvOd7gm8xgboLj+7Ik2WHS9QBGKyb5UoswOymUw4ML+PxwEkykIYo717QnNqyYc+pewMhEeDbx 9CCRbhc1c+caD7YOFzLAzGozJdqB3jSdwqnrj5m1yFWmQactw6PKQzWSG7CsL6QAAbRl18SsowD RUAGx3d+gXFwTnw1V/IlLY+akB9JDf7vtpNxrPJKaNKy7lGvhaIE4GwUY3apB2Az0ml9jkgGxnx n8MEyk39ZENrrfBRb4fKgr1pvnFobyWvk30GUnQvY9xSqFPct+gfqTKeKYO7bY= X-Google-Smtp-Source: AGHT+IFQKa+FZlLitOI+81eU92YyCY7iySPL5/OZykjhtsqwND3gt1523zwGXbz3ei7VPR6ZEbkqWw== X-Received: by 2002:a05:6214:19c6:b0:78e:8752:826e with SMTP id 6a1803df08f44-87c0c6d0b3amr17673706d6.7.1760556322438; Wed, 15 Oct 2025 12:25:22 -0700 (PDT) Received: from 136.1.168.192.in-addr.arpa ([2600:4808:6353:5c00:8573:f4c5:e7a9:9cd9]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87c012b165asm24076996d6.59.2025.10.15.12.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Oct 2025 12:25:21 -0700 (PDT) From: Tamir Duberstein Date: Wed, 15 Oct 2025 15:24:40 -0400 Subject: [PATCH v17 10/11] rust: support formatting of foreign types Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251015-cstr-core-v17-10-dc5e7aec870d@gmail.com> References: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> In-Reply-To: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" , Luis Chamberlain , Russ Weight , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Christian Brauner , Alexander Viro , Jan Kara , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760556296; l=11126; i=tamird@gmail.com; h=from:subject:message-id; bh=56qk4oXZToDCRjUenEK2FztuuA7wWME8i0VRUMgg2i0=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QFrNY4+4m4vAKukuSLoJFRCfJDb+Tq/Q2hqOOgtZg/QKSE2wld7ttq7E3MYm2zyTtcUPVBf4tcF KzbGgVn8QZwU= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc Introduce a `fmt!` macro which wraps all arguments in `kernel::fmt::Adapter` and a `kernel::fmt::Display` trait. This enables formatting of foreign types (like `core::ffi::CStr`) that do not implement `core::fmt::Display` due to concerns around lossy conversions which do not apply in the kernel. Suggested-by: Alice Ryhl Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/t= opic/Custom.20formatting/with/516476467 Acked-by: Greg Kroah-Hartman Reviewed-by: Alice Ryhl Acked-by: Danilo Krummrich Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- rust/kernel/fmt.rs | 87 +++++++++++++++++++++++++++++++++++++++++++++- rust/kernel/prelude.rs | 3 +- rust/macros/fmt.rs | 94 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ rust/macros/lib.rs | 19 ++++++++++ rust/macros/quote.rs | 7 ++++ 5 files changed, 207 insertions(+), 3 deletions(-) diff --git a/rust/kernel/fmt.rs b/rust/kernel/fmt.rs index 0306e8388968..84d634201d90 100644 --- a/rust/kernel/fmt.rs +++ b/rust/kernel/fmt.rs @@ -4,4 +4,89 @@ //! //! This module is intended to be used in place of `core::fmt` in kernel c= ode. =20 -pub use core::fmt::{Arguments, Debug, Display, Error, Formatter, Result, W= rite}; +pub use core::fmt::{Arguments, Debug, Error, Formatter, Result, Write}; + +/// Internal adapter used to route allow implementations of formatting tra= its for foreign types. +/// +/// It is inserted automatically by the [`fmt!`] macro and is not meant to= be used directly. +/// +/// [`fmt!`]: crate::prelude::fmt! +#[doc(hidden)] +pub struct Adapter(pub T); + +macro_rules! impl_fmt_adapter_forward { + ($($trait:ident),* $(,)?) =3D> { + $( + impl $trait for Adapter { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + let Self(t) =3D self; + $trait::fmt(t, f) + } + } + )* + }; +} + +use core::fmt::{Binary, LowerExp, LowerHex, Octal, Pointer, UpperExp, Uppe= rHex}; +impl_fmt_adapter_forward!(Debug, LowerHex, UpperHex, Octal, Binary, Pointe= r, LowerExp, UpperExp); + +/// A copy of [`core::fmt::Display`] that allows us to implement it for fo= reign types. +/// +/// Types should implement this trait rather than [`core::fmt::Display`]. = Together with the +/// [`Adapter`] type and [`fmt!`] macro, it allows for formatting foreign = types (e.g. types from +/// core) which do not implement [`core::fmt::Display`] directly. +/// +/// [`fmt!`]: crate::prelude::fmt! +pub trait Display { + /// Same as [`core::fmt::Display::fmt`]. + fn fmt(&self, f: &mut Formatter<'_>) -> Result; +} + +impl Display for &T { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + Display::fmt(*self, f) + } +} + +impl core::fmt::Display for Adapter<&T> { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + let Self(t) =3D self; + Display::fmt(t, f) + } +} + +macro_rules! impl_display_forward { + ($( + $( { $($generics:tt)* } )? $ty:ty $( { where $($where:tt)* } )? + ),* $(,)?) =3D> { + $( + impl$($($generics)*)? Display for $ty $(where $($where)*)? { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + core::fmt::Display::fmt(self, f) + } + } + )* + }; +} + +impl_display_forward!( + bool, + char, + core::panic::PanicInfo<'_>, + Arguments<'_>, + i128, + i16, + i32, + i64, + i8, + isize, + str, + u128, + u16, + u32, + u64, + u8, + usize, + {} crate::sync::Arc {where crate::sync::Arc: core::fm= t::Display}, + {} crate::sync::UniqueArc {where crate::sync::UniqueArc<= T>: core::fmt::Display}, +); diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs index 198d09a31449..26424ad7e989 100644 --- a/rust/kernel/prelude.rs +++ b/rust/kernel/prelude.rs @@ -25,7 +25,7 @@ pub use crate::alloc::{flags::*, Box, KBox, KVBox, KVVec, KVec, VBox, VVec= , Vec}; =20 #[doc(no_inline)] -pub use macros::{export, kunit_tests, module, vtable}; +pub use macros::{export, fmt, kunit_tests, module, vtable}; =20 pub use pin_init::{init, pin_data, pin_init, pinned_drop, InPlaceWrite, In= it, PinInit, Zeroable}; =20 @@ -36,7 +36,6 @@ pub use super::dbg; pub use super::{dev_alert, dev_crit, dev_dbg, dev_emerg, dev_err, dev_info= , dev_notice, dev_warn}; pub use super::{pr_alert, pr_crit, pr_debug, pr_emerg, pr_err, pr_info, pr= _notice, pr_warn}; -pub use core::format_args as fmt; =20 pub use super::{try_init, try_pin_init}; =20 diff --git a/rust/macros/fmt.rs b/rust/macros/fmt.rs new file mode 100644 index 000000000000..2f4b9f6e2211 --- /dev/null +++ b/rust/macros/fmt.rs @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: GPL-2.0 + +use proc_macro::{Ident, TokenStream, TokenTree}; +use std::collections::BTreeSet; + +/// Please see [`crate::fmt`] for documentation. +pub(crate) fn fmt(input: TokenStream) -> TokenStream { + let mut input =3D input.into_iter(); + + let first_opt =3D input.next(); + let first_owned_str; + let mut names =3D BTreeSet::new(); + let first_span =3D { + let Some((mut first_str, first_span)) =3D (match first_opt.as_ref(= ) { + Some(TokenTree::Literal(first_lit)) =3D> { + first_owned_str =3D first_lit.to_string(); + Some(first_owned_str.as_str()).and_then(|first| { + let first =3D first.strip_prefix('"')?; + let first =3D first.strip_suffix('"')?; + Some((first, first_lit.span())) + }) + } + _ =3D> None, + }) else { + return first_opt.into_iter().chain(input).collect(); + }; + + // Parse `identifier`s from the format string. + // + // See https://doc.rust-lang.org/std/fmt/index.html#syntax. + while let Some((_, rest)) =3D first_str.split_once('{') { + first_str =3D rest; + if let Some(rest) =3D first_str.strip_prefix('{') { + first_str =3D rest; + continue; + } + if let Some((name, rest)) =3D first_str.split_once('}') { + first_str =3D rest; + let name =3D name.split_once(':').map_or(name, |(name, _)|= name); + if !name.is_empty() && !name.chars().all(|c| c.is_ascii_di= git()) { + names.insert(name); + } + } + } + first_span + }; + + let adapter =3D quote_spanned!(first_span =3D> ::kernel::fmt::Adapter); + + let mut args =3D TokenStream::from_iter(first_opt); + { + let mut flush =3D |args: &mut TokenStream, current: &mut TokenStre= am| { + let current =3D std::mem::take(current); + if !current.is_empty() { + let (lhs, rhs) =3D (|| { + let mut current =3D current.into_iter(); + let mut acc =3D TokenStream::new(); + while let Some(tt) =3D current.next() { + // Split on `=3D` only once to handle cases like `= a =3D b =3D c`. + if matches!(&tt, TokenTree::Punct(p) if p.as_char(= ) =3D=3D '=3D') { + names.remove(acc.to_string().as_str()); + // Include the `=3D` itself to keep the handli= ng below uniform. + acc.extend([tt]); + return (Some(acc), current.collect::()); + } + acc.extend([tt]); + } + (None, acc) + })(); + args.extend(quote_spanned!(first_span =3D> #lhs #adapter(&= #rhs))); + } + }; + + let mut current =3D TokenStream::new(); + for tt in input { + match &tt { + TokenTree::Punct(p) if p.as_char() =3D=3D ',' =3D> { + flush(&mut args, &mut current); + &mut args + } + _ =3D> &mut current, + } + .extend([tt]); + } + flush(&mut args, &mut current); + } + + for name in names { + let name =3D Ident::new(name, first_span); + args.extend(quote_spanned!(first_span =3D> , #name =3D #adapter(&#= name))); + } + + quote_spanned!(first_span =3D> ::core::format_args!(#args)) +} diff --git a/rust/macros/lib.rs b/rust/macros/lib.rs index fa847cf3a9b5..793f712dbf7c 100644 --- a/rust/macros/lib.rs +++ b/rust/macros/lib.rs @@ -15,6 +15,7 @@ mod quote; mod concat_idents; mod export; +mod fmt; mod helpers; mod kunit; mod module; @@ -201,6 +202,24 @@ pub fn export(attr: TokenStream, ts: TokenStream) -> T= okenStream { export::export(attr, ts) } =20 +/// Like [`core::format_args!`], but automatically wraps arguments in [`ke= rnel::fmt::Adapter`]. +/// +/// This macro allows generating `fmt::Arguments` while ensuring that each= argument is wrapped with +/// `::kernel::fmt::Adapter`, which customizes formatting behavior for ker= nel logging. +/// +/// Named arguments used in the format string (e.g. `{foo}`) are detected = and resolved from local +/// bindings. All positional and named arguments are automatically wrapped. +/// +/// This macro is an implementation detail of other kernel logging macros = like [`pr_info!`] and +/// should not typically be used directly. +/// +/// [`kernel::fmt::Adapter`]: ../kernel/fmt/struct.Adapter.html +/// [`pr_info!`]: ../kernel/macro.pr_info.html +#[proc_macro] +pub fn fmt(input: TokenStream) -> TokenStream { + fmt::fmt(input) +} + /// Concatenate two identifiers. /// /// This is useful in macros that need to declare or reference items with = names diff --git a/rust/macros/quote.rs b/rust/macros/quote.rs index acc140c18653..ddfc21577539 100644 --- a/rust/macros/quote.rs +++ b/rust/macros/quote.rs @@ -48,6 +48,7 @@ macro_rules! quote_spanned { ($span:expr =3D> $($tt:tt)*) =3D> {{ let mut tokens =3D ::proc_macro::TokenStream::new(); { + #[allow(unused_variables)] let span =3D $span; quote_spanned!(@proc tokens span $($tt)*); } @@ -146,6 +147,12 @@ macro_rules! quote_spanned { )]); quote_spanned!(@proc $v $span $($tt)*); }; + (@proc $v:ident $span:ident & $($tt:tt)*) =3D> { + $v.extend([::proc_macro::TokenTree::Punct( + ::proc_macro::Punct::new('&', ::proc_macro::Spacing::Alone), + )]); + quote_spanned!(@proc $v $span $($tt)*); + }; (@proc $v:ident $span:ident _ $($tt:tt)*) =3D> { $v.extend([::proc_macro::TokenTree::Ident( ::proc_macro::Ident::new("_", $span), --=20 2.51.0 From nobody Fri Dec 19 20:51:15 2025 Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C177731197D for ; Wed, 15 Oct 2025 19:25:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556330; cv=none; b=r+jJqT9thUtVyPBUzxfM4fqvDYBIkW6EHyxXMsa6YnjUjh6jFyMoOjha3y1aHz+U9L84Qo0/c7Qmuyc34qoO0HYa2ixgVpioVZI2RFzgAJCKShkXQNzgTM8v1cJMGF3Hf0F0pJW0y5sBwNfzJOm53mnhD7yFZgCXdbJdTHuHC9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760556330; c=relaxed/simple; bh=nvdBegPr5g0BOjooHE/OjR4xevUEX/01pjqc4fPOaZ0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LCHem5RPoEVEjhc4ouihS4d1Mr5OS0dOlWALROLTyXaIIkxu2jwhN52Z9g/ko3ULF81s0C4YpDDyOV8g3m71EGdpcCwYsydG72YlUuMhjmtcqnDrMp9eHtfrZhXeRYyoocjaZw2GmPz0c1Y8zS0iORMrFXMLF3owSILzhsII0PQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=J10/H5ih; arc=none smtp.client-ip=209.85.219.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J10/H5ih" Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-87c103928ffso1692416d6.1 for ; Wed, 15 Oct 2025 12:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760556325; x=1761161125; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=9XW0tmdeJX0WAw5oKKpGucFhZ7e0wmYNmkFyTBXw3GM=; b=J10/H5ih2vaxQLVNs+iWJbvVBRki/6kCH/dBVVK+Ao8NWQOfRw9ahSgwfm77cEmk5j Ns5r33LoQCRXUmrhOSUHASccWDj1EM9tdH3UVkvzc4jtCcqRcd8SEo4hA+w4x+TRtlX3 mzz5feAWgeVlk2MVm19VK4GPs8Javf/2vVM62mWHYpO3kgalfkW1zyhNx8zyBUoXG1G0 XDujWs9eV4u3nObSQRbMh5DS1XPg3hMqxsHPmLxH1lzHVQiUtiiKWS91JY/twiq9xgtR KYUTenQ43C5hxZzlK/WzMHqyd7voxm93vS13K1AAPHs4F4m76A4WAJ8jpS2a0tzgWqJh +jIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760556325; x=1761161125; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9XW0tmdeJX0WAw5oKKpGucFhZ7e0wmYNmkFyTBXw3GM=; b=cZPhj5ahRXrq0ldSa9gSmtJ/NKsH5SmPqFDr+mF9KQ9sqeDhyBHwUCbCXHfjCDgAdP u3b0h4YZDL5nAHxy7RwjFkZo6Fn8AfZwLxRBhKM1UiruAJ3yoGFL0FaOk3Kkcjzezq1h U0lkx2Qow+/2KfA9CD5YU9K/wG9cVoGGY6zFpYzzuyiM2TyHOdE+e205L3xjxmPM2nXz 6M5r+tomwIHfPxgelpkeepEuKOcVNNH/PiGjLe+qJ16yC2olUXrY0X3hg+T4Ydw8qWrG 58+m8/AhPUTy91ZLGxSuldFXa04P//aHSyF64emAUhIreUdC/FUS0lFR/TaMEUWdF8YK foEg== X-Forwarded-Encrypted: i=1; AJvYcCWJw61onf9SgzDN0KP+pFWFBmkGVLq5yqhWnfzHD/l6mshgMjIVTTnuToGdYuGPYzKBuL1hv8wbtLeo3so=@vger.kernel.org X-Gm-Message-State: AOJu0Yz6AiZiSNmEgVZ+kMBr7I+9hG2EsnqQE5of9qvk/tziYO4ccazQ w9oIIUiiyIn4DU38GgAkFcW+odqqPfAdT57yfnhq4pCzlTwM3bteDwo9 X-Gm-Gg: ASbGncufpahcC3y91txkijEWV2BRMja8Hwanxrxq7+Z+j7kX65FJP3v1o8yjfp5iXSp 54Dua1zXZ5tIoDiyEeCQ0YNKU5yJ6/OFsRzkN6h5fSCtSpCdXI5DUgJSRWof+uSgpxCBSO6xE4R FYn4h5w+HxBDorAsoNHbiZVS/yfhi8kMTT9JX69cIhdvT1iEr9jgaTuTKLaaVQdlkQrFTujjyIC DAR0bM8qvzq5jNE1hd6MxNh+Z3vKHqZQ/txGoq/mFcS0SsNNtbQeDDeeyU7WylZOepmWVsWPIpq GBKgSRyt0QhEpKRbVqqutVdK74skRox2+TclotjcwtNn942LzaaJCyBsMzFU14fNZPNKJcwIxEF yyryxlu2iGYXKbNiEzf7JbykXQv+2hImRSu2S/pzexvtz9USEwo8/kD+EwzujAIAtXHad2ao3M4 pKouEw16Jd7uR/FMb3FGi4SBNrAKX4k8xp4pmWNHWuLqVOse1crbGiWzaxhNOk8semOL18rkFJZ Fr4IzDdY1ikh79IZZquwrUa/9BJC46RsN984CTL1PFv4LzaWn75 X-Google-Smtp-Source: AGHT+IGGQ7XdtRNAlmKNogkydmo5LFNEP/SqHh3fLon+Mnecpn0H+aQZsV0/rxvkQO23ncFdcCMpdw== X-Received: by 2002:a05:6214:2b85:b0:87c:81f:31cd with SMTP id 6a1803df08f44-87c081f3c74mr37741446d6.16.1760556324691; Wed, 15 Oct 2025 12:25:24 -0700 (PDT) Received: from 136.1.168.192.in-addr.arpa ([2600:4808:6353:5c00:8573:f4c5:e7a9:9cd9]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87c012b165asm24076996d6.59.2025.10.15.12.25.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Oct 2025 12:25:24 -0700 (PDT) From: Tamir Duberstein Date: Wed, 15 Oct 2025 15:24:41 -0400 Subject: [PATCH v17 11/11] rust: replace `CStr` with `core::ffi::CStr` Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251015-cstr-core-v17-11-dc5e7aec870d@gmail.com> References: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> In-Reply-To: <20251015-cstr-core-v17-0-dc5e7aec870d@gmail.com> To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" , Luis Chamberlain , Russ Weight , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Christian Brauner , Alexander Viro , Jan Kara , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760556296; l=26212; i=tamird@gmail.com; h=from:subject:message-id; bh=nvdBegPr5g0BOjooHE/OjR4xevUEX/01pjqc4fPOaZ0=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QEgxLNdSXOv2WF/D1sQEp2iRIrW74VbXGlf6VogHnsNT3qdLthlBCRIg41WjWi9YjYORWMt+CyT 1OkLNzQAr5Qc= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc `kernel::ffi::CStr` was introduced in commit d126d2380131 ("rust: str: add `CStr` type") in November 2022 as an upstreaming of earlier work that was done in May 2021[0]. That earlier work, having predated the inclusion of `CStr` in `core`, largely duplicated the implementation of `std::ffi::CStr`. `std::ffi::CStr` was moved to `core::ffi::CStr` in Rust 1.64 in September 2022. Hence replace `kernel::str::CStr` with `core::ffi::CStr` to reduce our custom code footprint, and retain needed custom functionality through an extension trait. Add `CStr` to `ffi` and the kernel prelude. Link: https://github.com/Rust-for-Linux/linux/commit/faa3cbcca03d0dec8f8e43= f1d8d5c0860d98a23f [0] Acked-by: Greg Kroah-Hartman Reviewed-by: Alice Ryhl Acked-by: Danilo Krummrich Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- drivers/android/binder/stats.rs | 2 +- rust/ffi.rs | 2 + rust/kernel/device.rs | 1 + rust/kernel/error.rs | 2 + rust/kernel/firmware.rs | 9 +- rust/kernel/prelude.rs | 4 +- rust/kernel/seq_file.rs | 2 +- rust/kernel/str.rs | 395 +++++++++---------------------------= ---- rust/kernel/sync/condvar.rs | 2 +- rust/kernel/sync/lock.rs | 2 +- rust/kernel/sync/lock/global.rs | 2 +- 11 files changed, 110 insertions(+), 313 deletions(-) diff --git a/drivers/android/binder/stats.rs b/drivers/android/binder/stats= .rs index 10c43679d5c3..037002651941 100644 --- a/drivers/android/binder/stats.rs +++ b/drivers/android/binder/stats.rs @@ -61,7 +61,7 @@ pub(crate) fn debug_print(&self, prefix: &str, m: &SeqFil= e) { =20 mod strings { use core::str::from_utf8_unchecked; - use kernel::str::CStr; + use kernel::str::{CStr, CStrExt as _}; =20 extern "C" { static binder_command_strings: [*const u8; super::BC_COUNT]; diff --git a/rust/ffi.rs b/rust/ffi.rs index d60aad792af4..f961e9728f59 100644 --- a/rust/ffi.rs +++ b/rust/ffi.rs @@ -46,3 +46,5 @@ macro_rules! alias { } =20 pub use core::ffi::c_void; + +pub use core::ffi::CStr; diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs index 1321e6f0b53c..0b13aa60b685 100644 --- a/rust/kernel/device.rs +++ b/rust/kernel/device.rs @@ -13,6 +13,7 @@ =20 #[cfg(CONFIG_PRINTK)] use crate::c_str; +use crate::str::CStrExt as _; =20 pub mod property; =20 diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index 1c0e0e241daa..258b12afdcba 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -182,6 +182,8 @@ pub fn name(&self) -> Option<&'static CStr> { if ptr.is_null() { None } else { + use crate::str::CStrExt as _; + // SAFETY: The string returned by `errname` is static and `NUL= `-terminated. Some(unsafe { CStr::from_char_ptr(ptr) }) } diff --git a/rust/kernel/firmware.rs b/rust/kernel/firmware.rs index 94e6bb88b903..376e7e77453f 100644 --- a/rust/kernel/firmware.rs +++ b/rust/kernel/firmware.rs @@ -4,7 +4,14 @@ //! //! C header: [`include/linux/firmware.h`](srctree/include/linux/firmware.= h) =20 -use crate::{bindings, device::Device, error::Error, error::Result, ffi, st= r::CStr}; +use crate::{ + bindings, + device::Device, + error::Error, + error::Result, + ffi, + str::{CStr, CStrExt as _}, +}; use core::ptr::NonNull; =20 /// # Invariants diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs index 26424ad7e989..33fa8404c5c6 100644 --- a/rust/kernel/prelude.rs +++ b/rust/kernel/prelude.rs @@ -19,7 +19,7 @@ =20 pub use ::ffi::{ c_char, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, = c_ulong, c_ulonglong, - c_ushort, c_void, + c_ushort, c_void, CStr, }; =20 pub use crate::alloc::{flags::*, Box, KBox, KVBox, KVVec, KVec, VBox, VVec= , Vec}; @@ -43,7 +43,7 @@ =20 pub use super::error::{code::*, Error, Result}; =20 -pub use super::{str::CStr, ThisModule}; +pub use super::{str::CStrExt as _, ThisModule}; =20 pub use super::init::InPlaceInit; =20 diff --git a/rust/kernel/seq_file.rs b/rust/kernel/seq_file.rs index 59fbfc2473f8..855e533813a6 100644 --- a/rust/kernel/seq_file.rs +++ b/rust/kernel/seq_file.rs @@ -4,7 +4,7 @@ //! //! C header: [`include/linux/seq_file.h`](srctree/include/linux/seq_file.= h) =20 -use crate::{bindings, c_str, fmt, types::NotThreadSafe, types::Opaque}; +use crate::{bindings, c_str, fmt, str::CStrExt as _, types::NotThreadSafe,= types::Opaque}; =20 /// A utility for generating the contents of a seq file. #[repr(transparent)] diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs index 5c74e5f77601..da539e1f29d4 100644 --- a/rust/kernel/str.rs +++ b/rust/kernel/str.rs @@ -10,9 +10,11 @@ }; use core::{ marker::PhantomData, - ops::{self, Deref, DerefMut, Index}, + ops::{Deref, DerefMut, Index}, }; =20 +pub use crate::prelude::CStr; + /// Byte string without UTF-8 validity guarantee. #[repr(transparent)] pub struct BStr([u8]); @@ -186,58 +188,17 @@ macro_rules! b_str { // - error[E0379]: functions in trait impls cannot be declared const #[inline] pub const fn as_char_ptr_in_const_context(c_str: &CStr) -> *const c_char { - c_str.0.as_ptr() + c_str.as_ptr().cast() } =20 -/// Possible errors when using conversion functions in [`CStr`]. -#[derive(Debug, Clone, Copy)] -pub enum CStrConvertError { - /// Supplied bytes contain an interior `NUL`. - InteriorNul, - - /// Supplied bytes are not terminated by `NUL`. - NotNulTerminated, -} +mod private { + pub trait Sealed {} =20 -impl From for Error { - #[inline] - fn from(_: CStrConvertError) -> Error { - EINVAL - } + impl Sealed for super::CStr {} } =20 -/// A string that is guaranteed to have exactly one `NUL` byte, which is a= t the -/// end. -/// -/// Used for interoperability with kernel APIs that take C strings. -#[repr(transparent)] -pub struct CStr([u8]); - -impl CStr { - /// Returns the length of this string excluding `NUL`. - #[inline] - pub const fn len(&self) -> usize { - self.len_with_nul() - 1 - } - - /// Returns the length of this string with `NUL`. - #[inline] - pub const fn len_with_nul(&self) -> usize { - if self.0.is_empty() { - // SAFETY: This is one of the invariant of `CStr`. - // We add a `unreachable_unchecked` here to hint the optimizer= that - // the value returned from this function is non-zero. - unsafe { core::hint::unreachable_unchecked() }; - } - self.0.len() - } - - /// Returns `true` if the string only includes `NUL`. - #[inline] - pub const fn is_empty(&self) -> bool { - self.len() =3D=3D 0 - } - +/// Extensions to [`CStr`]. +pub trait CStrExt: private::Sealed { /// Wraps a raw C string pointer. /// /// # Safety @@ -245,54 +206,9 @@ pub const fn is_empty(&self) -> bool { /// `ptr` must be a valid pointer to a `NUL`-terminated C string, and = it must /// last at least `'a`. When `CStr` is alive, the memory pointed by `p= tr` /// must not be mutated. - #[inline] - pub unsafe fn from_char_ptr<'a>(ptr: *const c_char) -> &'a Self { - // SAFETY: The safety precondition guarantees `ptr` is a valid poi= nter - // to a `NUL`-terminated C string. - let len =3D unsafe { bindings::strlen(ptr) } + 1; - // SAFETY: Lifetime guaranteed by the safety precondition. - let bytes =3D unsafe { core::slice::from_raw_parts(ptr.cast(), len= ) }; - // SAFETY: As `len` is returned by `strlen`, `bytes` does not cont= ain interior `NUL`. - // As we have added 1 to `len`, the last byte is known to be `NUL`. - unsafe { Self::from_bytes_with_nul_unchecked(bytes) } - } - - /// Creates a [`CStr`] from a `[u8]`. - /// - /// The provided slice must be `NUL`-terminated, does not contain any - /// interior `NUL` bytes. - pub const fn from_bytes_with_nul(bytes: &[u8]) -> Result<&Self, CStrCo= nvertError> { - if bytes.is_empty() { - return Err(CStrConvertError::NotNulTerminated); - } - if bytes[bytes.len() - 1] !=3D 0 { - return Err(CStrConvertError::NotNulTerminated); - } - let mut i =3D 0; - // `i + 1 < bytes.len()` allows LLVM to optimize away bounds check= ing, - // while it couldn't optimize away bounds checks for `i < bytes.le= n() - 1`. - while i + 1 < bytes.len() { - if bytes[i] =3D=3D 0 { - return Err(CStrConvertError::InteriorNul); - } - i +=3D 1; - } - // SAFETY: We just checked that all properties hold. - Ok(unsafe { Self::from_bytes_with_nul_unchecked(bytes) }) - } - - /// Creates a [`CStr`] from a `[u8]` without performing any additional - /// checks. - /// - /// # Safety - /// - /// `bytes` *must* end with a `NUL` byte, and should only have a single - /// `NUL` byte (or the string will be truncated). - #[inline] - pub const unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &CS= tr { - // SAFETY: Properties of `bytes` guaranteed by the safety precondi= tion. - unsafe { core::mem::transmute(bytes) } - } + // This function exists to paper over the fact that `CStr::from_ptr` t= akes a `*const + // core::ffi::c_char` rather than a `*const crate::ffi::c_char`. + unsafe fn from_char_ptr<'a>(ptr: *const c_char) -> &'a Self; =20 /// Creates a mutable [`CStr`] from a `[u8]` without performing any /// additional checks. @@ -301,99 +217,16 @@ pub const fn from_bytes_with_nul(bytes: &[u8]) -> Res= ult<&Self, CStrConvertError /// /// `bytes` *must* end with a `NUL` byte, and should only have a single /// `NUL` byte (or the string will be truncated). - #[inline] - pub unsafe fn from_bytes_with_nul_unchecked_mut(bytes: &mut [u8]) -> &= mut CStr { - // SAFETY: Properties of `bytes` guaranteed by the safety precondi= tion. - unsafe { &mut *(core::ptr::from_mut(bytes) as *mut CStr) } - } + unsafe fn from_bytes_with_nul_unchecked_mut(bytes: &mut [u8]) -> &mut = Self; =20 /// Returns a C pointer to the string. - /// - /// Using this function in a const context is deprecated in favor of - /// [`as_char_ptr_in_const_context`] in preparation for replacing `CSt= r` with `core::ffi::CStr` - /// which does not have this method. - #[inline] - pub const fn as_char_ptr(&self) -> *const c_char { - as_char_ptr_in_const_context(self) - } - - /// Convert the string to a byte slice without the trailing `NUL` byte. - #[inline] - pub fn to_bytes(&self) -> &[u8] { - &self.0[..self.len()] - } - - /// Convert the string to a byte slice without the trailing `NUL` byte. - /// - /// This function is deprecated in favor of [`Self::to_bytes`] in prep= aration for replacing - /// `CStr` with `core::ffi::CStr` which does not have this method. - #[inline] - pub fn as_bytes(&self) -> &[u8] { - self.to_bytes() - } - - /// Convert the string to a byte slice containing the trailing `NUL` b= yte. - #[inline] - pub const fn to_bytes_with_nul(&self) -> &[u8] { - &self.0 - } - - /// Convert the string to a byte slice containing the trailing `NUL` b= yte. - /// - /// This function is deprecated in favor of [`Self::to_bytes_with_nul`= ] in preparation for - /// replacing `CStr` with `core::ffi::CStr` which does not have this m= ethod. - #[inline] - pub const fn as_bytes_with_nul(&self) -> &[u8] { - self.to_bytes_with_nul() - } - - /// Yields a [`&str`] slice if the [`CStr`] contains valid UTF-8. - /// - /// If the contents of the [`CStr`] are valid UTF-8 data, this - /// function will return the corresponding [`&str`] slice. Otherwise, - /// it will return an error with details of where UTF-8 validation fai= led. - /// - /// # Examples - /// - /// ``` - /// # use kernel::str::CStr; - /// let cstr =3D CStr::from_bytes_with_nul(b"foo\0")?; - /// assert_eq!(cstr.to_str(), Ok("foo")); - /// # Ok::<(), kernel::error::Error>(()) - /// ``` - #[inline] - pub fn to_str(&self) -> Result<&str, core::str::Utf8Error> { - core::str::from_utf8(self.as_bytes()) - } - - /// Unsafely convert this [`CStr`] into a [`&str`], without checking f= or - /// valid UTF-8. - /// - /// # Safety - /// - /// The contents must be valid UTF-8. - /// - /// # Examples - /// - /// ``` - /// # use kernel::c_str; - /// # use kernel::str::CStr; - /// let bar =3D c_str!("=E3=83=84"); - /// // SAFETY: String literals are guaranteed to be valid UTF-8 - /// // by the Rust compiler. - /// assert_eq!(unsafe { bar.as_str_unchecked() }, "=E3=83=84"); - /// ``` - #[inline] - pub unsafe fn as_str_unchecked(&self) -> &str { - // SAFETY: TODO. - unsafe { core::str::from_utf8_unchecked(self.as_bytes()) } - } + // This function exists to paper over the fact that `CStr::as_ptr` ret= urns a `*const + // core::ffi::c_char` rather than a `*const crate::ffi::c_char`. + fn as_char_ptr(&self) -> *const c_char; =20 /// Convert this [`CStr`] into a [`CString`] by allocating memory and /// copying over the string data. - pub fn to_cstring(&self) -> Result { - CString::try_from(self) - } + fn to_cstring(&self) -> Result; =20 /// Converts this [`CStr`] to its ASCII lower case equivalent in-place. /// @@ -404,11 +237,7 @@ pub fn to_cstring(&self) -> Result { /// [`to_ascii_lowercase()`]. /// /// [`to_ascii_lowercase()`]: #method.to_ascii_lowercase - pub fn make_ascii_lowercase(&mut self) { - // INVARIANT: This doesn't introduce or remove NUL bytes in the C - // string. - self.0.make_ascii_lowercase(); - } + fn make_ascii_lowercase(&mut self); =20 /// Converts this [`CStr`] to its ASCII upper case equivalent in-place. /// @@ -419,11 +248,7 @@ pub fn make_ascii_lowercase(&mut self) { /// [`to_ascii_uppercase()`]. /// /// [`to_ascii_uppercase()`]: #method.to_ascii_uppercase - pub fn make_ascii_uppercase(&mut self) { - // INVARIANT: This doesn't introduce or remove NUL bytes in the C - // string. - self.0.make_ascii_uppercase(); - } + fn make_ascii_uppercase(&mut self); =20 /// Returns a copy of this [`CString`] where each character is mapped = to its /// ASCII lower case equivalent. @@ -434,13 +259,7 @@ pub fn make_ascii_uppercase(&mut self) { /// To lowercase the value in-place, use [`make_ascii_lowercase`]. /// /// [`make_ascii_lowercase`]: str::make_ascii_lowercase - pub fn to_ascii_lowercase(&self) -> Result { - let mut s =3D self.to_cstring()?; - - s.make_ascii_lowercase(); - - Ok(s) - } + fn to_ascii_lowercase(&self) -> Result; =20 /// Returns a copy of this [`CString`] where each character is mapped = to its /// ASCII upper case equivalent. @@ -451,13 +270,7 @@ pub fn to_ascii_lowercase(&self) -> Result { /// To uppercase the value in-place, use [`make_ascii_uppercase`]. /// /// [`make_ascii_uppercase`]: str::make_ascii_uppercase - pub fn to_ascii_uppercase(&self) -> Result { - let mut s =3D self.to_cstring()?; - - s.make_ascii_uppercase(); - - Ok(s) - } + fn to_ascii_uppercase(&self) -> Result; } =20 impl fmt::Display for CStr { @@ -490,98 +303,75 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Res= ult { } } =20 -impl fmt::Debug for CStr { - /// Formats printable ASCII characters with a double quote on either e= nd, escaping the rest. - /// - /// ``` - /// # use kernel::c_str; - /// # use kernel::prelude::fmt; - /// # use kernel::str::CStr; - /// # use kernel::str::CString; - /// let penguin =3D c_str!("=F0=9F=90=A7"); - /// let s =3D CString::try_from_fmt(fmt!("{penguin:?}"))?; - /// assert_eq!(s.as_bytes_with_nul(), "\"\\xf0\\x9f\\x90\\xa7\"\0".as_= bytes()); - /// - /// // Embedded double quotes are escaped. - /// let ascii =3D c_str!("so \"cool\""); - /// let s =3D CString::try_from_fmt(fmt!("{ascii:?}"))?; - /// assert_eq!(s.as_bytes_with_nul(), "\"so \\\"cool\\\"\"\0".as_bytes= ()); - /// # Ok::<(), kernel::error::Error>(()) - /// ``` - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("\"")?; - for &c in self.as_bytes() { - match c { - // Printable characters. - b'\"' =3D> f.write_str("\\\"")?, - 0x20..=3D0x7e =3D> f.write_char(c as char)?, - _ =3D> write!(f, "\\x{c:02x}")?, - } - } - f.write_str("\"") - } +/// Converts a mutable C string to a mutable byte slice. +/// +/// # Safety +/// +/// The caller must ensure that the slice ends in a NUL byte and contains = no other NUL bytes before +/// the borrow ends and the underlying [`CStr`] is used. +unsafe fn to_bytes_mut(s: &mut CStr) -> &mut [u8] { + // SAFETY: the cast from `&CStr` to `&[u8]` is safe since `CStr` has t= he same layout as `&[u8]` + // (this is technically not guaranteed, but we rely on it here). The p= ointer dereference is + // safe since it comes from a mutable reference which is guaranteed to= be valid for writes. + unsafe { &mut *(core::ptr::from_mut(s) as *mut [u8]) } } =20 -impl AsRef for CStr { +impl CStrExt for CStr { #[inline] - fn as_ref(&self) -> &BStr { - BStr::from_bytes(self.as_bytes()) + unsafe fn from_char_ptr<'a>(ptr: *const c_char) -> &'a Self { + // SAFETY: The safety preconditions are the same as for `CStr::fro= m_ptr`. + unsafe { CStr::from_ptr(ptr.cast()) } } -} =20 -impl Deref for CStr { - type Target =3D BStr; + #[inline] + unsafe fn from_bytes_with_nul_unchecked_mut(bytes: &mut [u8]) -> &mut = Self { + // SAFETY: the cast from `&[u8]` to `&CStr` is safe since the prop= erties of `bytes` are + // guaranteed by the safety precondition and `CStr` has the same l= ayout as `&[u8]` (this is + // technically not guaranteed, but we rely on it here). The pointe= r dereference is safe + // since it comes from a mutable reference which is guaranteed to = be valid for writes. + unsafe { &mut *(core::ptr::from_mut(bytes) as *mut CStr) } + } =20 #[inline] - fn deref(&self) -> &Self::Target { - self.as_ref() + fn as_char_ptr(&self) -> *const c_char { + self.as_ptr().cast() + } + + fn to_cstring(&self) -> Result { + CString::try_from(self) } -} =20 -impl Index> for CStr { - type Output =3D CStr; + fn make_ascii_lowercase(&mut self) { + // SAFETY: This doesn't introduce or remove NUL bytes in the C str= ing. + unsafe { to_bytes_mut(self) }.make_ascii_lowercase(); + } =20 - #[inline] - fn index(&self, index: ops::RangeFrom) -> &Self::Output { - // Delegate bounds checking to slice. - // Assign to _ to mute clippy's unnecessary operation warning. - let _ =3D &self.as_bytes()[index.start..]; - // SAFETY: We just checked the bounds. - unsafe { Self::from_bytes_with_nul_unchecked(&self.0[index.start..= ]) } + fn make_ascii_uppercase(&mut self) { + // SAFETY: This doesn't introduce or remove NUL bytes in the C str= ing. + unsafe { to_bytes_mut(self) }.make_ascii_uppercase(); } -} =20 -impl Index for CStr { - type Output =3D CStr; + fn to_ascii_lowercase(&self) -> Result { + let mut s =3D self.to_cstring()?; =20 - #[inline] - fn index(&self, _index: ops::RangeFull) -> &Self::Output { - self + s.make_ascii_lowercase(); + + Ok(s) } -} =20 -mod private { - use core::ops; + fn to_ascii_uppercase(&self) -> Result { + let mut s =3D self.to_cstring()?; =20 - // Marker trait for index types that can be forward to `BStr`. - pub trait CStrIndex {} + s.make_ascii_uppercase(); =20 - impl CStrIndex for usize {} - impl CStrIndex for ops::Range {} - impl CStrIndex for ops::RangeInclusive {} - impl CStrIndex for ops::RangeToInclusive {} + Ok(s) + } } =20 -impl Index for CStr -where - Idx: private::CStrIndex, - BStr: Index, -{ - type Output =3D >::Output; - +impl AsRef for CStr { #[inline] - fn index(&self, index: Idx) -> &Self::Output { - &self.as_ref()[index] + fn as_ref(&self) -> &BStr { + BStr::from_bytes(self.to_bytes()) } } =20 @@ -612,6 +402,13 @@ macro_rules! c_str { mod tests { use super::*; =20 + impl From for Error { + #[inline] + fn from(_: core::ffi::FromBytesWithNulError) -> Error { + EINVAL + } + } + macro_rules! format { ($($f:tt)*) =3D> ({ CString::try_from_fmt(fmt!($($f)*))?.to_str()? @@ -634,40 +431,28 @@ macro_rules! format { =20 #[test] fn test_cstr_to_str() -> Result { - let good_bytes =3D b"\xf0\x9f\xa6\x80\0"; - let checked_cstr =3D CStr::from_bytes_with_nul(good_bytes)?; - let checked_str =3D checked_cstr.to_str()?; + let cstr =3D c"\xf0\x9f\xa6\x80"; + let checked_str =3D cstr.to_str()?; assert_eq!(checked_str, "=F0=9F=A6=80"); Ok(()) } =20 #[test] fn test_cstr_to_str_invalid_utf8() -> Result { - let bad_bytes =3D b"\xc3\x28\0"; - let checked_cstr =3D CStr::from_bytes_with_nul(bad_bytes)?; - assert!(checked_cstr.to_str().is_err()); - Ok(()) - } - - #[test] - fn test_cstr_as_str_unchecked() -> Result { - let good_bytes =3D b"\xf0\x9f\x90\xA7\0"; - let checked_cstr =3D CStr::from_bytes_with_nul(good_bytes)?; - // SAFETY: The contents come from a string literal which contains = valid UTF-8. - let unchecked_str =3D unsafe { checked_cstr.as_str_unchecked() }; - assert_eq!(unchecked_str, "=F0=9F=90=A7"); + let cstr =3D c"\xc3\x28"; + assert!(cstr.to_str().is_err()); Ok(()) } =20 #[test] fn test_cstr_display() -> Result { - let hello_world =3D CStr::from_bytes_with_nul(b"hello, world!\0")?; + let hello_world =3D c"hello, world!"; assert_eq!(format!("{hello_world}"), "hello, world!"); - let non_printables =3D CStr::from_bytes_with_nul(b"\x01\x09\x0a\0"= )?; + let non_printables =3D c"\x01\x09\x0a"; assert_eq!(format!("{non_printables}"), "\\x01\\x09\\x0a"); - let non_ascii =3D CStr::from_bytes_with_nul(b"d\xe9j\xe0 vu\0")?; + let non_ascii =3D c"d\xe9j\xe0 vu"; assert_eq!(format!("{non_ascii}"), "d\\xe9j\\xe0 vu"); - let good_bytes =3D CStr::from_bytes_with_nul(b"\xf0\x9f\xa6\x80\0"= )?; + let good_bytes =3D c"\xf0\x9f\xa6\x80"; assert_eq!(format!("{good_bytes}"), "\\xf0\\x9f\\xa6\\x80"); Ok(()) } @@ -686,13 +471,13 @@ fn test_cstr_display_all_bytes() -> Result { =20 #[test] fn test_cstr_debug() -> Result { - let hello_world =3D CStr::from_bytes_with_nul(b"hello, world!\0")?; + let hello_world =3D c"hello, world!"; assert_eq!(format!("{hello_world:?}"), "\"hello, world!\""); - let non_printables =3D CStr::from_bytes_with_nul(b"\x01\x09\x0a\0"= )?; - assert_eq!(format!("{non_printables:?}"), "\"\\x01\\x09\\x0a\""); - let non_ascii =3D CStr::from_bytes_with_nul(b"d\xe9j\xe0 vu\0")?; + let non_printables =3D c"\x01\x09\x0a"; + assert_eq!(format!("{non_printables:?}"), "\"\\x01\\t\\n\""); + let non_ascii =3D c"d\xe9j\xe0 vu"; assert_eq!(format!("{non_ascii:?}"), "\"d\\xe9j\\xe0 vu\""); - let good_bytes =3D CStr::from_bytes_with_nul(b"\xf0\x9f\xa6\x80\0"= )?; + let good_bytes =3D c"\xf0\x9f\xa6\x80"; assert_eq!(format!("{good_bytes:?}"), "\"\\xf0\\x9f\\xa6\\x80\""); Ok(()) } diff --git a/rust/kernel/sync/condvar.rs b/rust/kernel/sync/condvar.rs index c6ec64295c9f..a24e25a690ee 100644 --- a/rust/kernel/sync/condvar.rs +++ b/rust/kernel/sync/condvar.rs @@ -8,7 +8,7 @@ use super::{lock::Backend, lock::Guard, LockClassKey}; use crate::{ ffi::{c_int, c_long}, - str::CStr, + str::{CStr, CStrExt as _}, task::{ MAX_SCHEDULE_TIMEOUT, TASK_FREEZABLE, TASK_INTERRUPTIBLE, TASK_NOR= MAL, TASK_UNINTERRUPTIBLE, }, diff --git a/rust/kernel/sync/lock.rs b/rust/kernel/sync/lock.rs index 27202beef90c..5d7991e6d373 100644 --- a/rust/kernel/sync/lock.rs +++ b/rust/kernel/sync/lock.rs @@ -7,7 +7,7 @@ =20 use super::LockClassKey; use crate::{ - str::CStr, + str::{CStr, CStrExt as _}, types::{NotThreadSafe, Opaque, ScopeGuard}, }; use core::{cell::UnsafeCell, marker::PhantomPinned, pin::Pin}; diff --git a/rust/kernel/sync/lock/global.rs b/rust/kernel/sync/lock/global= .rs index d65f94b5caf2..79d0ef7fda86 100644 --- a/rust/kernel/sync/lock/global.rs +++ b/rust/kernel/sync/lock/global.rs @@ -5,7 +5,7 @@ //! Support for defining statics containing locks. =20 use crate::{ - str::CStr, + str::{CStr, CStrExt as _}, sync::lock::{Backend, Guard, Lock}, sync::{LockClassKey, LockedBy}, types::Opaque, --=20 2.51.0