diff --git a/src/ctx.rs b/src/ctx.rs index c31b05513b..993f6dd924 100644 --- a/src/ctx.rs +++ b/src/ctx.rs @@ -110,7 +110,7 @@ impl WasiCtxBuilder { .into_iter() .map(|(k, v)| { let mut pair = k.into_bytes(); - pair.extend_from_slice(b"="); + pair.push(b'='); pair.extend_from_slice(v.to_bytes_with_nul()); // constructing a new CString from existing CStrings is safe unsafe { CString::from_vec_unchecked(pair) } diff --git a/src/hostcalls_impl/fs_helpers.rs b/src/hostcalls_impl/fs_helpers.rs index 1886681b66..ec433aea50 100644 --- a/src/hostcalls_impl/fs_helpers.rs +++ b/src/hostcalls_impl/fs_helpers.rs @@ -61,7 +61,7 @@ pub(crate) fn path_get( Some(cur_path) => { log::debug!("cur_path = {:?}", cur_path); - let ends_with_slash = cur_path.ends_with("/"); + let ends_with_slash = cur_path.ends_with('/'); let mut components = Path::new(&cur_path).components(); let head = match components.next() { None => return Err(host::__WASI_ENOENT), @@ -72,7 +72,7 @@ pub(crate) fn path_get( if tail.components().next().is_some() { let mut tail = host_impl::path_from_host(tail.as_os_str())?; if ends_with_slash { - tail.push_str("/"); + tail.push('/'); } path_stack.push(tail); } @@ -98,7 +98,7 @@ pub(crate) fn path_get( let mut head = host_impl::path_from_host(head)?; if ends_with_slash { // preserve trailing slash - head.push_str("/"); + head.push('/'); } if !path_stack.is_empty() || (ends_with_slash && !needs_final_component) { @@ -124,8 +124,8 @@ pub(crate) fn path_get( return Err(host::__WASI_ELOOP); } - if head.ends_with("/") { - link_path.push_str("/"); + if head.ends_with('/') { + link_path.push('/'); } log::debug!( @@ -156,8 +156,8 @@ pub(crate) fn path_get( return Err(host::__WASI_ELOOP); } - if head.ends_with("/") { - link_path.push_str("/"); + if head.ends_with('/') { + link_path.push('/'); } log::debug!( diff --git a/src/sys/windows/hostcalls_impl/fs_helpers.rs b/src/sys/windows/hostcalls_impl/fs_helpers.rs index b2c96d9e42..6064a5d31d 100644 --- a/src/sys/windows/hostcalls_impl/fs_helpers.rs +++ b/src/sys/windows/hostcalls_impl/fs_helpers.rs @@ -86,9 +86,9 @@ pub(crate) fn readlinkat(dirfd: &File, s_path: &str) -> Result { log::debug!("readlinkat error={:?}", e); match WinError::from_u32(e as u32) { WinError::ERROR_INVALID_NAME => { - if s_path.ends_with("/") { + if s_path.ends_with('/') { // strip "/" and check if exists - let path = concatenate(dirfd, Path::new(s_path.trim_end_matches("/")))?; + let path = concatenate(dirfd, Path::new(s_path.trim_end_matches('/')))?; if path.exists() && !path.is_dir() { Err(host::__WASI_ENOTDIR) } else {