Skip to content

Commit a465ff4

Browse files
nyurikRenjiSann
authored andcommitted
rm unused error
1 parent 178daed commit a465ff4

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/uu/chroot/src/chroot.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ struct Options {
5353
///
5454
/// The `spec` must be of the form `[USER][:[GROUP]]`, otherwise an
5555
/// error is returned.
56-
fn parse_userspec(spec: &str) -> UResult<UserSpec> {
57-
Ok(match spec.split_once(':') {
56+
fn parse_userspec(spec: &str) -> UserSpec {
57+
match spec.split_once(':') {
5858
// ""
5959
None if spec.is_empty() => UserSpec::NeitherGroupNorUser,
6060
// "usr"
@@ -67,10 +67,7 @@ fn parse_userspec(spec: &str) -> UResult<UserSpec> {
6767
Some((usr, "")) => UserSpec::UserOnly(usr.to_string()),
6868
// "usr:grp"
6969
Some((usr, grp)) => UserSpec::UserAndGroup(usr.to_string(), grp.to_string()),
70-
// BUG: this would never be reached. Should we check for another ':', or some invalid characters?
71-
// everything else
72-
// _ => Err(ChrootError::InvalidUserspec(spec.to_string()).into()),
73-
})
70+
}
7471
}
7572

7673
// Pre-condition: `list_str` is non-empty.
@@ -145,10 +142,9 @@ impl Options {
145142
}
146143
};
147144
let skip_chdir = matches.get_flag(options::SKIP_CHDIR);
148-
let userspec = match matches.get_one::<String>(options::USERSPEC) {
149-
None => None,
150-
Some(s) => Some(parse_userspec(s)?),
151-
};
145+
let userspec = matches
146+
.get_one::<String>(options::USERSPEC)
147+
.map(|s| parse_userspec(s));
152148
Ok(Self {
153149
newroot,
154150
skip_chdir,

src/uu/chroot/src/error.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ pub enum ChrootError {
3434
#[error("invalid group list: {list}", list = .0.quote())]
3535
InvalidGroupList(String),
3636

37-
/// The given user and group specification was invalid.
38-
#[error("invalid userspec: {spec}", spec = .0.quote())]
39-
InvalidUserspec(String),
40-
4137
/// The new root directory was not given.
4238
#[error(
4339
"Missing operand: NEWROOT\nTry '{0} --help' for more information.",

0 commit comments

Comments
 (0)