Skip to content

Commit 3dea952

Browse files
committed
Fix warnings from rustc and clippy
1 parent 507eb38 commit 3dea952

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,6 @@ impl HelperState {
605605
lock.consumer_done = true;
606606
self.cvar.notify_one();
607607
}
608-
609-
fn producer_done(&self) -> bool {
610-
self.lock().producer_done
611-
}
612608
}
613609

614610
/// Finds and returns the value of `--jobserver-auth=<VALUE>` in the given

src/unix.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ impl Client {
291291
{
292292
let read = self.read().as_raw_fd();
293293
loop {
294-
match non_blocking_read(read, &mut buf) {
294+
match non_blocking_read(read, &buf) {
295295
Ok(1) => return Ok(Some(Acquired { byte: buf[0] })),
296296
Ok(_) => {
297297
return Err(io::Error::new(
@@ -437,7 +437,7 @@ pub(crate) fn spawn_helper(
437437
}));
438438
}
439439
Err(e) => break f(Err(e)),
440-
Ok(None) if helper.producer_done() => break,
440+
Ok(None) if helper.lock().producer_done => break,
441441
Ok(None) => {}
442442
}
443443
});
@@ -625,12 +625,7 @@ mod test {
625625

626626
use crate::{test::run_named_fifo_try_acquire_tests, Client};
627627

628-
use std::{
629-
fs::File,
630-
io::{self, Write},
631-
os::unix::io::AsRawFd,
632-
sync::Arc,
633-
};
628+
use std::sync::Arc;
634629

635630
fn from_imp_client(imp: ClientImp) -> Client {
636631
Client {
@@ -657,6 +652,12 @@ mod test {
657652
#[cfg(not(target_os = "linux"))]
658653
#[test]
659654
fn test_try_acquire_annoymous_pipe_linux_specific_optimization() {
655+
use std::{
656+
fs::File,
657+
io::{self, Write},
658+
os::unix::io::AsRawFd,
659+
};
660+
660661
let (read, write) = nix::unistd::pipe().unwrap();
661662
let read = File::from(read);
662663
let mut write = File::from(write);

src/windows.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ pub struct Client {
1515
#[derive(Debug)]
1616
pub struct Acquired;
1717

18+
#[allow(clippy::upper_case_acronyms)]
1819
type BOOL = i32;
20+
#[allow(clippy::upper_case_acronyms)]
1921
type DWORD = u32;
22+
#[allow(clippy::upper_case_acronyms)]
2023
type HANDLE = *mut u8;
24+
#[allow(clippy::upper_case_acronyms)]
2125
type LONG = i32;
2226

2327
const ERROR_ALREADY_EXISTS: DWORD = 183;
@@ -71,7 +75,7 @@ extern "system" {
7175
// randomness.
7276
fn getrandom(dest: &mut [u8]) -> io::Result<()> {
7377
// Prevent overflow of u32
74-
for chunk in dest.chunks_mut(u32::max_value() as usize) {
78+
for chunk in dest.chunks_mut(u32::MAX as usize) {
7579
let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr(), chunk.len() as u32) };
7680
if ret == 0 {
7781
return Err(io::Error::new(
@@ -115,10 +119,7 @@ impl Client {
115119
continue;
116120
}
117121
name.pop(); // chop off the trailing nul
118-
let client = Client {
119-
sem: handle,
120-
name: name,
121-
};
122+
let client = Client { sem: handle, name };
122123
if create_limit != limit {
123124
client.acquire()?;
124125
}
@@ -259,7 +260,7 @@ pub(crate) fn spawn_helper(
259260
state.for_each_request(|_| {
260261
const WAIT_OBJECT_1: u32 = WAIT_OBJECT_0 + 1;
261262
match unsafe { WaitForMultipleObjects(2, objects.as_ptr(), FALSE, INFINITE) } {
262-
WAIT_OBJECT_0 => return,
263+
WAIT_OBJECT_0 => {}
263264
WAIT_OBJECT_1 => f(Ok(crate::Acquired {
264265
client: client.inner.clone(),
265266
data: Acquired,

tests/helper.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use jobserver::Client;
22
use std::sync::atomic::*;
3-
use std::sync::mpsc;
43
use std::sync::*;
54

65
macro_rules! t {

0 commit comments

Comments
 (0)