Skip to content

Commit 56df8a7

Browse files
authored
Merge pull request #151 from wedsonaf/signal
Warn if the caller doesn't check if a signal is pending.
2 parents e63414c + 2ea89dd commit 56df8a7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

drivers/char/rust_example.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl KernelModule for RustExample {
102102
let guard = data.lock();
103103
#[allow(clippy::while_immutable_condition)]
104104
while *guard != 10 {
105-
cv.wait(&guard);
105+
let _ = cv.wait(&guard);
106106
}
107107
}
108108
cv.notify_one();
@@ -125,7 +125,7 @@ impl KernelModule for RustExample {
125125
let guard = data.lock();
126126
#[allow(clippy::while_immutable_condition)]
127127
while *guard != 10 {
128-
cv.wait(&guard);
128+
let _ = cv.wait(&guard);
129129
}
130130
}
131131
cv.notify_one();

rust/kernel/sync/condvar.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ impl CondVar {
6464
/// [`CondVar::notify_all`], or when the thread receives a signal.
6565
///
6666
/// Returns whether there is a signal pending.
67+
#[must_use = "wait returns if a signal is pending, so the caller must check the return value"]
6768
pub fn wait<L: Lock>(&self, guard: &Guard<L>) -> bool {
6869
let lock = guard.lock;
6970
let mut wait = MaybeUninit::<bindings::wait_queue_entry>::uninit();

0 commit comments

Comments
 (0)