The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] rust: soc: silence clippy warning with rustc >= 1.88
@ 2026-07-07 10:12 Alexandre Courbot
  2026-07-07 11:11 ` Onur Özkan
  2026-07-07 11:43 ` Gary Guo
  0 siblings, 2 replies; 10+ messages in thread
From: Alexandre Courbot @ 2026-07-07 10:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Daniel Almeida, Tamir Duberstein, Onur Özkan, Matthew Maurer
  Cc: driver-core, rust-for-linux, linux-kernel, Alexandre Courbot

The `clippy::unwrap_or_default` warning triggers on
`rust/kernel/soc.rs` since rustc 1.88:

    warning: use of `unwrap_or` to construct default value
      --> ../rust/kernel/soc.rs:66:10
      |
   66 |         .unwrap_or(core::ptr::null())
      |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
      |
      = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.96.0/index.html#unwrap_or_default
      = note: `-W clippy::unwrap-or-default` implied by `-W clippy::all`
      = help: to override `-W clippy::all` add `#[allow(clippy::unwrap_or_default)]`

Since our current MSRV is 1.85, we cannot fix the warning as
recommended, so allow the lint on the `cstring_to_c` function instead.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 rust/kernel/soc.rs | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rust/kernel/soc.rs b/rust/kernel/soc.rs
index 0d6a36c83cb6..7998962560f8 100644
--- a/rust/kernel/soc.rs
+++ b/rust/kernel/soc.rs
@@ -60,6 +60,9 @@ struct BuiltAttributes {
     inner: Opaque<bindings::soc_device_attribute>,
 }
 
+// `unwrap_or_default()` on a raw pointer requires `Default for *const T`, which is stable since
+// Rust 1.88. Remove when the MSRV allows it.
+#[allow(clippy::unwrap_or_default)]
 fn cstring_to_c(mcs: &Option<CString>) -> *const kernel::ffi::c_char {
     mcs.as_ref()
         .map(|cs| cs.as_char_ptr())

---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260707-soc_unwrap_or-ed37e674a759

Best regards,
--  
Alexandre Courbot <acourbot@nvidia.com>


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-07-08 10:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 10:12 [PATCH] rust: soc: silence clippy warning with rustc >= 1.88 Alexandre Courbot
2026-07-07 11:11 ` Onur Özkan
2026-07-07 11:43 ` Gary Guo
2026-07-07 12:12   ` Alexandre Courbot
2026-07-07 12:12   ` Miguel Ojeda
2026-07-07 14:19     ` Alexandre Courbot
2026-07-07 14:30       ` Gary Guo
2026-07-08  8:25         ` Alexandre Courbot
2026-07-08  9:04           ` Miguel Ojeda
2026-07-08 10:11             ` Alexandre Courbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox