Remove tail return statements.

Per review feedback.
This commit is contained in:
Brian Anderson 2014-06-11 21:41:53 -07:00
parent 1adc027382
commit bad19f6016
40 changed files with 61 additions and 60 deletions

View file

@ -89,7 +89,7 @@ pub fn uumain(args: Vec<String>) -> int {
Version => version()
}
return 0;
0
}
#[allow(dead_code)]

View file

@ -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()
}

View file

@ -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> {

View file

@ -130,5 +130,5 @@ pub fn uumain(args: Vec<String>) -> int {
}
}
return exit_code;
exit_code
}

View file

@ -136,5 +136,5 @@ pub fn uumain(args: Vec<String>) -> int {
comm(&mut f1, &mut f2, &matches);
return 0;
0
}

View file

@ -63,7 +63,7 @@ pub fn uumain(args: Vec<String>) -> int {
Version => version(),
}
return 0;
0
}
fn version() {

View file

@ -68,5 +68,5 @@ directory).", opts).as_slice());
println!("Try '{0:s} --help' for more information.", program);
}
return 0;
0
}

View file

@ -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
}

View file

@ -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
View file

@ -211,5 +211,5 @@ pub fn uumain(args: Vec<String>) -> int {
print_env(opts.null);
}
return 0;
0
}

View file

@ -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>) {

View file

@ -43,5 +43,5 @@ pub fn uumain(args: Vec<String>) -> int {
group(get_pw_from_args(&matches.free), true);
return 0;
0
}

View file

@ -94,7 +94,7 @@ pub fn uumain(args: Vec<String>) -> int {
}
}
return 0;
0
}
// It searches for an option in the form of -123123

View file

@ -84,7 +84,7 @@ pub fn uumain(args: Vec<String>) -> int {
Version => version(),
}
return 0;
0
}
fn version() {

View file

@ -65,7 +65,7 @@ pub fn uumain(args: Vec<String>) -> int {
_ => { help_menu(program.as_slice(), options); }
};
return 0;
0
}
fn version() {

View file

@ -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>) {

View file

@ -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>) {

View file

@ -78,7 +78,7 @@ pub fn uumain(args: Vec<String>) -> int {
exec();
return 0;
0
}
fn exec() {

View file

@ -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 {

View file

@ -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
}
/**

View file

@ -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) {

View file

@ -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) {

View file

@ -58,5 +58,5 @@ pub fn uumain(args: Vec<String>) -> int {
return 0;
}
return 0;
0
}

View file

@ -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 {

View file

@ -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
}

View file

@ -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 {

View file

@ -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>) {

View file

@ -129,5 +129,5 @@ pub fn uumain(args: Vec<String>) -> int {
println!("{} {}", sum, blocks);
return 0;
0
}

View file

@ -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) {

View file

@ -132,7 +132,7 @@ pub fn uumain(args: Vec<String>) -> int {
}
}
return 0;
0
}
fn stat(path: &Path, follow: bool) -> std::io::FileStat {

View file

@ -199,5 +199,5 @@ pub fn uumain(args: Vec<String>) -> int {
tr(set1.as_slice(), set2.as_slice());
}
return 0;
0
}

View file

@ -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) {

View file

@ -71,7 +71,7 @@ pub fn uumain(args: Vec<String>) -> int {
}
};
return exit_code as int;
exit_code as int
}
fn usage () {

View file

@ -105,5 +105,5 @@ pub fn uumain(args: Vec<String>) -> int {
}
println!("{}", output.as_slice().trim_left());
return 0;
0
}

View file

@ -87,5 +87,5 @@ pub fn uumain(args: Vec<String>) -> int {
}
}
return 0;
0
}

View file

@ -81,7 +81,7 @@ pub fn uumain(args: Vec<String>) -> int {
print_nusers(user_count);
print_loadavg();
return 0;
0
}
fn print_loadavg() {

View file

@ -84,7 +84,7 @@ pub fn uumain(args: Vec<String>) -> int {
exec(filename);
return 0;
0
}
fn exec(filename: &str) {

View file

@ -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)
}
}
}

View file

@ -70,7 +70,7 @@ pub fn uumain(args: Vec<String>) -> int {
exec();
return 0;
0
}
pub fn exec() {

View file

@ -59,7 +59,7 @@ pub fn uumain(args: Vec<String>) -> int {
exec(string.as_slice());
return 0;
0
}
pub fn exec(string: &str) {