clippy: fix several clippy warnings

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-06-01 11:36:19 +08:00
parent d4db20e516
commit 40d4483e4f
8 changed files with 34 additions and 34 deletions

View file

@ -34,7 +34,6 @@ impl Uart {
let base = DEFAULT_UART_ADDR;
// Wait until TXFULL is `0`
while base.add(1).read_volatile() != 0 {
()
}
base.add(0).write_volatile(c as usize)
};

View file

@ -1,6 +1,5 @@
use core::fmt;
use core::slice;
use xous;
pub struct LogString<'a> {
raw_slice: &'a mut [u8],

View file

@ -24,13 +24,13 @@ fn handle_irq(irq_no: usize, arg: *mut usize) {
while let Some(c) = debug::DEFAULT.getc() {
print!("0x{:02x}", c);
}
println!("");
println!();
}
#[no_mangle]
fn main() {
let uart = xous::syscall::map_memory(
xous::MemoryAddress::new(0xf0004000),
xous::MemoryAddress::new(0xf000_4000),
None,
4096,
xous::MemoryFlags::R | xous::MemoryFlags::W,

View file

@ -33,9 +33,7 @@ impl Uart {
unsafe {
let base = DEFAULT_UART_ADDR;
// Wait until TXFULL is `0`
while base.add(1).read_volatile() != 0 {
()
}
while base.add(1).read_volatile() != 0 {}
base.add(0).write_volatile(c as usize)
};
}

View file

@ -1,6 +1,5 @@
use core::fmt::{Error, Write};
use core::slice;
use xous;
pub struct LogStr<'a> {
raw_slice: &'a mut [u8],
@ -33,7 +32,7 @@ impl<'a> LogStr<'a> {
pub fn into_memory_message(self, id: xous::MessageId) -> Result<xous::MemoryMessage, xous::Error> {
// XXX This should forget the memory allocated, as it will be sent to the other process
Ok(xous::MemoryMessage {
id: id,
id,
buf: xous::MemoryRange::new(self.raw_slice.as_ptr() as usize, self.raw_slice.len()),
offset: None,
valid: xous::MemorySize::new(self.len),
@ -42,7 +41,7 @@ impl<'a> LogStr<'a> {
pub fn as_memory_message(&self, id: xous::MessageId) -> Result<xous::MemoryMessage, xous::Error> {
Ok(xous::MemoryMessage {
id: id,
id,
buf: xous::MemoryRange::new(self.raw_slice.as_ptr() as usize, self.raw_slice.len()),
offset: None,
valid: xous::MemorySize::new(self.len),

View file

@ -26,7 +26,7 @@ fn handle_irq(irq_no: usize, arg: *mut usize) {
while let Some(c) = debug::DEFAULT.getc() {
print!("0x{:02x}", c);
}
println!("");
println!();
}
// fn print_and_yield(index: *mut usize) -> ! {
@ -40,7 +40,7 @@ fn handle_irq(irq_no: usize, arg: *mut usize) {
#[no_mangle]
fn main() {
let uart = xous::syscall::map_memory(
xous::MemoryAddress::new(0xf0001000),
xous::MemoryAddress::new(0xf000_1000),
None,
4096,
xous::MemoryFlags::R | xous::MemoryFlags::W,
@ -50,7 +50,7 @@ fn main() {
println!("Mapped UART @ {:08x}", uart.addr.get() );
xous::syscall::map_memory(
xous::MemoryAddress::new(0xf0002000),
xous::MemoryAddress::new(0xf000_2000),
None,
4096,
xous::MemoryFlags::R | xous::MemoryFlags::W,
@ -114,7 +114,7 @@ fn main() {
let mut connection = None;
println!("Attempting to connect to server...");
while connection.is_none() {
if let Ok(cid) = xous::syscall::connect((3, 2626920432, 3, 2626920432)) {
if let Ok(cid) = xous::syscall::connect((3, 2_626_920_432, 3, 2_626_920_432)) {
connection = Some(cid);
} else {
xous::syscall::yield_slice();

View file

@ -33,21 +33,21 @@ bitflags! {
/// writable and not readable.
pub struct MemoryFlags: usize {
/// Free this memory
const FREE = 0b00000000;
const FREE = 0b0000_0000;
/// Immediately allocate this memory. Otherwise it will
/// be demand-paged. This is implicitly set when `phys`
/// is not 0.
const RESERVE = 0b00000001;
const RESERVE = 0b0000_0001;
/// Allow the CPU to read from this page.
const R = 0b00000010;
const R = 0b0000_0010;
/// Allow the CPU to write to this page.
const W = 0b00000100;
const W = 0b0000_0100;
/// Allow the CPU to execute from this page.
const X = 0b00001000;
const X = 0b0000_1000;
}
}
@ -165,6 +165,10 @@ impl MemoryRange {
self.size.get()
}
pub fn is_empty(&self) -> bool {
self.size.get() > 0
}
pub fn as_ptr(&self) -> *const usize {
self.addr.get() as *const usize
}

View file

@ -507,6 +507,8 @@ impl SysCall {
],
}
}
#[allow(clippy::too_many_arguments)]
pub fn from_args(
a0: usize,
a1: usize,
@ -784,8 +786,7 @@ pub fn wait_event() {
}
pub fn rsyscall(call: SysCall) -> SyscallResult {
use core::mem::MaybeUninit;
let mut ret = unsafe { MaybeUninit::uninit().assume_init() };
let mut ret = Result::Ok;
let args = call.as_args();
unsafe {
_xous_syscall(
@ -798,16 +799,16 @@ pub fn rsyscall(call: SysCall) -> SyscallResult {
}
}
/// This is dangerous, but fast.
pub unsafe fn dangerous_syscall(call: SysCall) -> SyscallResult {
use core::mem::{transmute, MaybeUninit};
let mut ret = MaybeUninit::uninit().assume_init();
let presto = transmute::<_, (usize, usize, usize, usize, usize, usize, usize, usize)>(call);
_xous_syscall_rust(
presto.0, presto.1, presto.2, presto.3, presto.4, presto.5, presto.6, presto.7, &mut ret,
);
match ret {
Result::Error(e) => Err(e),
other => Ok(other),
}
}
// /// This is dangerous, but fast.
// pub unsafe fn dangerous_syscall(call: SysCall) -> SyscallResult {
// use core::mem::{transmute, MaybeUninit};
// let mut ret = MaybeUninit::uninit().assume_init();
// let presto = transmute::<_, (usize, usize, usize, usize, usize, usize, usize, usize)>(call);
// _xous_syscall_rust(
// presto.0, presto.1, presto.2, presto.3, presto.4, presto.5, presto.6, presto.7, &mut ret,
// );
// match ret {
// Result::Error(e) => Err(e),
// other => Ok(other),
// }
// }