Skip to content

Commit f4a665f

Browse files
committed
unistd: groups: clean up return statements
1 parent c95d70f commit f4a665f

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/unistd.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ pub fn getgroups() -> Result<Vec<Gid>> {
966966
match Errno::result(ret) {
967967
Ok(s) => {
968968
unsafe { groups.set_len(s as usize) };
969-
break
969+
return Ok(groups);
970970
},
971971
Err(Error::Sys(Errno::EINVAL)) => {
972972
// EINVAL indicates that size was too small, so trigger a
@@ -979,7 +979,6 @@ pub fn getgroups() -> Result<Vec<Gid>> {
979979
Err(e) => return Err(e)
980980
}
981981
}
982-
Ok(groups)
983982
}
984983

985984
/// Set the list of supplementary group IDs for the calling process.
@@ -1049,7 +1048,7 @@ pub fn getgrouplist(user: &CString, group: Gid) -> Result<Vec<Gid>> {
10491048
// BSD systems only return 0 or -1, Linux returns ngroups on success.
10501049
if ret >= 0 {
10511050
unsafe { groups.set_len(ngroups as usize) };
1052-
break
1051+
return Ok(groups);
10531052
}
10541053

10551054
// Returns -1 if ngroups is too small, but does not set errno.
@@ -1059,7 +1058,7 @@ pub fn getgrouplist(user: &CString, group: Gid) -> Result<Vec<Gid>> {
10591058
let cap = groups.capacity();
10601059
if cap >= ngroups_max as usize {
10611060
// We already have the largest capacity we can, give up
1062-
return Err(Error::invalid_argument())
1061+
return Err(Error::invalid_argument());
10631062
}
10641063

10651064
// Reserve space for at least ngroups
@@ -1070,8 +1069,6 @@ pub fn getgrouplist(user: &CString, group: Gid) -> Result<Vec<Gid>> {
10701069
ngroups = min(ngroups_max, groups.capacity() as c_int);
10711070
}
10721071
}
1073-
1074-
Ok(groups)
10751072
}
10761073

10771074
/// Initialize the supplementary group access list. Sets the supplementary

0 commit comments

Comments
 (0)