rust: add missing newlines in printing calls
cover rust: add missing newlines in printing calls
This patch series adds missing trailing newlines (\n) in Rust pr_*! and dev_*! calls across sample drivers and documentation examples.
Missing newlines cause kernel log lines to not be properly terminated, leading to unexpected concatenation of consecutive log messages.
Mehmet Koseoglu (3):
rust: samples: add missing newlines in rust_print_main
dma-mapping: rust: samples: add missing newline in rust_dma
rust: io: register: add missing newline in doc example
rust/kernel/io/register.rs | 2 +- samples/rust/rust_dma.rs | 2 +- samples/rust/rust_print_main.rs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.55.0
PATCH 1/3 rust: samples: add missing newlines in rust_print_main
Calls to pr_info! in arc_print are missing trailing newlines, which causes consecutive messages to not be properly line-terminated.
Add the missing \n to all four formatting strings.
--- samples/rust/rust_print_main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
samples/rust/rust_print_main.rs +4 -4
@@ -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 kernel::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 (()) }
Signature · 1 line
2.55.0
Re: [PATCH v1 1/3] rust: samples: add missing newlines in rust_print_main
Quoted 3 lines · Mehmet Koseoglu
Fixes f431c5c581fa ("samples: rust: print: Add sample code for Arc printing")Fixes 47cb6bf7860c ("rust: use derive(CoercePointee) on rustc >= 1.84.0")
Thanks!
These Fixes tags point to different set of stable releases, but we probably don't care about backporting this, so it is not a big deal (otherwise; we would have needed to split the patch).
Cheers,
Miguel
Re: [PATCH v1 1/3] rust: samples: add missing newlines in rust_print_main
In reply to Mehmet KoseogluQuoted 11 lines · Mehmet Koseoglu
Calls to
pr_info!inarc_printare missing trailing newlines, which causes consecutive messages to not be properly line-terminated.Add the missing
\nto all four formatting strings.Fixes f431c5c581fa ("samples: rust: print: Add sample code for Arc printing")Fixes 47cb6bf7860c ("rust: use derive(CoercePointee) on rustc >= 1.84.0")Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Mehmet Koseoglu <[email protected]>
Applied (this one) to rust-fixes -- thanks!
[ Reworded to fix the description of the missing-newline behavior.
- Miguel ]
Cheers,
Miguel
PATCH 2/3 dma-mapping: rust: samples: add missing newline in rust_dma
In reply to Mehmet KoseogluThe dev_info! call iterating over scatter-gather table entries in DmaSampleDriver::drop is missing a trailing newline, causing the printed message to not be properly line-terminated.
Add the missing \n to the format string.
--- samples/rust/rust_dma.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
samples/rust/rust_dma.rs +1 -1
@@ -125,7 +125,7 @@ fn drop(self: Pin<&mut Self>) {for (i, entry)in self.sgt.iter ().enumerate () {dev_info! ( self.pdev, -"Entry[{}]: DMA address: {:#x}" , +"Entry[{}]: DMA address: {:#x}\n" , i, entry.dma_address (), );
Signature · 1 line
2.55.0
PATCH 3/3 rust: io: register: add missing newline in doc example
In reply to Mehmet KoseogluThe pr_info! call in the register module documentation code example is missing a trailing newline.
Add the missing \n to the format string.
--- rust/kernel/io/register.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/io/register.rs +1 -1
@@ -71,7 +71,7 @@//! //! // Read from the register's defined offset (0x100). //! let boot0 = io.read(BOOT_0); -//! pr_info!("chip revision: {}.{}", boot0.major_revision().get(), boot0.minor_revision().get()); +//! pr_info!("chip revision: {}.{}\n", boot0.major_revision().get(), boot0.minor_revision().get()); //! //! // Update some fields and write the new value back. //! let new_boot0 = boot0
Signature · 1 line
2.55.0