forked from Proxmox/proxmox
clippy: misc fixes
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
b1c2250000
commit
e303ad8605
@ -257,7 +257,7 @@ impl CommandLineInterface {
|
|||||||
/// ``stdout``.
|
/// ``stdout``.
|
||||||
pub fn print_bash_completion(&self) {
|
pub fn print_bash_completion(&self) {
|
||||||
let comp_point: usize = match std::env::var("COMP_POINT") {
|
let comp_point: usize = match std::env::var("COMP_POINT") {
|
||||||
Ok(val) => match usize::from_str_radix(&val, 10) {
|
Ok(val) => match val.parse::<usize>() {
|
||||||
Ok(i) => i,
|
Ok(i) => i,
|
||||||
Err(_) => return,
|
Err(_) => return,
|
||||||
},
|
},
|
||||||
|
@ -223,14 +223,14 @@ fn test_boolean_arg() {
|
|||||||
for (args, expect) in variants {
|
for (args, expect) in variants {
|
||||||
let res = parse_arguments(
|
let res = parse_arguments(
|
||||||
&args,
|
&args,
|
||||||
&vec![],
|
&[],
|
||||||
&HashMap::new(),
|
&HashMap::new(),
|
||||||
ParameterSchema::from(&PARAMETERS),
|
ParameterSchema::from(&PARAMETERS),
|
||||||
);
|
);
|
||||||
assert!(res.is_ok());
|
assert!(res.is_ok());
|
||||||
if let Ok((options, remaining)) = res {
|
if let Ok((options, remaining)) = res {
|
||||||
assert!(options["enable"] == expect);
|
assert!(options["enable"] == expect);
|
||||||
assert!(remaining.len() == 0);
|
assert!(remaining.is_empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,6 +258,6 @@ fn test_argument_paramenter() {
|
|||||||
if let Ok((options, remaining)) = res {
|
if let Ok((options, remaining)) = res {
|
||||||
assert!(options["enable"] == true);
|
assert!(options["enable"] == true);
|
||||||
assert!(options["storage"] == "local");
|
assert!(options["storage"] == "local");
|
||||||
assert!(remaining.len() == 0);
|
assert!(remaining.is_empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,9 +278,7 @@ impl TableFormatOptions {
|
|||||||
let key = key.into();
|
let key = key.into();
|
||||||
match self.sortkeys {
|
match self.sortkeys {
|
||||||
None => {
|
None => {
|
||||||
let mut list = Vec::new();
|
self.sortkeys = Some(vec![(key, sort_desc)]);
|
||||||
list.push((key, sort_desc));
|
|
||||||
self.sortkeys = Some(list);
|
|
||||||
}
|
}
|
||||||
Some(ref mut list) => {
|
Some(ref mut list) => {
|
||||||
list.push((key, sort_desc));
|
list.push((key, sort_desc));
|
||||||
@ -379,9 +377,7 @@ fn format_table<W: Write>(
|
|||||||
let sortkeys = if let Some(ref sortkeys) = options.sortkeys {
|
let sortkeys = if let Some(ref sortkeys) = options.sortkeys {
|
||||||
sortkeys.clone()
|
sortkeys.clone()
|
||||||
} else {
|
} else {
|
||||||
let mut keys = Vec::new();
|
vec![(properties_to_print[0].clone(), false)] // leftmost, ASC
|
||||||
keys.push((properties_to_print[0].clone(), false)); // leftmost, ASC
|
|
||||||
keys
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut sortinfo = Vec::new();
|
let mut sortinfo = Vec::new();
|
||||||
@ -712,9 +708,7 @@ fn format_object<W: Write>(
|
|||||||
right_align: all_right_aligned,
|
right_align: all_right_aligned,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut tabledata: Vec<TableColumn> = Vec::new();
|
let tabledata = vec![name_column, value_column];
|
||||||
tabledata.push(name_column);
|
|
||||||
tabledata.push(value_column);
|
|
||||||
|
|
||||||
render_table(output, &tabledata, &column_names, options)
|
render_table(output, &tabledata, &column_names, options)
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ mod test {
|
|||||||
return groups.contains(&Value::from(group));
|
return groups.contains(&Value::from(group));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lookup_privs(&self, userid: &str, path: &[&str]) -> u64 {
|
fn lookup_privs(&self, userid: &str, path: &[&str]) -> u64 {
|
||||||
@ -227,7 +227,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ impl StringSchema {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ApiStringFormat::Enum(variants) => {
|
ApiStringFormat::Enum(variants) => {
|
||||||
if variants.iter().find(|&e| e.value == value).is_none() {
|
if !variants.iter().any(|e| e.value == value) {
|
||||||
bail!("value '{}' is not defined in the enumeration.", value);
|
bail!("value '{}' is not defined in the enumeration.", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ fn mmap_file<T: Init>(file: &mut File, initialize: bool) -> Result<Mmap<T>, Erro
|
|||||||
Init::initialize(&mut mmap[0]);
|
Init::initialize(&mut mmap[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
match Init::check_type_magic(&mut mmap[0]) {
|
match Init::check_type_magic(&mmap[0]) {
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
Err(err) => bail!("detected wrong types in mmaped files: {}", err),
|
Err(err) => bail!("detected wrong types in mmaped files: {}", err),
|
||||||
}
|
}
|
||||||
@ -164,20 +164,20 @@ impl <T: Sized + Init> SharedMemory<T> {
|
|||||||
drop(file); // no longer required
|
drop(file); // no longer required
|
||||||
|
|
||||||
match res {
|
match res {
|
||||||
Ok(_rc) => return Ok(mmap),
|
Ok(_rc) => Ok(mmap),
|
||||||
// if someone else was faster, open the existing file:
|
// if someone else was faster, open the existing file:
|
||||||
Err(nix::Error::Sys(Errno::EEXIST)) => {
|
Err(nix::Error::Sys(Errno::EEXIST)) => {
|
||||||
// if opening fails again now, we'll just error...
|
// if opening fails again now, we'll just error...
|
||||||
match nix::fcntl::open(path, oflag, Mode::empty()) {
|
match nix::fcntl::open(path, oflag, Mode::empty()) {
|
||||||
Ok(fd) => {
|
Ok(fd) => {
|
||||||
let mut file = unsafe { File::from_raw_fd(fd) };
|
let mut file = unsafe { File::from_raw_fd(fd) };
|
||||||
let mmap = mmap_file(&mut file, false)?;
|
let mmap = mmap_file(&mut file, false)?;
|
||||||
return Ok(mmap);
|
Ok(mmap)
|
||||||
}
|
}
|
||||||
Err(err) => bail!("open {:?} failed - {}", path, err),
|
Err(err) => bail!("open {:?} failed - {}", path, err),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
Err(err) => return Err(err.into()),
|
Err(err) => Err(err.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ fn sort_data(data: TokenStream) -> Result<TokenStream, Error> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Some(err) = err {
|
if let Some(err) = err {
|
||||||
return Err(err.into());
|
return Err(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
array.elems = Punctuated::from_iter(fields);
|
array.elems = Punctuated::from_iter(fields);
|
||||||
|
@ -28,7 +28,7 @@ pub fn fill_with_random_data(buffer: &mut [u8]) -> Result<(), Error> {
|
|||||||
libc::getrandom(
|
libc::getrandom(
|
||||||
buffer.as_mut_ptr() as *mut libc::c_void,
|
buffer.as_mut_ptr() as *mut libc::c_void,
|
||||||
buffer.len() as libc::size_t,
|
buffer.len() as libc::size_t,
|
||||||
0 as libc::c_uint,
|
0_u32,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ impl LogRotate {
|
|||||||
}
|
}
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
base_path: path.as_ref().to_path_buf(),
|
base_path: path.as_ref().to_path_buf(),
|
||||||
options: options.unwrap_or(CreateOptions::new()),
|
options: options.unwrap_or_default(),
|
||||||
compress,
|
compress,
|
||||||
max_files,
|
max_files,
|
||||||
})
|
})
|
||||||
@ -58,7 +58,7 @@ impl LogRotate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compress(source_path: &PathBuf, target_path: &PathBuf, options: &CreateOptions) -> Result<(), Error> {
|
fn compress(source_path: &Path, target_path: &Path, options: &CreateOptions) -> Result<(), Error> {
|
||||||
let mut source = File::open(source_path)?;
|
let mut source = File::open(source_path)?;
|
||||||
let (fd, tmp_path) = make_tmp_file(target_path, options.clone())?;
|
let (fd, tmp_path) = make_tmp_file(target_path, options.clone())?;
|
||||||
let target = unsafe { File::from_raw_fd(fd.into_raw_fd()) };
|
let target = unsafe { File::from_raw_fd(fd.into_raw_fd()) };
|
||||||
|
Loading…
Reference in New Issue
Block a user