Skip to content

Commit 3ac88a9

Browse files
Gnurouojeda
authored andcommitted
rust: str: make NullTerminatedFormatter public
If `CONFIG_BLOCK` is disabled, the following warnings are displayed during build: warning: struct `NullTerminatedFormatter` is never constructed --> ../rust/kernel/str.rs:667:19 | 667 | pub(crate) struct NullTerminatedFormatter<'a> { | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default warning: associated function `new` is never used --> ../rust/kernel/str.rs:673:19 | 671 | impl<'a> NullTerminatedFormatter<'a> { | ------------------------------------ associated function in this implementation 672 | /// Create a new [`Self`] instance. 673 | pub(crate) fn new(buffer: &'a mut [u8]) -> Option<NullTerminatedFormatter<'a>> { Fix them by making `NullTerminatedFormatter` public, as it could be useful for drivers anyway. Fixes: cdde7a1 ("rust: str: introduce `NullTerminatedFormatter`") Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260224-nullterminatedformatter-v1-1-5bef7b9b3d4c@nvidia.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 11439c4 commit 3ac88a9

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

rust/kernel/str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,13 +664,13 @@ impl fmt::Write for Formatter<'_> {
664664
///
665665
/// * The first byte of `buffer` is always zero.
666666
/// * The length of `buffer` is at least 1.
667-
pub(crate) struct NullTerminatedFormatter<'a> {
667+
pub struct NullTerminatedFormatter<'a> {
668668
buffer: &'a mut [u8],
669669
}
670670

671671
impl<'a> NullTerminatedFormatter<'a> {
672672
/// Create a new [`Self`] instance.
673-
pub(crate) fn new(buffer: &'a mut [u8]) -> Option<NullTerminatedFormatter<'a>> {
673+
pub fn new(buffer: &'a mut [u8]) -> Option<NullTerminatedFormatter<'a>> {
674674
*(buffer.first_mut()?) = 0;
675675

676676
// INVARIANT:

0 commit comments

Comments
 (0)