fix clippy warnings

This commit is contained in:
Matt Bilker 2022-01-09 13:32:35 +00:00
parent 856a9a8cb6
commit 388e7c29d7
No known key found for this signature in database
GPG Key ID: 69ADF8AEB6C8B5D1
4 changed files with 6 additions and 6 deletions

View File

@ -26,7 +26,7 @@ pub fn dump(data: &[u8]) -> String {
output.push(' '); output.push(' ');
output.extend(data.iter().map(|&c| { output.extend(data.iter().map(|&c| {
if c < 0x20 || c >= 0x7f { if !(0x20..0x7f).contains(&c) {
'.' '.'
} else { } else {
c as char c as char

View File

@ -13,7 +13,7 @@ impl<'a> fmt::Debug for CStrFormat<'a> {
impl<'a> fmt::Display for CStrFormat<'a> { impl<'a> fmt::Display for CStrFormat<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let s = crate::from_c_str(&self.0); let s = crate::from_c_str(self.0);
fmt::Debug::fmt(&s, f) fmt::Debug::fmt(&s, f)
} }

View File

@ -55,8 +55,8 @@ static CONFIG: Config = {
} }
}; };
const DEFAULT_CONFIG_PATH: &'static str = "/etc/vgpu_unlock/config.toml"; const DEFAULT_CONFIG_PATH: &str = "/etc/vgpu_unlock/config.toml";
const DEFAULT_PROFILE_OVERRIDE_CONFIG_PATH: &'static str = "/etc/vgpu_unlock/profile_override.toml"; const DEFAULT_PROFILE_OVERRIDE_CONFIG_PATH: &str = "/etc/vgpu_unlock/profile_override.toml";
/// Value of the "request" argument used by `nvidia-vgpud` and `nvidia-vgpu-mgr` when calling /// Value of the "request" argument used by `nvidia-vgpud` and `nvidia-vgpu-mgr` when calling
/// ioctl to read the PCI device ID and type (and possibly other things) from the GPU. /// ioctl to read the PCI device ID and type (and possibly other things) from the GPU.
@ -380,7 +380,7 @@ pub unsafe extern "C" fn ioctl(fd: RawFd, request: c_ulong, argp: *mut c_void) -
ret ret
} }
pub fn from_c_str<'a>(value: &'a [u8]) -> Cow<'a, str> { pub fn from_c_str(value: &[u8]) -> Cow<'_, str> {
let len = value.iter().position(|&c| c == 0).unwrap_or(value.len()); let len = value.iter().position(|&c| c == 0).unwrap_or(value.len());
String::from_utf8_lossy(&value[..len]) String::from_utf8_lossy(&value[..len])

View File

@ -25,7 +25,7 @@ pub(crate) fn syslog(level: c_int, args: fmt::Arguments<'_>) {
let _ = msg_buffer.write_all(b"Failed to format message: "); let _ = msg_buffer.write_all(b"Failed to format message: ");
if let Err(_) = write!(&mut msg_buffer, "{}", e) { if write!(&mut msg_buffer, "{}", e).is_err() {
msg_buffer.clear(); msg_buffer.clear();
let _ = msg_buffer.write_all(b"Failed to format message and error message"); let _ = msg_buffer.write_all(b"Failed to format message and error message");