Skip to content

Commit

Permalink
rust: samples: add missing newline to pr_info! calls in rust_print_main
Browse files Browse the repository at this point in the history
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: f431c5c ("samples: rust: print: Add sample code for Arc printing")
Fixes: 47cb6bf ("rust: use derive(CoercePointee) on rustc >= 1.84.0")
Reported-by: Miguel Ojeda <ojeda@kernel.org>
Closes: Rust-for-Linux#1139
Signed-off-by: Alban Kurti <kurti@invicto.ai>
  • Loading branch information
albankurti authored and intel-lab-lkp committed Feb 6, 2025
1 parent 312206b commit a394665
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions samples/rust/rust_print_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)?;
Expand All @@ -53,7 +53,7 @@ fn arc_print() -> Result {
}

// Pretty-prints the debug formatting with lower-case hexadecimal integers.
pr_info!("{:#x?}", a);
pr_info!("{:#x?}\n", a);

Ok(())
}
Expand Down

0 comments on commit a394665

Please sign in to comment.