From dd36fec23db414c7eeed40b23208bdcd3a6d7ac4 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 25 Jul 2024 13:53:08 +0200 Subject: [PATCH] sys: replace CStr::from_bytes_... with c"literals" Signed-off-by: Wolfgang Bumiller --- proxmox-sys/src/fs/dir.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/proxmox-sys/src/fs/dir.rs b/proxmox-sys/src/fs/dir.rs index 6a5ad4d9..173a8ff9 100644 --- a/proxmox-sys/src/fs/dir.rs +++ b/proxmox-sys/src/fs/dir.rs @@ -117,11 +117,7 @@ fn create_path_do( Some(Component::Prefix(_)) => bail!("illegal prefix path component encountered"), Some(Component::RootDir) => { let _ = iter.next(); - crate::fd::open( - unsafe { CStr::from_bytes_with_nul_unchecked(b"/\0") }, - OFlag::O_DIRECTORY, - stat::Mode::empty(), - )? + crate::fd::open(c"/", OFlag::O_DIRECTORY, stat::Mode::empty())? } Some(Component::CurDir) => { let _ = iter.next(); @@ -129,11 +125,7 @@ fn create_path_do( } Some(Component::ParentDir) => { let _ = iter.next(); - crate::fd::open( - unsafe { CStr::from_bytes_with_nul_unchecked(b"..\0") }, - OFlag::O_DIRECTORY, - stat::Mode::empty(), - )? + crate::fd::open(c"..", OFlag::O_DIRECTORY, stat::Mode::empty())? } Some(Component::Normal(_)) => { // simply do not advance the iterator, heavy lifting happens in create_path_at_do() @@ -159,12 +151,7 @@ fn create_path_at_do( None => return Ok(created), Some(Component::ParentDir) => { - at = crate::fd::openat( - &at, - unsafe { CStr::from_bytes_with_nul_unchecked(b"..\0") }, - OFlag::O_DIRECTORY, - stat::Mode::empty(), - )?; + at = crate::fd::openat(&at, c"..", OFlag::O_DIRECTORY, stat::Mode::empty())?; } Some(Component::Normal(path)) => {