mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-18 07:18:27 +00:00
genpolicy: Fix clippy manual_unwrap_or_default
Manually fix `manual_unwrap_or_default` clippy warning reported by rust 1.85.1. ```console error: if let can be simplified with `.unwrap_or_default()` --> src/registry.rs:619:37 | 619 | let mut data: Vec<ImageLayer> = if let Ok(vec) = serde_json::from_reader(read_file) { | _____________________________________^ 620 | | vec 621 | | } else { ... | 624 | | }; | |_____^ help: replace it with: `serde_json::from_reader(read_file).unwrap_or_default()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default = note: `-D clippy::manual-unwrap-or-default` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::manual_unwrap_or_default)]` ``` Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
@@ -575,12 +575,8 @@ pub fn add_verity_and_users_to_store(
|
||||
.truncate(false)
|
||||
.open(cache_file)?;
|
||||
|
||||
let mut data: Vec<ImageLayer> = if let Ok(vec) = serde_json::from_reader(read_file) {
|
||||
vec
|
||||
} else {
|
||||
// Delete the malformed file here if it's present
|
||||
Vec::new()
|
||||
};
|
||||
// Return empty vector if the file is malformed
|
||||
let mut data: Vec<ImageLayer> = serde_json::from_reader(read_file).unwrap_or_default();
|
||||
|
||||
// Add new data to the deserialized JSON
|
||||
data.push(ImageLayer {
|
||||
|
Reference in New Issue
Block a user