Skip to contentSkip to conversation

rust: impl_flags: use bit helper in example

PATCH Superseded kosumi 2 participants 2 messages Jul 11 Rust

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

kosumi

author
#0 lore raw

PATCH 1/1 rust: impl_flags: use bit helper in example

Use bit_u32() instead of open-coding shifts in the impl_flags! example. This demonstrates the checked bit helper and ensures that bit positions remain within the underlying u32 type.

---
 rust/kernel/impl_flags.rs | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
rust/kernel/impl_flags.rs +7 -4
index e2bd7639d..fdf44d5ee 100644
@@ -19,7 +19,10 @@
 /// # Examples
 ///
 /// ```
-/// use kernel::impl_flags;
+/// use kernel::{
+///     bits::bit_u32,
+///     impl_flags, //
+/// };
 ///
 /// impl_flags!(
 ///     /// Represents multiple permissions.
@@ -30,13 +33,13 @@
 ///     #[derive(Debug, Clone, Copy, PartialEq, Eq)]
 ///     pub enum Permission {
 ///         /// Read permission.
-///         Read = 1 << 0,
+///         Read = bit_u32(0),
 ///
 ///         /// Write permission.
-///         Write = 1 << 1,
+///         Write = bit_u32(1),
 ///
 ///         /// Execute permission.
-///         Execute = 1 << 2,
+///         Execute = bit_u32(2),
 ///     }
 /// );
 ///

base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482

Signature · 1 line
2.54.0
#1 lore raw
Quoted 11 lines · kosumi

Use bit_u32() instead of open-coding shifts in the impl_flags! example. This demonstrates the checked bit helper and ensures that bit positions remain within the underlying u32 type.

---
 rust/kernel/impl_flags.rs | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.

You are receiving this message because of the following common error(s) as indicated below:

- It looks like you did not use your "real" name for the patch on either the Signed-off-by: line, or the From: line (both of which have to match). Please read the kernel file, Documentation/process/submitting-patches.rst for how to do this correctly.

If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.

thanks,

greg k-h's patch email bot