Skip to content

Commit c8fcdcf

Browse files
committed
Fix dead_code in rust KParamGuard.
Signed-off-by: Finn Behrens <[email protected]>
1 parent be91a55 commit c8fcdcf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

rust/kernel/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,20 @@ pub struct KParamGuard<'a> {
149149
this_module: &'a ThisModule,
150150
}
151151

152-
#[cfg(CONFIG_SYSFS)]
153152
impl<'a> Drop for KParamGuard<'a> {
153+
#[cfg(CONFIG_SYSFS)]
154154
fn drop(&mut self) {
155155
// SAFETY: `kernel_param_lock` will check if the pointer is null and
156156
// use the built-in mutex in that case. The existance of `self`
157157
// guarantees that the lock is held.
158158
unsafe { bindings::kernel_param_unlock(self.this_module.0) }
159159
}
160+
161+
#[cfg(not(CONFIG_SYSFS))]
162+
fn drop(&mut self) {
163+
// This just touches the `this_module` field, to prevent dead_code warnings.
164+
let _ = self.this_module;
165+
}
160166
}
161167

162168
/// Calculates the offset of a field from the beginning of the struct it belongs to.

0 commit comments

Comments
 (0)