mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-10 20:19:07 +00:00
sys_util: Fix 1.51.0 acronym case clippy warnings.
This also fixes a self convention warning for sys_util::sock_ctl_msg and removes a stray semicolon from ac97_bus_master. BUG=None TEST=cargo clippy && cargo test Change-Id: I7fcf7577e09888836f7664d7127f94c9c24d3cfa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2840050 Tested-by: Allen Webb <allenwebb@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Commit-Queue: Allen Webb <allenwebb@google.com>
This commit is contained in:
parent
78145acd86
commit
82561b445b
3 changed files with 33 additions and 32 deletions
|
@ -720,7 +720,7 @@ fn next_guest_buffer(
|
|||
// 0 h l n
|
||||
// +++++++++......++++
|
||||
(low > high && (low <= value || value <= high))
|
||||
};
|
||||
}
|
||||
|
||||
// Check if
|
||||
// * we're halted
|
||||
|
|
|
@ -59,7 +59,7 @@ pub enum Error {
|
|||
/// Failed to convert signum to Signal.
|
||||
UnrecognizedSignum(i32),
|
||||
/// Converted signum greater than SIGRTMAX.
|
||||
RTSignumGreaterThanMax(Signal),
|
||||
RtSignumGreaterThanMax(Signal),
|
||||
}
|
||||
|
||||
impl Display for Error {
|
||||
|
@ -94,7 +94,7 @@ impl Display for Error {
|
|||
WaitPid(e) => write!(f, "failed to wait for process: {}", e),
|
||||
TimedOut => write!(f, "timeout reached."),
|
||||
UnrecognizedSignum(signum) => write!(f, "unrecoginized signal number: {}", signum),
|
||||
RTSignumGreaterThanMax(signal) => {
|
||||
RtSignumGreaterThanMax(signal) => {
|
||||
write!(f, "got RT signal greater than max: {:?}", signal)
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ pub enum Signal {
|
|||
HangUp = libc::SIGHUP,
|
||||
IllegalInstruction = libc::SIGILL,
|
||||
Interrupt = libc::SIGINT,
|
||||
IO = libc::SIGIO,
|
||||
Io = libc::SIGIO,
|
||||
Kill = libc::SIGKILL,
|
||||
Pipe = libc::SIGPIPE,
|
||||
Power = libc::SIGPWR,
|
||||
|
@ -126,15 +126,15 @@ pub enum Signal {
|
|||
Sys = libc::SIGSYS,
|
||||
Trap = libc::SIGTRAP,
|
||||
Terminate = libc::SIGTERM,
|
||||
TTYIn = libc::SIGTTIN,
|
||||
TTYOut = libc::SIGTTOU,
|
||||
TTYStop = libc::SIGTSTP,
|
||||
TtyIn = libc::SIGTTIN,
|
||||
TtyOut = libc::SIGTTOU,
|
||||
TtyStop = libc::SIGTSTP,
|
||||
Urgent = libc::SIGURG,
|
||||
User1 = libc::SIGUSR1,
|
||||
User2 = libc::SIGUSR2,
|
||||
VTAlarm = libc::SIGVTALRM,
|
||||
VtAlarm = libc::SIGVTALRM,
|
||||
Winch = libc::SIGWINCH,
|
||||
XCPU = libc::SIGXCPU,
|
||||
Xcpu = libc::SIGXCPU,
|
||||
// Rt signal numbers are be adjusted in the conversion to integer.
|
||||
Rt0 = libc::SIGSYS + 1,
|
||||
Rt1,
|
||||
|
@ -198,7 +198,7 @@ impl TryFrom<c_int> for Signal {
|
|||
libc::SIGHUP => HangUp,
|
||||
libc::SIGILL => IllegalInstruction,
|
||||
libc::SIGINT => Interrupt,
|
||||
libc::SIGIO => IO,
|
||||
libc::SIGIO => Io,
|
||||
libc::SIGKILL => Kill,
|
||||
libc::SIGPIPE => Pipe,
|
||||
libc::SIGPWR => Power,
|
||||
|
@ -210,15 +210,15 @@ impl TryFrom<c_int> for Signal {
|
|||
libc::SIGSYS => Sys,
|
||||
libc::SIGTRAP => Trap,
|
||||
libc::SIGTERM => Terminate,
|
||||
libc::SIGTTIN => TTYIn,
|
||||
libc::SIGTTOU => TTYOut,
|
||||
libc::SIGTSTP => TTYStop,
|
||||
libc::SIGTTIN => TtyIn,
|
||||
libc::SIGTTOU => TtyOut,
|
||||
libc::SIGTSTP => TtyStop,
|
||||
libc::SIGURG => Urgent,
|
||||
libc::SIGUSR1 => User1,
|
||||
libc::SIGUSR2 => User2,
|
||||
libc::SIGVTALRM => VTAlarm,
|
||||
libc::SIGVTALRM => VtAlarm,
|
||||
libc::SIGWINCH => Winch,
|
||||
libc::SIGXCPU => XCPU,
|
||||
libc::SIGXCPU => Xcpu,
|
||||
_ => {
|
||||
if value < SIGRTMIN() {
|
||||
return Err(Error::UnrecognizedSignum(value));
|
||||
|
@ -261,7 +261,7 @@ impl TryFrom<c_int> for Signal {
|
|||
}
|
||||
};
|
||||
if value > SIGRTMAX() {
|
||||
return Err(Error::RTSignumGreaterThanMax(signal));
|
||||
return Err(Error::RtSignumGreaterThanMax(signal));
|
||||
}
|
||||
signal
|
||||
}
|
||||
|
|
|
@ -105,11 +105,11 @@ impl CmsgBuffer {
|
|||
}
|
||||
}
|
||||
|
||||
fn raw_sendmsg<D: IntoIobuf>(fd: RawFd, out_data: &[D], out_fds: &[RawFd]) -> Result<usize> {
|
||||
fn raw_sendmsg<D: AsIobuf>(fd: RawFd, out_data: &[D], out_fds: &[RawFd]) -> Result<usize> {
|
||||
let cmsg_capacity = CMSG_SPACE!(size_of::<RawFd>() * out_fds.len());
|
||||
let mut cmsg_buffer = CmsgBuffer::with_capacity(cmsg_capacity);
|
||||
|
||||
let iovec = IntoIobuf::as_iobufs(out_data);
|
||||
let iovec = AsIobuf::as_iobuf_slice(out_data);
|
||||
|
||||
let mut msg = msghdr {
|
||||
msg_name: null_mut(),
|
||||
|
@ -239,7 +239,7 @@ pub trait ScmSocket {
|
|||
///
|
||||
/// * `buf` - A buffer of data to send on the `socket`.
|
||||
/// * `fd` - A file descriptors to be sent.
|
||||
fn send_with_fd<D: IntoIobuf>(&self, buf: &[D], fd: RawFd) -> Result<usize> {
|
||||
fn send_with_fd<D: AsIobuf>(&self, buf: &[D], fd: RawFd) -> Result<usize> {
|
||||
self.send_with_fds(buf, &[fd])
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ pub trait ScmSocket {
|
|||
///
|
||||
/// * `buf` - A buffer of data to send on the `socket`.
|
||||
/// * `fds` - A list of file descriptors to be sent.
|
||||
fn send_with_fds<D: IntoIobuf>(&self, buf: &[D], fd: &[RawFd]) -> Result<usize> {
|
||||
fn send_with_fds<D: AsIobuf>(&self, buf: &[D], fd: &[RawFd]) -> Result<usize> {
|
||||
raw_sendmsg(self.socket_fd(), buf, fd)
|
||||
}
|
||||
|
||||
|
@ -362,25 +362,26 @@ impl ScmSocket for UnixSeqpacket {
|
|||
///
|
||||
/// This trait is unsafe because interfaces that use this trait depend on the base pointer and size
|
||||
/// being accurate.
|
||||
pub unsafe trait IntoIobuf: Sized {
|
||||
pub unsafe trait AsIobuf: Sized {
|
||||
/// Returns a `iovec` that describes a contiguous region of memory.
|
||||
fn into_iobuf(&self) -> iovec;
|
||||
fn as_iobuf(&self) -> iovec;
|
||||
|
||||
/// Returns a slice of `iovec`s that each describe a contiguous region of memory.
|
||||
fn as_iobufs(bufs: &[Self]) -> &[iovec];
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
fn as_iobuf_slice(bufs: &[Self]) -> &[iovec];
|
||||
}
|
||||
|
||||
// Safe because there are no other mutable references to the memory described by `IoSlice` and it is
|
||||
// guaranteed to be ABI-compatible with `iovec`.
|
||||
unsafe impl<'a> IntoIobuf for IoSlice<'a> {
|
||||
fn into_iobuf(&self) -> iovec {
|
||||
unsafe impl<'a> AsIobuf for IoSlice<'a> {
|
||||
fn as_iobuf(&self) -> iovec {
|
||||
iovec {
|
||||
iov_base: self.as_ptr() as *mut c_void,
|
||||
iov_len: self.len(),
|
||||
}
|
||||
}
|
||||
|
||||
fn as_iobufs(bufs: &[Self]) -> &[iovec] {
|
||||
fn as_iobuf_slice(bufs: &[Self]) -> &[iovec] {
|
||||
// Safe because `IoSlice` is guaranteed to be ABI-compatible with `iovec`.
|
||||
unsafe { slice::from_raw_parts(bufs.as_ptr() as *const iovec, bufs.len()) }
|
||||
}
|
||||
|
@ -388,15 +389,15 @@ unsafe impl<'a> IntoIobuf for IoSlice<'a> {
|
|||
|
||||
// Safe because there are no other references to the memory described by `IoSliceMut` and it is
|
||||
// guaranteed to be ABI-compatible with `iovec`.
|
||||
unsafe impl<'a> IntoIobuf for IoSliceMut<'a> {
|
||||
fn into_iobuf(&self) -> iovec {
|
||||
unsafe impl<'a> AsIobuf for IoSliceMut<'a> {
|
||||
fn as_iobuf(&self) -> iovec {
|
||||
iovec {
|
||||
iov_base: self.as_ptr() as *mut c_void,
|
||||
iov_len: self.len(),
|
||||
}
|
||||
}
|
||||
|
||||
fn as_iobufs(bufs: &[Self]) -> &[iovec] {
|
||||
fn as_iobuf_slice(bufs: &[Self]) -> &[iovec] {
|
||||
// Safe because `IoSliceMut` is guaranteed to be ABI-compatible with `iovec`.
|
||||
unsafe { slice::from_raw_parts(bufs.as_ptr() as *const iovec, bufs.len()) }
|
||||
}
|
||||
|
@ -404,12 +405,12 @@ unsafe impl<'a> IntoIobuf for IoSliceMut<'a> {
|
|||
|
||||
// Safe because volatile slices are only ever accessed with other volatile interfaces and the
|
||||
// pointer and size are guaranteed to be accurate.
|
||||
unsafe impl<'a> IntoIobuf for VolatileSlice<'a> {
|
||||
fn into_iobuf(&self) -> iovec {
|
||||
unsafe impl<'a> AsIobuf for VolatileSlice<'a> {
|
||||
fn as_iobuf(&self) -> iovec {
|
||||
*self.as_iobuf()
|
||||
}
|
||||
|
||||
fn as_iobufs(bufs: &[Self]) -> &[iovec] {
|
||||
fn as_iobuf_slice(bufs: &[Self]) -> &[iovec] {
|
||||
VolatileSlice::as_iobufs(bufs)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue