Skip to content

Commit

Permalink
Merge pull request #151 from wedsonaf/signal
Browse files Browse the repository at this point in the history
Warn if the caller doesn't check if a signal is pending.
  • Loading branch information
ojeda authored Mar 30, 2021
2 parents e63414c + 2ea89dd commit 56df8a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/char/rust_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl KernelModule for RustExample {
let guard = data.lock();
#[allow(clippy::while_immutable_condition)]
while *guard != 10 {
cv.wait(&guard);
let _ = cv.wait(&guard);
}
}
cv.notify_one();
Expand All @@ -125,7 +125,7 @@ impl KernelModule for RustExample {
let guard = data.lock();
#[allow(clippy::while_immutable_condition)]
while *guard != 10 {
cv.wait(&guard);
let _ = cv.wait(&guard);
}
}
cv.notify_one();
Expand Down
1 change: 1 addition & 0 deletions rust/kernel/sync/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl CondVar {
/// [`CondVar::notify_all`], or when the thread receives a signal.
///
/// Returns whether there is a signal pending.
#[must_use = "wait returns if a signal is pending, so the caller must check the return value"]
pub fn wait<L: Lock>(&self, guard: &Guard<L>) -> bool {
let lock = guard.lock;
let mut wait = MaybeUninit::<bindings::wait_queue_entry>::uninit();
Expand Down

0 comments on commit 56df8a7

Please sign in to comment.