Reduce warnings

This commit is contained in:
Jeremy Soller
2018-11-10 07:52:45 -07:00
parent 131dcac554
commit ebffc977b2
20 changed files with 28 additions and 54 deletions
-1
View File
@@ -3,7 +3,6 @@
use c_str::CStr;
use core::fmt::Write;
use header::{stdio, stdlib};
use platform;
use platform::types::*;
#[no_mangle]
+1 -1
View File
@@ -12,7 +12,7 @@ pub fn get_dns_server() -> String {
Ok(file) => file,
Err(_) => return String::new(), // TODO: better error handling
};
let mut file = BufReader::new(file);
let file = BufReader::new(file);
for line in file.split(b'\n') {
let mut line = match line {
+7 -16
View File
@@ -227,15 +227,11 @@ fn lookup_host(host: &str) -> Result<LookupHost, c_int> {
Box::from_raw(packet_data_ptr);
}
let mut i = 0 as socklen_t;
let i = 0 as socklen_t;
let mut buf = [0u8; 65536];
let buf_ptr = buf.as_mut_ptr() as *mut c_void;
let mut count = -1;
unsafe {
count = sys_socket::recv(sock, buf_ptr, 65536, 0);
}
let count = unsafe { sys_socket::recv(sock, buf_ptr, 65536, 0) };
if count < 0 {
return Err(EIO);
}
@@ -347,15 +343,11 @@ fn lookup_addr(addr: in_addr) -> Result<Vec<Vec<u8>>, c_int> {
Box::from_raw(packet_data_ptr);
}
let mut i = mem::size_of::<sockaddr_in>() as socklen_t;
let i = mem::size_of::<sockaddr_in>() as socklen_t;
let mut buf = [0u8; 65536];
let buf_ptr = buf.as_mut_ptr() as *mut c_void;
let mut count = -1;
unsafe {
count = sys_socket::recv(sock, buf_ptr, 65536, 0);
}
let count = unsafe { sys_socket::recv(sock, buf_ptr, 65536, 0) };
if count < 0 {
return Err(EIO);
}
@@ -385,11 +377,10 @@ fn lookup_addr(addr: in_addr) -> Result<Vec<Vec<u8>>, c_int> {
fn parse_revdns_answer(data: Vec<u8>) -> Vec<u8> {
let mut cursor = 0;
let mut offset = 0;
let mut index = 0;
let mut output = data.clone();
while index < data.len() - 1 {
offset = data[index] as usize;
let offset = data[index] as usize;
index = cursor + offset + 1;
output[index] = '.' as u8;
cursor = index;
@@ -855,10 +846,10 @@ pub unsafe extern "C" fn getservent() -> *const servent {
let mut rlb = RawLineBuffer::new(SERVDB);
rlb.seek(S_POS);
let mut r: Box<str> = Box::default();
let r: Box<str> = Box::default();
loop {
let mut r = match rlb.next() {
let r = match rlb.next() {
Line::Some(s) => bytes_to_box_str(s),
_ => {
if SERV_STAYOPEN == 0 {
+1 -2
View File
@@ -1,7 +1,6 @@
//! regex.h implementation, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/regex.h.html
use alloc::borrow::Cow;
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::{mem, slice, ptr};
use header::string::strlen;
@@ -116,7 +115,7 @@ pub extern "C" fn regexec(regex: *const regex_t, input: *const c_char,
// Allow specifying a compiler argument to the executor and vise versa
// because why not?
let mut flags = regex.cflags | eflags;
let flags = regex.cflags | eflags;
let input = unsafe { slice::from_raw_parts(input as *const u8, strlen(input)) };
+1 -2
View File
@@ -1,7 +1,6 @@
use super::{constants, Buffer, BUFSIZ, FILE, UNGET};
use super::{constants, Buffer, BUFSIZ, FILE};
use core::cell::UnsafeCell;
use core::ptr;
use core::sync::atomic::AtomicBool;
use fs::File;
use io::LineWriter;
-2
View File
@@ -1,6 +1,4 @@
use alloc::boxed::Box;
use core::sync::atomic::AtomicBool;
use core::{mem, ptr};
use fs::File;
use header::errno;
+3 -4
View File
@@ -3,10 +3,9 @@
use alloc::borrow::{Borrow, BorrowMut};
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::fmt;
use core::fmt::Write as WriteFmt;
use core::fmt::{self, Error};
use core::ops::{Deref, DerefMut};
use core::sync::atomic::{self, AtomicBool, Ordering};
use core::{ptr, str, slice};
use va_list::VaList as va_list;
@@ -16,7 +15,7 @@ use header::errno::{self, STR_ERROR};
use header::fcntl;
use header::stdlib::mkstemp;
use header::string::strlen;
use io::{self, BufRead, LineWriter, SeekFrom, Read, Write};
use io::{self, BufRead, LineWriter, Read, Write};
use mutex::Mutex;
use platform::types::*;
use platform::{Pal, Sys};
@@ -513,7 +512,7 @@ pub extern "C" fn ftell(stream: *mut FILE) -> c_long {
/// Get the current position of the cursor in the file
#[no_mangle]
pub extern "C" fn ftello(stream: *mut FILE) -> off_t {
let mut stream = unsafe { &mut *stream }.lock();
let stream = unsafe { &mut *stream }.lock();
let pos = Sys::lseek(*stream.file, 0, SEEK_CUR);
if pos < 0 {
return -1;
+5 -7
View File
@@ -1,14 +1,12 @@
use alloc::string::String;
use alloc::string::ToString;
use alloc::vec::Vec;
use core::fmt::Write as CoreWrite;
use core::ops::Range;
use core::{fmt, ptr, slice, str};
use core::{fmt, slice};
use c_str::CStr;
use io::{self, Write};
use platform;
use platform::types::*;
use platform::{self, WriteByte};
use va_list::{VaList, VaPrimitive};
#[derive(PartialEq, Eq)]
@@ -221,7 +219,7 @@ fn fmt_float_exp<W: Write>(
}
let string = float_string(float, precision, trim);
let mut len = string.len() + 2 + 2.max(exp_len);
let len = string.len() + 2 + 2.max(exp_len);
pad(w, !left, b' ', len..pad_space)?;
let bytes = if string.starts_with('-') {
@@ -261,8 +259,8 @@ fn fmt_float_normal<W: Write>(
Ok(string.len())
}
unsafe fn inner_printf<W: Write>(w: W, format: *const c_char, mut ap: VaList) -> io::Result<c_int> {
let mut w = &mut platform::CountingWriter::new(w);
unsafe fn inner_printf<W: Write>(w: W, format: *const c_char, ap: VaList) -> io::Result<c_int> {
let w = &mut platform::CountingWriter::new(w);
let mut ap = BufferedVaList::new(ap);
let mut format = format as *const u8;
+1 -1
View File
@@ -366,7 +366,7 @@ pub unsafe extern "C" fn strspn(s1: *const c_char, s2: *const c_char) -> size_t
inner_strspn(s1, s2, true)
}
unsafe fn inner_strstr(mut haystack: *const c_char, mut needle: *const c_char, mask: c_char) -> *mut c_char {
unsafe fn inner_strstr(mut haystack: *const c_char, needle: *const c_char, mask: c_char) -> *mut c_char {
while *haystack != 0 {
let mut i = 0;
loop {
+1 -2
View File
@@ -1,6 +1,5 @@
//! strings implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/strings.h.html
use alloc::vec::Vec;
use core::ptr;
use platform::types::*;
@@ -66,7 +65,7 @@ pub unsafe extern "C" fn rindex(mut s: *const c_char, c: c_int) -> *mut c_char {
}
#[no_mangle]
pub unsafe extern "C" fn strcasecmp(mut first: *const c_char, mut second: *const c_char) -> c_int {
pub unsafe extern "C" fn strcasecmp(first: *const c_char, second: *const c_char) -> c_int {
strncasecmp(first, second, size_t::max_value())
}
+1 -1
View File
@@ -24,7 +24,7 @@ pub struct winsize {
#[cfg(target_os = "linux")]
pub mod inner {
use platform::types::*;
use platform::{Pal, Sys};
use platform::Sys;
#[no_mangle]
pub extern "C" fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) -> c_int {
-1
View File
@@ -3,7 +3,6 @@
use c_str::CStr;
use header::fcntl::{O_NOFOLLOW, O_PATH};
use header::time::timespec;
use platform;
use platform::types::*;
use platform::{Pal, Sys};
+1 -1
View File
@@ -17,7 +17,7 @@ pub struct utsname {
#[cfg(target_os = "linux")]
mod inner {
use super::*;
use platform::{Pal, Sys};
use platform::Sys;
#[no_mangle]
pub unsafe extern "C" fn uname(uts: *mut utsname) -> c_int {
+1 -1
View File
@@ -2,7 +2,7 @@
use core::ptr;
use header::{getopt, stdio, string};
use header::getopt;
use platform::types::*;
#[allow(non_upper_case_globals)]
+1 -1
View File
@@ -3,7 +3,7 @@
use core::{ptr, slice};
use c_str::CStr;
use header::{limits, sys_time};
use header::limits;
use header::time::timespec;
use platform;
use platform::types::*;
-1
View File
@@ -7,7 +7,6 @@
#![feature(const_fn)]
#![feature(const_vec_new)]
#![feature(core_intrinsics)]
#![feature(extern_prelude)]
#![feature(global_asm)]
#![feature(lang_items)]
#![feature(linkage)]
+2 -4
View File
@@ -1,14 +1,12 @@
use alloc::vec::Vec;
use core::fmt::Write as _WriteFmt;
use core::{mem, ptr};
use core_io::Write;
use super::types::*;
use super::{errno, FileWriter, Pal};
use super::{errno, Pal};
use c_str::CStr;
use fs::File;
use header::dirent::dirent;
use header::errno::{EINVAL, ENOSYS};
use header::errno::EINVAL;
use header::fcntl;
use header::signal::SIGCHLD;
use header::sys_ioctl::{winsize, TCGETS, TCSETS, TIOCGWINSZ};
+1 -4
View File
@@ -1,12 +1,9 @@
use super::types::*;
use c_str::CStr;
use header::dirent::dirent;
//use header::sys_resource::rusage;
use header::sys_select::fd_set;
use header::sys_stat::stat;
use header::sys_time::{itimerval, timeval, timezone};
//use header::sys_times::tms;
use header::sys_utsname::utsname;
use header::sys_time::{timeval, timezone};
use header::termios::termios;
use header::time::timespec;
+1 -1
View File
@@ -1,6 +1,6 @@
use super::super::types::*;
use super::super::Pal;
use header::signal::{sigaction, sigset_t};
use header::signal::sigaction;
pub trait PalSignal: Pal {
fn kill(pid: pid_t, sig: c_int) -> c_int;
-1
View File
@@ -4,7 +4,6 @@ use core::ptr;
use header::{stdio, stdlib};
use platform;
use platform::types::*;
use platform::{Pal, Sys};
#[repr(C)]
pub struct Stack {