]> www.infradead.org Git - users/jedix/linux-maple.git/commit
rust: miscdevice: add missing safety comments
authorAlice Ryhl <aliceryhl@google.com>
Tue, 22 Oct 2024 13:14:13 +0000 (13:14 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 22 Oct 2024 13:53:15 +0000 (15:53 +0200)
commitbd5ee6bcc51b617d28e54069fef818751763962b
tree37ff64fe1142b8672590fce0a69b5ad4ab6f30b3
parentd723c456ef5ad60d368e62791004fd152c4380aa
rust: miscdevice: add missing safety comments

This fixes the following four warnings:

warning: unsafe block missing a safety comment
   --> /home/aliceryhl/rust-for-linux/rust/kernel/miscdevice.rs:168:15
    |
168 |             ..unsafe { MaybeUninit::zeroed().assume_init() }
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider adding a safety comment on the preceding line
    = help: for further information visit
      https://rust-lang.github.io/rust-clippy/master/index.html#undocumented_unsafe_blocks
    = note: requested on the command line with `-W clippy::undocumented-unsafe-blocks`

warning: unsafe function's docs are missing a `# Safety` section
   --> /home/aliceryhl/rust-for-linux/rust/kernel/miscdevice.rs:175:1
    |
175 | / unsafe extern "C" fn fops_open<T: MiscDevice>(
176 | |     inode: *mut bindings::inode,
177 | |     file: *mut bindings::file,
178 | | ) -> c_int {
    | |__________^
    |
    = help: for further information visit
      https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc
    = note: `-W clippy::missing-safety-doc` implied by `-W clippy::all`
    = help: to override `-W clippy::all` add `#[allow(clippy::missing_safety_doc)]`

warning: unsafe function's docs are missing a `# Safety` section
   --> /home/aliceryhl/rust-for-linux/rust/kernel/miscdevice.rs:196:1
    |
196 | / unsafe extern "C" fn fops_release<T: MiscDevice>(
197 | |     _inode: *mut bindings::inode,
198 | |     file: *mut bindings::file,
199 | | ) -> c_int {
    | |__________^
    |
    = help: for further information visit
      https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs are missing a `# Safety` section
   --> /home/aliceryhl/rust-for-linux/rust/kernel/miscdevice.rs:210:1
    |
210 | / unsafe extern "C" fn fops_ioctl<T: MiscDevice>(
211 | |     file: *mut bindings::file,
212 | |     cmd: c_uint,
213 | |     arg: c_ulong,
214 | | ) -> c_long {
    | |___________^
    |
    = help: for further information visit
      https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

Note that these warnings are currently not enabled in the build, but
rust-next contains a commit that will enable them, so we should fix
them.

Reported-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Closes: https://lore.kernel.org/rust-for-linux/CANiq72kOs6vPDUzZttQNqePFHphCQ30iVmZ5MO7eCJfPG==Vzg@mail.gmail.com/
Acked-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://lore.kernel.org/r/20241022-miscdevice-unsafe-warn-fix-v1-1-a78fde1740d6@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
rust/kernel/miscdevice.rs