-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chroot: remove unwrap calls #7890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
GNU testsuite comparison:
|
src/uu/chroot/src/chroot.rs
Outdated
@@ -439,7 +439,9 @@ fn enter_chroot(root: &Path, skip_chdir: bool) -> UResult<()> { | |||
let err = unsafe { | |||
chroot( | |||
CString::new(root.as_os_str().as_bytes().to_vec()) | |||
.unwrap() | |||
.map_err(|e| { | |||
ChrootError::CannotEnter("Unable to enter root directory".to_string(), e.into()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think the "unable to enter..." string should be passed
coreutils/src/uu/chroot/src/error.rs
Line 17 in 9d9f2c9
#[error("cannot chroot to {dir}: {err}", dir = .0.quote(), err = .1)] |
the first arg is the path (so, root here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, I'll fix that. Sorry for the delay, I've been on vacation!
@jovielarue ping ? :) |
GNU testsuite comparison:
|
This PR aims to solve #7876. I have not found the underlying problem to that issue, but I have removed the unwrap() calls on lines 442 and 451 as mentioned in #7876 so that the code aligns with the "never use panic!" guideline.