Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5661358

Browse files
RenTrieuphip1611
andauthored
uefi: Revise comments to be more descriptive and use macros for CStr16
Co-authored-by: Philipp Schuster <phip1611@gmail.com>
1 parent 42cad4a commit 5661358

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

‎uefi-test-runner/src/proto/shell.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
2525
/* Test setting and getting a specific environment variable */
2626
let cur_env_vec = shell.get_envs();
2727
let mut test_env_buf = [0u16; 32];
28-
let test_var = CStr16::from_str_with_buf("test_var",&mut test_env_buf).unwrap();
28+
let test_var = cstr16!("test_var");
2929
let mut test_val_buf = [0u16; 32];
30-
let test_val = CStr16::from_str_with_buf("test_val",&mut test_val_buf).unwrap();
30+
let test_val = cstr16!("test_val");
3131
assert!(shell.get_env(test_var).is_none());
3232
let status = shell.set_env(test_var, test_val, false);
3333
assert_eq!(status, Status::SUCCESS);
@@ -56,7 +56,7 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
5656
assert_eq!(cur_env_vec.count(), default_len + 1);
5757

5858
/* Test deleting environment variable */
59-
let test_val = CStr16::from_str_with_buf("",&mut test_val_buf).unwrap();
59+
let test_val = cstr16!("");
6060
let status = shell.set_env(test_var, test_val, false);
6161
assert_eq!(status, Status::SUCCESS);
6262
assert!(shell.get_env(test_var).is_none());
@@ -73,13 +73,13 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
7373
assert_eq!(cur_env_vec.count(), default_len);
7474
}
7575

76-
/// Test ``get_cur_dir()`` and ``set_cur_dir()``
76+
/// Test `get_cur_dir()` and `set_cur_dir()`
7777
pub fn test_cur_dir(shell: &ScopedProtocol<Shell>) {
7878
let mut test_buf = [0u16; 128];
7979

8080
/* Test setting and getting current file system and current directory */
8181
let mut fs_buf = [0u16; 16];
82-
let fs_var = CStr16::from_str_with_buf("fs0:",&mut fs_buf).unwrap();
82+
let fs_var = cstr16!("fs0:")
8383
let mut dir_buf = [0u16; 32];
8484
let dir_var = CStr16::from_str_with_buf("/", &mut dir_buf).unwrap();
8585
let status = shell.set_cur_dir(Some(fs_var), Some(dir_var));

‎uefi/src/proto/shell/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::{CStr16, Char16};
1818
#[unsafe_protocol(ShellProtocol::GUID)]
1919
pub struct Shell(ShellProtocol);
2020

21-
/// Contains environment variables
21+
/// Iterator over the names of environmental variables obtained from the Shell protocol.
2222
#[derive(Debug)]
2323
pub struct Vars<'a> {
2424
/// Char16 containing names of environment variables
@@ -29,6 +29,8 @@ pub struct Vars<'a> {
2929

3030
impl<'a> Iterator for Vars<'a> {
3131
type Item = &'a CStr16;
32+
// We iterate a list of NUL terminated CStr16s.
33+
// The list is terminated with a double NUL.
3234
fn next(&mut self) -> Option<Self::Item> {
3335
let cur_start = self.inner;
3436
let mut cur_len = 0;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /