clippy: misc. fixes
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
3f48cdb380
commit
ea368a06cd
@ -212,8 +212,7 @@ pub fn delete_datastore_disk(name: String) -> Result<(), Error> {
|
||||
let (config, _) = crate::config::datastore::config()?;
|
||||
let datastores: Vec<DataStoreConfig> = config.convert_to_typed_array("datastore")?;
|
||||
let conflicting_datastore: Option<DataStoreConfig> = datastores.into_iter()
|
||||
.filter(|ds| ds.path == path)
|
||||
.next();
|
||||
.find(|ds| ds.path == path);
|
||||
|
||||
if let Some(conflicting_datastore) = conflicting_datastore {
|
||||
bail!("Can't remove '{}' since it's required by datastore '{}'",
|
||||
|
@ -585,6 +585,7 @@ impl <R: Read + Seek> CatalogReader<R> {
|
||||
///
|
||||
/// Stores 7 bits per byte, Bit 8 indicates the end of the sequence (when not set).
|
||||
/// If the value is negative, we end with a zero byte (0x00).
|
||||
#[allow(clippy::neg_multiply)]
|
||||
pub fn catalog_encode_i64<W: Write>(writer: &mut W, v: i64) -> Result<(), Error> {
|
||||
let mut enc = Vec::new();
|
||||
|
||||
@ -617,6 +618,7 @@ pub fn catalog_encode_i64<W: Write>(writer: &mut W, v: i64) -> Result<(), Error>
|
||||
/// We currently read maximal 11 bytes, which give a maximum of 70 bits + sign.
|
||||
/// this method is compatible with catalog_encode_u64 iff the
|
||||
/// value encoded is <= 2^63 (values > 2^63 cannot be represented in an i64)
|
||||
#[allow(clippy::neg_multiply)]
|
||||
pub fn catalog_decode_i64<R: Read>(reader: &mut R) -> Result<i64, Error> {
|
||||
|
||||
let mut v: u64 = 0;
|
||||
|
@ -408,9 +408,7 @@ impl <'a, 'b> DataChunkBuilder<'a, 'b> {
|
||||
chunk_size: usize,
|
||||
compress: bool,
|
||||
) -> Result<(DataBlob, [u8; 32]), Error> {
|
||||
|
||||
let mut zero_bytes = Vec::with_capacity(chunk_size);
|
||||
zero_bytes.resize(chunk_size, 0u8);
|
||||
let zero_bytes = vec![0; chunk_size];
|
||||
let mut chunk_builder = DataChunkBuilder::new(&zero_bytes).compress(compress);
|
||||
if let Some(ref crypt_config) = crypt_config {
|
||||
chunk_builder = chunk_builder.crypt_config(crypt_config);
|
||||
|
@ -476,12 +476,11 @@ impl DataStore {
|
||||
let image_list = self.list_images()?;
|
||||
let image_count = image_list.len();
|
||||
|
||||
let mut done = 0;
|
||||
let mut last_percentage: usize = 0;
|
||||
|
||||
let mut strange_paths_count: u64 = 0;
|
||||
|
||||
for img in image_list {
|
||||
for (i, img) in image_list.into_iter().enumerate() {
|
||||
|
||||
worker.check_abort()?;
|
||||
tools::fail_on_shutdown()?;
|
||||
@ -514,15 +513,14 @@ impl DataStore {
|
||||
Err(err) if err.kind() == io::ErrorKind::NotFound => (), // ignore vanished files
|
||||
Err(err) => bail!("can't open index {} - {}", img.to_string_lossy(), err),
|
||||
}
|
||||
done += 1;
|
||||
|
||||
let percentage = done*100/image_count;
|
||||
let percentage = (i + 1) * 100 / image_count;
|
||||
if percentage > last_percentage {
|
||||
crate::task_log!(
|
||||
worker,
|
||||
"marked {}% ({} of {} index files)",
|
||||
percentage,
|
||||
done,
|
||||
i + 1,
|
||||
image_count,
|
||||
);
|
||||
last_percentage = percentage;
|
||||
|
@ -4,7 +4,7 @@ use std::os::unix::io::AsRawFd;
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use futures::*;
|
||||
use hyper;
|
||||
|
||||
use openssl::ssl::{SslMethod, SslAcceptor, SslFiletype};
|
||||
use tokio_stream::wrappers::ReceiverStream;
|
||||
|
||||
|
@ -293,7 +293,7 @@ fn test_crypt_speed(
|
||||
let speed = (bytes as f64)/start_time.elapsed().as_secs_f64();
|
||||
benchmark_result.sha256.speed = Some(speed);
|
||||
|
||||
eprintln!("SHA256 speed: {:.2} MB/s", speed/1_000_000_.0);
|
||||
eprintln!("SHA256 speed: {:.2} MB/s", speed/1_000_000.0);
|
||||
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
@ -308,7 +308,7 @@ fn test_crypt_speed(
|
||||
let speed = (bytes as f64)/start_time.elapsed().as_secs_f64();
|
||||
benchmark_result.compress.speed = Some(speed);
|
||||
|
||||
eprintln!("Compression speed: {:.2} MB/s", speed/1_000_000_.0);
|
||||
eprintln!("Compression speed: {:.2} MB/s", speed/1_000_000.0);
|
||||
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
@ -328,7 +328,7 @@ fn test_crypt_speed(
|
||||
let speed = (bytes as f64)/start_time.elapsed().as_secs_f64();
|
||||
benchmark_result.decompress.speed = Some(speed);
|
||||
|
||||
eprintln!("Decompress speed: {:.2} MB/s", speed/1_000_000_.0);
|
||||
eprintln!("Decompress speed: {:.2} MB/s", speed/1_000_000.0);
|
||||
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
@ -343,7 +343,7 @@ fn test_crypt_speed(
|
||||
let speed = (bytes as f64)/start_time.elapsed().as_secs_f64();
|
||||
benchmark_result.aes256_gcm.speed = Some(speed);
|
||||
|
||||
eprintln!("AES256/GCM speed: {:.2} MB/s", speed/1_000_000_.0);
|
||||
eprintln!("AES256/GCM speed: {:.2} MB/s", speed/1_000_000.0);
|
||||
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
@ -361,7 +361,7 @@ fn test_crypt_speed(
|
||||
let speed = (bytes as f64)/start_time.elapsed().as_secs_f64();
|
||||
benchmark_result.verify.speed = Some(speed);
|
||||
|
||||
eprintln!("Verify speed: {:.2} MB/s", speed/1_000_000_.0);
|
||||
eprintln!("Verify speed: {:.2} MB/s", speed/1_000_000.0);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ fn get_tape_handle(param: &Value) -> Result<LinuxTapeHandle, Error> {
|
||||
let file = unsafe { File::from_raw_fd(fd) };
|
||||
check_tape_is_linux_tape_device(&file)?;
|
||||
LinuxTapeHandle::new(file)
|
||||
} else if let Some(name) = std::env::var("PROXMOX_TAPE_DRIVE").ok() {
|
||||
} else if let Ok(name) = std::env::var("PROXMOX_TAPE_DRIVE") {
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
let drive: LinuxTapeDrive = config.lookup("linux", &name)?;
|
||||
eprintln!("using device {}", drive.path);
|
||||
|
@ -24,10 +24,7 @@ pub fn has_encryption<F: AsRawFd>(
|
||||
Ok(data) => data,
|
||||
Err(_) => return false,
|
||||
};
|
||||
match decode_spin_data_encryption_caps(&data) {
|
||||
Ok(_) => true,
|
||||
Err(_) => false,
|
||||
}
|
||||
decode_spin_data_encryption_caps(&data).is_ok()
|
||||
}
|
||||
|
||||
/// Set or clear encryption key
|
||||
|
@ -17,6 +17,7 @@ bitflags::bitflags!{
|
||||
///
|
||||
/// See LTO SCSI Reference LOG_SENSE - LP 2Eh: TapeAlerts
|
||||
pub struct TapeAlertFlags: u64 {
|
||||
#[allow(clippy::eq_op)]
|
||||
const READ_WARNING = 1 << (0x0001 -1);
|
||||
const WRITE_WARNING = 1 << (0x0002 -1);
|
||||
const HARD_ERROR = 1 << (0x0003 -1);
|
||||
|
@ -201,7 +201,7 @@ impl <'a, F: AsRawFd> SgRaw<'a, F> {
|
||||
|
||||
let data_len = self.buffer.len() -
|
||||
(unsafe { get_scsi_pt_resid(&mut *ptvp) } as usize);
|
||||
if data_len <= 0 {
|
||||
if data_len == 0 {
|
||||
bail!("do_scsi_pt failed - no data received");
|
||||
}
|
||||
|
||||
|
@ -144,6 +144,6 @@ fn correct_byte_convert() {
|
||||
assert_eq!(convert(1023), "1023 B");
|
||||
assert_eq!(convert(1<<10), "1.00 KiB");
|
||||
assert_eq!(convert(1<<20), "1.00 MiB");
|
||||
assert_eq!(convert((1<<30) + (103 * 1<<20)), "1.10 GiB");
|
||||
assert_eq!(convert((2<<50) + (500 * 1<<40)), "2.49 PiB");
|
||||
assert_eq!(convert((1<<30) + 103 * (1<<20)), "1.10 GiB");
|
||||
assert_eq!(convert((2<<50) + 500 * (1<<40)), "2.49 PiB");
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ pub fn write_canonical_json(value: &Value, output: &mut Vec<u8>) -> Result<(), E
|
||||
Value::Object(map) => {
|
||||
output.push(b'{');
|
||||
let mut keys: Vec<&str> = map.keys().map(String::as_str).collect();
|
||||
keys.sort();
|
||||
keys.sort_unstable();
|
||||
let mut iter = keys.into_iter();
|
||||
if let Some(key) = iter.next() {
|
||||
serde_json::to_writer(&mut *output, &key)?;
|
||||
|
@ -49,7 +49,7 @@ impl DateTimeValue {
|
||||
}
|
||||
|
||||
pub fn list_contains(list: &[DateTimeValue], value: u32) -> bool {
|
||||
list.iter().find(|spec| spec.contains(value)).is_some()
|
||||
list.iter().any(|spec| spec.contains(value))
|
||||
}
|
||||
|
||||
// Find an return an entry greater than value
|
||||
|
@ -52,9 +52,9 @@ fn pxar_create_and_extract() {
|
||||
.unwrap();
|
||||
|
||||
let reader = BufReader::new(stdout);
|
||||
let mut line_iter = reader.lines().map(|l| l.unwrap());
|
||||
let line_iter = reader.lines().map(|l| l.unwrap());
|
||||
let mut linecount = 0;
|
||||
while let Some(curr) = line_iter.next() {
|
||||
for curr in line_iter {
|
||||
println!("{}", curr);
|
||||
linecount += 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user