Skip to content

Commit aaf5d63

Browse files
committed
Fix dead_code in rust KParamGuard.
Signed-off-by: Finn Behrens <me@kloenk.de>
1 parent bc33ea8 commit aaf5d63

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

rust/kernel/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,25 @@ impl ThisModule {
131131
bindings::kernel_param_lock(self.0)
132132
}
133133

134-
KParamGuard { this_module: self }
134+
#[cfg(CONFIG_SYSFS)]
135+
return KParamGuard { this_module: self };
136+
137+
#[cfg(not(CONFIG_SYSFS))]
138+
return KParamGuard { _private: () };
135139
}
136140
}
137141

138142
/// Scoped lock on the kernel parameters of [`ThisModule`].
139143
///
140144
/// Lock will be released when this struct is dropped.
145+
#[cfg_attr(CONFIG_SYSFS, repr(transparent))]
141146
pub struct KParamGuard<'a> {
147+
#[cfg(CONFIG_SYSFS)]
142148
this_module: &'a ThisModule,
149+
150+
// private field, so this struct can not be constructed from outside this crate
151+
#[cfg(not(CONFIG_SYSFS))]
152+
_private: (),
143153
}
144154

145155
#[cfg(CONFIG_SYSFS)]

0 commit comments

Comments
 (0)