mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 23:32:39 +00:00
Remove tail return statements.
Per review feedback.
This commit is contained in:
parent
1adc027382
commit
bad19f6016
40 changed files with 61 additions and 60 deletions
|
@ -89,7 +89,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
Version => version()
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
|
|
@ -86,7 +86,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
println(name.as_slice());
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn strip_dir(fullname: &str) -> String {
|
||||
|
@ -99,7 +99,7 @@ fn strip_dir(fullname: &str) -> String {
|
|||
name.push_char(c);
|
||||
}
|
||||
|
||||
return name.as_slice().chars().rev().collect();
|
||||
name.as_slice().chars().rev().collect()
|
||||
}
|
||||
|
||||
fn strip_suffix(name: &str, suffix: &str) -> String {
|
||||
|
@ -111,5 +111,5 @@ fn strip_suffix(name: &str, suffix: &str) -> String {
|
|||
return name.slice_to(name.len() - suffix.len()).into_string();
|
||||
}
|
||||
|
||||
return name.into_string();
|
||||
name.into_string()
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
exec(files, number_mode, show_nonprint, show_ends, show_tabs, squeeze_blank);
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
#[deriving(Eq, PartialEq)]
|
||||
|
@ -285,12 +285,12 @@ fn open(path: &str) -> Option<(Box<Reader>, bool)> {
|
|||
}
|
||||
|
||||
match File::open(&std::path::Path::new(path)) {
|
||||
Ok(f) => return Some((box f as Box<Reader>, false)),
|
||||
Ok(f) => Some((box f as Box<Reader>, false)),
|
||||
Err(e) => {
|
||||
(writeln!(stderr(), "cat: {0:s}: {1:s}", path, e.to_str())).unwrap();
|
||||
return None;
|
||||
None
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
struct UnsafeWriter<'a, W> {
|
||||
|
|
|
@ -130,5 +130,5 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
}
|
||||
|
||||
return exit_code;
|
||||
exit_code
|
||||
}
|
||||
|
|
|
@ -136,5 +136,5 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
comm(&mut f1, &mut f2, &matches);
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
|
2
cp/cp.rs
2
cp/cp.rs
|
@ -63,7 +63,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
Version => version(),
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn version() {
|
||||
|
|
|
@ -68,5 +68,5 @@ directory).", opts).as_slice());
|
|||
println!("Try '{0:s} --help' for more information.", program);
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
|
4
du/du.rs
4
du/du.rs
|
@ -86,7 +86,7 @@ fn du(path: &Path, mut my_stat: Stat,
|
|||
|
||||
stats.push(Arc::new(my_stat));
|
||||
|
||||
return stats;
|
||||
stats
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
@ -367,5 +367,5 @@ Try '{program} --help' for more information.", s, program = program);
|
|||
print!("{}", line_separator);
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
|
|
@ -66,7 +66,8 @@ fn convert_str(string: &str, index: uint, base: uint) -> (char, int) {
|
|||
}
|
||||
}
|
||||
}
|
||||
return (to_char(&bytes, base), max_digits)
|
||||
|
||||
(to_char(&bytes, base), max_digits)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
@ -187,5 +188,5 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
println!("")
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
|
2
env/env.rs
vendored
2
env/env.rs
vendored
|
@ -211,5 +211,5 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
print_env(opts.null);
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
fold(files, bytes, spaces, width);
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn handle_obsolete(args: &[String]) -> (Vec<String>, Option<String>) {
|
||||
|
|
|
@ -43,5 +43,5 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
group(get_pw_from_args(&matches.free), true);
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
// It searches for an option in the form of -123123
|
||||
|
|
|
@ -84,7 +84,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
Version => version(),
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn version() {
|
||||
|
|
|
@ -65,7 +65,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
_ => { help_menu(program.as_slice(), options); }
|
||||
};
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn version() {
|
||||
|
|
2
id/id.rs
2
id/id.rs
|
@ -195,7 +195,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
id_print(possible_pw, false, true, true)
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn pretty(possible_pw: Option<c_passwd>) {
|
||||
|
|
|
@ -97,7 +97,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
Version => version(),
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn version() {
|
||||
|
@ -177,7 +177,7 @@ fn signal_by_name_or_value(signal_name_or_value: &str) -> Option<uint> {
|
|||
return Some(signal.value);
|
||||
}
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
|
||||
fn kill(signalname: &str, pids: std::vec::Vec<String>) {
|
||||
|
|
|
@ -78,7 +78,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
exec();
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn exec() {
|
||||
|
|
|
@ -80,7 +80,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn md5sum(files: Vec<String>, binary: bool, check: bool, tag: bool, status: bool, quiet: bool, strict: bool, warn: bool) -> Result<(), int> {
|
||||
|
@ -150,7 +150,7 @@ fn md5sum(files: Vec<String>, binary: bool, check: bool, tag: bool, status: bool
|
|||
}
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn calc_sum(md5: &mut crypto::md5::Md5, file: &mut Reader, binary: bool) -> String {
|
||||
|
|
|
@ -85,8 +85,8 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
crash!(1, "missing operand");
|
||||
}
|
||||
match exec(dirs, mk_parents, mode, verbose_flag) {
|
||||
Ok(()) => return 0,
|
||||
Err(e) => return e
|
||||
Ok(()) => 0,
|
||||
Err(e) => e
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ fn exec(dirs: Vec<String>, mk_parents: bool, mode: FilePermission, verbose: bool
|
|||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
result
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,7 +57,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
paste(matches.free, serial, delimiters.as_slice());
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn paste(filenames: Vec<String>, serial: bool, delimiters: &str) {
|
||||
|
|
|
@ -60,7 +60,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
exec(matches.free, separator);
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
pub fn exec(args: Vec<String>, separator: &str) {
|
||||
|
|
|
@ -58,5 +58,5 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
|
8
rm/rm.rs
8
rm/rm.rs
|
@ -124,7 +124,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
// TODO: implement one-file-system
|
||||
|
@ -167,7 +167,7 @@ fn remove(files: Vec<String>, force: bool, interactive: InteractiveMode, one_fs:
|
|||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
r
|
||||
}
|
||||
|
||||
fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), int> {
|
||||
|
@ -187,7 +187,7 @@ fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bo
|
|||
}
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn remove_file(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), int> {
|
||||
|
@ -207,7 +207,7 @@ fn remove_file(path: &Path, name: &str, interactive: InteractiveMode, verbose: b
|
|||
}
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn prompt_file(path: &Path, name: &str) -> bool {
|
||||
|
|
|
@ -66,7 +66,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn remove(dirs: Vec<String>, ignore: bool, parents: bool, verbose: bool) -> Result<(), int>{
|
||||
|
@ -87,7 +87,7 @@ fn remove(dirs: Vec<String>, ignore: bool, parents: bool, verbose: bool) -> Resu
|
|||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
r
|
||||
}
|
||||
|
||||
fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool) -> Result<(), int> {
|
||||
|
@ -124,6 +124,6 @@ fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool
|
|||
r = Err(1);
|
||||
}
|
||||
|
||||
return r;
|
||||
r
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
let terminator = escape_sequences(matches.opt_str("t").unwrap_or(separator.to_string()).as_slice());
|
||||
print_seq(first, step, last, separator, terminator, matches.opt_present("w"));
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn done_printing(next: f32, step: f32, last: f32) -> bool {
|
||||
|
|
|
@ -64,7 +64,7 @@ specified by the sum of their values.", opts).as_slice());
|
|||
sleep(matches.free);
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn sleep(args: Vec<String>) {
|
||||
|
|
|
@ -129,5 +129,5 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
println!("{} {}", sum, blocks);
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
tac(files, before, regex, separator.as_slice());
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn tac(filenames: Vec<String>, before: bool, _: bool, separator: &str) {
|
||||
|
|
|
@ -132,7 +132,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn stat(path: &Path, follow: bool) -> std::io::FileStat {
|
||||
|
|
2
tr/tr.rs
2
tr/tr.rs
|
@ -199,5 +199,5 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
tr(set1.as_slice(), set2.as_slice());
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ file based on its current size:
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn truncate(no_create: bool, _: bool, reference: Option<String>, size: Option<String>, filenames: Vec<String>) -> Result<(), int> {
|
||||
|
@ -159,7 +159,7 @@ fn truncate(no_create: bool, _: bool, reference: Option<String>, size: Option<St
|
|||
}
|
||||
}
|
||||
}
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_size(size: &str) -> (u64, TruncateMode) {
|
||||
|
|
|
@ -71,7 +71,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
};
|
||||
|
||||
return exit_code as int;
|
||||
exit_code as int
|
||||
}
|
||||
|
||||
fn usage () {
|
||||
|
|
|
@ -105,5 +105,5 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
println!("{}", output.as_slice().trim_left());
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
|
|
@ -87,5 +87,5 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
print_nusers(user_count);
|
||||
print_loadavg();
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn print_loadavg() {
|
||||
|
|
|
@ -84,7 +84,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
exec(filename);
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn exec(filename: &str) {
|
||||
|
|
8
wc/wc.rs
8
wc/wc.rs
|
@ -81,7 +81,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
Err(e) => return e
|
||||
}
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
static CR: u8 = '\r' as u8;
|
||||
|
@ -192,7 +192,7 @@ pub fn wc(files: Vec<String>, matches: &Matches) -> StdResult<(), int> {
|
|||
print_stats("total", total_line_count, total_word_count, total_char_count, total_byte_count, total_longest_line_length, matches, max_str_len);
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn print_stats(filename: &str, line_count: uint, word_count: uint, char_count: uint,
|
||||
|
@ -241,11 +241,11 @@ fn open(path: String) -> StdResult<BufferedReader<Box<Reader>>, int> {
|
|||
match File::open(&std::path::Path::new(path.as_slice())) {
|
||||
Ok(fd) => {
|
||||
let reader = box fd as Box<Reader>;
|
||||
return Ok(BufferedReader::new(reader));
|
||||
Ok(BufferedReader::new(reader))
|
||||
},
|
||||
Err(e) => {
|
||||
show_error!("wc: {0:s}: {1:s}", path, e.desc.to_str());
|
||||
return Err(1);
|
||||
Err(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
exec();
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
pub fn exec() {
|
||||
|
|
|
@ -59,7 +59,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
exec(string.as_slice());
|
||||
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
pub fn exec(string: &str) {
|
||||
|
|
Loading…
Reference in a new issue