Skip to content

Commit b2d36f7

Browse files
Traistaru Andrei Cristianandreitraistaru
Traistaru Andrei Cristian
authored andcommitted
Adding comment for cmdline_contains()
Signed-off-by: Traistaru Andrei Cristian <[email protected]>
1 parent 92d24ff commit b2d36f7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/vmm/src/builder.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,16 @@ pub mod tests {
10891089
}
10901090

10911091
fn cmdline_contains(cmdline: &Cmdline, slug: &str) -> bool {
1092+
// The following unwraps can never fail; the only way any of these methods
1093+
// would return an `Err` is if one of the following conditions is met:
1094+
// 1. The command line is empty: We just added things to it, and if insertion
1095+
// of an argument goes wrong, then `Cmdline::insert` would have already
1096+
// returned `Err`.
1097+
// 2. There's a spurious null character somewhere in the command line: The
1098+
// `Cmdline::insert` methods verify that this is not the case.
1099+
// 3. The `CString` is not valid UTF8: It just got created from a `String`,
1100+
// which was valid UTF8.
1101+
10921102
cmdline
10931103
.as_cstring()
10941104
.unwrap()

0 commit comments

Comments
 (0)