From f9e99c0c26f0248269647e2ced2a46be890d8968 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Tue, 2 Sep 2014 09:38:29 +0200 Subject: [PATCH] Fix non_snake_case warnings --- src/chroot/chroot.rs | 44 +++++++++++++++++++++--------------------- src/cut/buffer.rs | 1 + src/du/du.rs | 2 +- src/relpath/relpath.rs | 8 ++++---- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/chroot/chroot.rs b/src/chroot/chroot.rs index e1030f11c..9a449a183 100644 --- a/src/chroot/chroot.rs +++ b/src/chroot/chroot.rs @@ -68,9 +68,9 @@ pub fn uumain(args: Vec) -> int { return 1 } - let defaultShell: &'static str = "/bin/sh"; - let defaultOption: &'static str = "-i"; - let userShell = std::os::getenv("SHELL"); + let default_shell: &'static str = "/bin/sh"; + let default_option: &'static str = "-i"; + let user_shell = std::os::getenv("SHELL"); let newroot = Path::new(opts.free[0].as_slice()); if !newroot.is_dir() { @@ -79,11 +79,11 @@ pub fn uumain(args: Vec) -> int { let command: Vec<&str> = match opts.free.len() { 1 => { - let shell: &str = match userShell { - None => defaultShell, + let shell: &str = match user_shell { + None => default_shell, Some(ref s) => s.as_slice() }; - vec!(shell, defaultOption) + vec!(shell, default_option) } _ => opts.free.slice(1, opts.free.len()).iter().map(|x| x.as_slice()).collect() }; @@ -92,18 +92,18 @@ pub fn uumain(args: Vec) -> int { unsafe { let executable = command[0].as_slice().to_c_str().unwrap(); - let mut commandParts: Vec<*const i8> = command.iter().map(|x| x.to_c_str().unwrap()).collect(); - commandParts.push(std::ptr::null()); - execvp(executable as *const libc::c_char, commandParts.as_ptr() as *mut *const libc::c_char) as int + let mut command_parts: Vec<*const i8> = command.iter().map(|x| x.to_c_str().unwrap()).collect(); + command_parts.push(std::ptr::null()); + execvp(executable as *const libc::c_char, command_parts.as_ptr() as *mut *const libc::c_char) as int } } fn set_context(root: &Path, options: &getopts::Matches) { - let userspecStr = options.opt_str("userspec"); - let userStr = options.opt_str("user").unwrap_or_default(); - let groupStr = options.opt_str("group").unwrap_or_default(); - let groupsStr = options.opt_str("groups").unwrap_or_default(); - let userspec = match userspecStr { + let userspec_str = options.opt_str("userspec"); + let user_str = options.opt_str("user").unwrap_or_default(); + let group_str = options.opt_str("group").unwrap_or_default(); + let groups_str = options.opt_str("groups").unwrap_or_default(); + let userspec = match userspec_str { Some(ref u) => { let s: Vec<&str> = u.as_slice().split(':').collect(); if s.len() != 2 { @@ -113,26 +113,26 @@ fn set_context(root: &Path, options: &getopts::Matches) { } None => Vec::new() }; - let user = if userspec.is_empty() { userStr.as_slice() } else { userspec[0].as_slice() }; - let group = if userspec.is_empty() { groupStr.as_slice() } else { userspec[1].as_slice() }; + let user = if userspec.is_empty() { user_str.as_slice() } else { userspec[0].as_slice() }; + let group = if userspec.is_empty() { group_str.as_slice() } else { userspec[1].as_slice() }; enter_chroot(root); - set_groups_from_str(groupsStr.as_slice()); + set_groups_from_str(groups_str.as_slice()); set_main_group(group); set_user(user); } fn enter_chroot(root: &Path) { - let rootStr = root.display(); + let root_str = root.display(); if !std::os::change_dir(root) { - crash!(1, "cannot chdir to {}", rootStr) + crash!(1, "cannot chdir to {}", root_str) }; let err = unsafe { chroot(".".to_c_str().unwrap() as *const libc::c_char) }; if err != 0 { - crash!(1, "cannot chroot to {}: {:s}", rootStr, strerror(err).as_slice()) + crash!(1, "cannot chroot to {}: {:s}", root_str, strerror(err).as_slice()) }; } @@ -167,14 +167,14 @@ fn set_groups(groups: Vec) -> libc::c_int { fn set_groups_from_str(groups: &str) { if !groups.is_empty() { - let groupsVec: Vec = FromIterator::from_iter( + let groups_vec: Vec = FromIterator::from_iter( groups.split(',').map( |x| match get_group(x) { None => crash!(1, "no such group: {}", x), Some(g) => g.gr_gid }) ); - let err = set_groups(groupsVec); + let err = set_groups(groups_vec); if err != 0 { crash!(1, "cannot set groups: {:s}", strerror(err).as_slice()) } diff --git a/src/cut/buffer.rs b/src/cut/buffer.rs index b8874f96e..fc441dd29 100644 --- a/src/cut/buffer.rs +++ b/src/cut/buffer.rs @@ -8,6 +8,7 @@ pub struct BufReader { end: uint, // exclusive } +#[allow(non_snake_case)] pub mod Bytes { pub trait Select { fn select<'a>(&'a mut self, bytes: uint) -> Selected<'a>; diff --git a/src/du/du.rs b/src/du/du.rs index fed078a8c..e65db0913 100644 --- a/src/du/du.rs +++ b/src/du/du.rs @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -#![allow(uppercase_variables)] +#![allow(non_snake_case)] #![feature(macro_rules)] extern crate getopts; diff --git a/src/relpath/relpath.rs b/src/relpath/relpath.rs index f6710eb17..26c0f2ede 100644 --- a/src/relpath/relpath.rs +++ b/src/relpath/relpath.rs @@ -64,19 +64,19 @@ pub fn uumain(args: Vec) -> int { } } - let mut suffixPos = 0; + let mut suffix_pos = 0; absfrom.components() .zip(absto.components()) .take_while( |&(f, t)| if f == t { - suffixPos += 1; true + suffix_pos += 1; true } else { false }).last(); let mut result = Path::new(""); - absfrom.components().skip(suffixPos).map(|_| result.push("..")).last(); - absto.components().skip(suffixPos).map(|x| result.push(x)).last(); + absfrom.components().skip(suffix_pos).map(|_| result.push("..")).last(); + absto.components().skip(suffix_pos).map(|x| result.push(x)).last(); println!("{}", result.display()); 0