[PATCH v3 6/6] rust: samples: add missing newline to pr_info! calls in rust_print_main

Alban Kurti posted 6 patches 1 year ago
[PATCH v3 6/6] rust: samples: add missing newline to pr_info! calls in rust_print_main
Posted by Alban Kurti 1 year ago
The sample code in samples/rust/rust_print_main.rs contained pr_info!
calls without a newline. This commit updates those calls, ensuring
that the output is properly formatted when the sample is run.

Fixes: f431c5c581fa ("samples: rust: print: Add sample code for Arc printing")
Fixes: 47cb6bf7860c ("rust: use derive(CoercePointee) on rustc >= 1.84.0")
Reported-by: Miguel Ojeda <ojeda@kernel.org>
Closes: https://github.com/Rust-for-Linux/linux/issues/1139
Signed-off-by: Alban Kurti <kurti@invicto.ai>
---
 samples/rust/rust_print_main.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/samples/rust/rust_print_main.rs b/samples/rust/rust_print_main.rs
index 7e8af5f176a33925881c7d65b34c823028b7b93b..7ef3cecc65a15627276699c691273608253c9df5 100644
--- a/samples/rust/rust_print_main.rs
+++ b/samples/rust/rust_print_main.rs
@@ -23,10 +23,10 @@ fn arc_print() -> Result {
     let b = UniqueArc::new("hello, world", GFP_KERNEL)?;
 
     // Prints the value of data in `a`.
-    pr_info!("{}", a);
+    pr_info!("{}\n", a);
 
     // Uses ":?" to print debug fmt of `b`.
-    pr_info!("{:?}", b);
+    pr_info!("{:?}\n", b);
 
     let a: Arc<&str> = b.into();
     let c = a.clone();
@@ -42,7 +42,7 @@ fn arc_print() -> Result {
 
         use core::fmt::Display;
         fn arc_dyn_print(arc: &Arc<dyn Display>) {
-            pr_info!("Arc<dyn Display> says {arc}");
+            pr_info!("Arc<dyn Display> says {arc}\n");
         }
 
         let a_i32_display: Arc<dyn Display> = Arc::new(42i32, GFP_KERNEL)?;
@@ -53,7 +53,7 @@ fn arc_dyn_print(arc: &Arc<dyn Display>) {
     }
 
     // Pretty-prints the debug formatting with lower-case hexadecimal integers.
-    pr_info!("{:#x?}", a);
+    pr_info!("{:#x?}\n", a);
 
     Ok(())
 }

-- 
2.48.1
Re: [PATCH v3 6/6] rust: samples: add missing newline to pr_info! calls in rust_print_main
Posted by Miguel Ojeda 11 months, 1 week ago
On Thu, Feb 6, 2025 at 10:08 PM Alban Kurti <kurti@invicto.ai> wrote:
>
> Fixes: f431c5c581fa ("samples: rust: print: Add sample code for Arc printing")
> Fixes: 47cb6bf7860c ("rust: use derive(CoercePointee) on rustc >= 1.84.0")

Thanks Alban for making the effort of splitting the patch into several
and finding the right commits to tag.

I will take the first 5 patches already, but I think this last one in
particular will need to be split, because one Fixes tag points to some
LTSs and the other is very recent, so it wouldn't be backported.

Cheers,
Miguel
Re: [PATCH v3 6/6] rust: samples: add missing newline to pr_info! calls in rust_print_main
Posted by Miguel Ojeda 10 months ago
On Thu, Mar 6, 2025 at 12:55 AM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> Thanks Alban for making the effort of splitting the patch into several
> and finding the right commits to tag.
>
> I will take the first 5 patches already, but I think this last one in
> particular will need to be split, because one Fixes tag points to some
> LTSs and the other is very recent, so it wouldn't be backported.

Ping about this -- thanks!

Cheers,
Miguel