Skip to content

Commit

Permalink
virtme-ng-init: always check return code when executing bash
Browse files Browse the repository at this point in the history
Fix the following warning:

warning: unused return value of `exec` that must be used
   --> src/main.rs:978:13
    |
978 |             Command::new("bash").arg("-l").exec();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(unused_must_use)]` on by default

Moreover, check the return code in case exec() fails and log an explicit
error before exiting.

Signed-off-by: Andrea Righi <[email protected]>
  • Loading branch information
arighi committed Jan 23, 2025
1 parent f1c27d9 commit 89ea3b1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion virtme_ng_init/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,8 @@ fn setup_user_session() {
Some(console) => console,
None => {
log!("failed to determine console");
Command::new("bash").arg("-l").exec();
let err = Command::new("bash").arg("-l").exec();
log!("failed to exec bash: {}", err);
return;
}
};
Expand Down

0 comments on commit 89ea3b1

Please sign in to comment.