From c1f4a7b295b577107d3107b47a190379aa7dcf08 Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Tue, 6 Feb 2024 14:48:41 -0800 Subject: [PATCH] main: Clarify `truncate` behavior for event monitor file Fix beta clippy issue: error: file opened with `create`, but `truncate` behavior not defined --> src/main.rs:624:26 | 624 | .create(true) | ^^^^^^^^^^^^- help: add: `.truncate(true)` | = help: if you intend to overwrite an existing file entirely, call `.truncate(true)` = help: if you instead know that you may want to keep some parts of the old file, call `.truncate(false)` = help: alternatively, use `.append(true)` to append to the file instead of overwriting it = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_open_options = note: `-D clippy::suspicious-open-options` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::suspicious_open_options)]` Signed-off-by: Bo Chen --- src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.rs b/src/main.rs index 36869215f..8016ac5bb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -622,6 +622,7 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result, Error> { std::fs::OpenOptions::new() .write(true) .create(true) + .truncate(true) .open(parser.get("path").unwrap()) .map_err(Error::EventMonitorIo)?, ))