diff options
| author | Lzu Tao <taolzu@gmail.com> | 2020-01-10 12:52:00 +0000 |
|---|---|---|
| committer | Lzu Tao <taolzu@gmail.com> | 2020-01-10 12:52:00 +0000 |
| commit | cd9a73d2ea4ca9452e3471d7e6c04af14eb1c2ed (patch) | |
| tree | 9cc6c46767976077aa615a3c8311a72201fbf376 /src/libstd/sys/wasi | |
| parent | 2d8d559bbecf6272eb41f8a800e319238aa9d621 (diff) | |
make use of pointer::is_null
Diffstat (limited to 'src/libstd/sys/wasi')
| -rw-r--r-- | src/libstd/sys/wasi/os.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libstd/sys/wasi/os.rs b/src/libstd/sys/wasi/os.rs index 3baec6bf099..8052c0aa8a8 100644 --- a/src/libstd/sys/wasi/os.rs +++ b/src/libstd/sys/wasi/os.rs @@ -6,7 +6,6 @@ use crate::io; use crate::marker::PhantomData; use crate::os::wasi::prelude::*; use crate::path::{self, PathBuf}; -use crate::ptr; use crate::str; use crate::sys::memchr; use crate::sys::{unsupported, Void}; @@ -107,11 +106,13 @@ pub fn env() -> Env { let _guard = env_lock(); let mut environ = libc::environ; let mut result = Vec::new(); - while environ != ptr::null_mut() && *environ != ptr::null_mut() { - if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) { - result.push(key_value); + if !environ.is_null() { + while !(*environ).is_null() { + if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) { + result.push(key_value); + } + environ = environ.add(1); } - environ = environ.offset(1); } return Env { iter: result.into_iter(), _dont_send_or_sync_me: PhantomData }; } |
