mirror of
https://github.com/AmbiML/sparrow-kata-full.git
synced 2025-09-25 22:59:20 +00:00
DebugConsole: clippy findings
Change-Id: I8e93e5441e5762171b4e32baa253ceba6d96855b GitOrigin-RevId: 90106f4f236c27f88a59ea6286612bb6db378cfc
This commit is contained in:
@@ -12,13 +12,10 @@
|
||||
#![no_std]
|
||||
|
||||
use core::slice;
|
||||
use kata_io;
|
||||
use kata_os_common::allocator;
|
||||
use kata_os_common::logger::KataLogger;
|
||||
use kata_os_common::sel4_sys;
|
||||
use kata_os_common::slot_allocator;
|
||||
use kata_shell;
|
||||
use kata_uart_client;
|
||||
use log::trace;
|
||||
|
||||
use sel4_sys::seL4_CPtr;
|
||||
|
@@ -127,7 +127,7 @@ impl<R: Read> BufReader<R> {
|
||||
pub fn new(inner: R) -> BufReader<R> {
|
||||
const BUFFER_SIZE : usize = 1024; // free to be changed
|
||||
BufReader {
|
||||
inner: inner,
|
||||
inner,
|
||||
buf: Box::new([0u8; BUFFER_SIZE]),
|
||||
pos: 0,
|
||||
cap: 0,
|
||||
|
@@ -38,6 +38,11 @@ pub struct LineReader {
|
||||
// Owned by LineReader to facilitate static allocation.
|
||||
buf: [u8; LINE_MAX],
|
||||
}
|
||||
impl Default for LineReader {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
fn get_u8(reader: &mut dyn io::Read) -> io::Result<u8> {
|
||||
let mut buf: [u8; 1] = [0u8];
|
||||
|
@@ -6,8 +6,6 @@ use alloc::vec::Vec;
|
||||
use core::fmt;
|
||||
use core::fmt::Write;
|
||||
use cpio::CpioNewcReader;
|
||||
use hex;
|
||||
use log;
|
||||
|
||||
use kata_io as io;
|
||||
use kata_line_reader::LineReader;
|
||||
@@ -124,7 +122,7 @@ fn dispatch_command(
|
||||
builtin_cpio: &[u8],
|
||||
) {
|
||||
let mut args = cmdline.split_ascii_whitespace();
|
||||
match args.nth(0) {
|
||||
match args.next() {
|
||||
Some(command) => {
|
||||
// Statically binds command names to implementations fns, which are
|
||||
// defined below.
|
||||
@@ -221,7 +219,7 @@ fn loglevel_command(
|
||||
args: &mut dyn Iterator<Item = &str>,
|
||||
output: &mut dyn io::Write,
|
||||
) -> Result<(), CommandError> {
|
||||
if let Some(level) = args.nth(0) {
|
||||
if let Some(level) = args.next() {
|
||||
use log::LevelFilter;
|
||||
match level {
|
||||
"off" => log::set_max_level(LevelFilter::Off),
|
||||
@@ -652,7 +650,7 @@ fn test_mlcontinuous_command(args: &mut dyn Iterator<Item = &str>) -> Result<(),
|
||||
extern "C" {
|
||||
fn mlcoord_set_continuous_mode(mode: bool);
|
||||
}
|
||||
if let Some(mode_str) = args.nth(0) {
|
||||
if let Some(mode_str) = args.next() {
|
||||
let mode = mode_str.parse::<bool>()?;
|
||||
unsafe {
|
||||
mlcoord_set_continuous_mode(mode);
|
||||
@@ -779,7 +777,7 @@ fn test_timer_async_command(
|
||||
|
||||
timer_service_oneshot(id, time_ms);
|
||||
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Implements a command that starts a timer, blocking until the timer has
|
||||
|
@@ -10,7 +10,6 @@ use core::ptr;
|
||||
use kata_memory_interface::kata_frame_alloc;
|
||||
use kata_memory_interface::ObjDescBundle;
|
||||
use kata_os_common::sel4_sys;
|
||||
use log;
|
||||
|
||||
use sel4_sys::seL4_CapRights;
|
||||
use sel4_sys::seL4_CPtr;
|
||||
@@ -21,8 +20,6 @@ use sel4_sys::seL4_RISCV_Page_Map as seL4_Page_Map;
|
||||
use sel4_sys::seL4_RISCV_Page_Unmap as seL4_Page_Unmap;
|
||||
use sel4_sys::seL4_RISCV_VMAttributes::Default_VMAttributes as seL4_Default_VMAttributes;
|
||||
|
||||
use zmodem;
|
||||
|
||||
use kata_io as io;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -132,7 +129,7 @@ impl Drop for Upload {
|
||||
impl io::Write for Upload {
|
||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||
let mut cursor = buf;
|
||||
while cursor.len() > 0 {
|
||||
while !cursor.is_empty() {
|
||||
let available_bytes = self.mapped_bytes - self.next_free;
|
||||
if available_bytes > 0 {
|
||||
// Fill the current frame (as space permits).
|
||||
@@ -156,7 +153,7 @@ impl io::Write for Upload {
|
||||
self.unmap_current_frame()?;
|
||||
}
|
||||
}
|
||||
if cursor.len() == 0 { break }
|
||||
if cursor.is_empty() { break }
|
||||
|
||||
// Allocate another frame and map it for write.
|
||||
self.expand_and_map()?;
|
||||
|
@@ -6,7 +6,8 @@ use kata_io as io;
|
||||
|
||||
// Console logging interface.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn logger_log(level: u8, msg: *const cstr_core::c_char) {
|
||||
#[allow(clippy::missing_safety_doc)]
|
||||
pub unsafe extern "C" fn logger_log(level: u8, msg: *const cstr_core::c_char) {
|
||||
use log::Level;
|
||||
let l = match level {
|
||||
x if x == Level::Error as u8 => Level::Error,
|
||||
@@ -18,10 +19,8 @@ pub extern "C" fn logger_log(level: u8, msg: *const cstr_core::c_char) {
|
||||
if l <= log::max_level() {
|
||||
// TODO(sleffler): is the uart driver ok w/ multiple writers?
|
||||
let output: &mut dyn io::Write = &mut self::Tx::new();
|
||||
unsafe {
|
||||
let _ = writeln!(output, "{}", CStr::from_ptr(msg).to_str().unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const DATAPORT_SIZE: usize = 4096;
|
||||
@@ -29,6 +28,11 @@ const DATAPORT_SIZE: usize = 4096;
|
||||
pub struct Rx {
|
||||
dataport: &'static [u8],
|
||||
}
|
||||
impl Default for Rx {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Rx {
|
||||
pub fn new() -> Rx {
|
||||
@@ -60,6 +64,11 @@ impl io::Read for Rx {
|
||||
pub struct Tx {
|
||||
dataport: &'static mut [u8],
|
||||
}
|
||||
impl Default for Tx {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Tx {
|
||||
pub fn new() -> Tx {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
use alloc::string::String;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt;
|
||||
|
||||
@@ -46,9 +47,8 @@ impl Frame {
|
||||
}
|
||||
|
||||
pub fn build(&self) -> Vec<u8> {
|
||||
let mut out = Vec::new();
|
||||
let mut out = vec![ZPAD];
|
||||
|
||||
out.push(ZPAD);
|
||||
if self.header == ZHEX {
|
||||
out.push(ZPAD);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ impl Frame {
|
||||
|
||||
if self.header == ZHEX {
|
||||
let hex = out.drain(4..).collect::<Vec<u8>>().encode_hex::<String>();
|
||||
out.extend_from_slice(&hex.as_bytes());
|
||||
out.extend_from_slice(hex.as_bytes());
|
||||
}
|
||||
|
||||
let tmp = out.drain(3..).collect::<Vec<_>>();
|
||||
|
@@ -1,5 +1,6 @@
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
use alloc::string::ToString;
|
||||
|
||||
use kata_io as io;
|
||||
use log::Level::Debug;
|
||||
@@ -35,7 +36,7 @@ where
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
pub fn parse_header<'a, R>(mut r: R) -> io::Result<Option<Frame>>
|
||||
pub fn parse_header<R>(mut r: R) -> io::Result<Option<Frame>>
|
||||
where
|
||||
R: io::Read,
|
||||
{
|
||||
@@ -209,10 +210,7 @@ fn unescape(escaped_byte: u8) -> u8 {
|
||||
}
|
||||
|
||||
fn is_escaped(byte: u8) -> bool {
|
||||
match byte {
|
||||
ZCRCE | ZCRCG | ZCRCQ | ZCRCW => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(byte, ZCRCE | ZCRCG | ZCRCQ | ZCRCW)
|
||||
}
|
||||
|
||||
/// Reads out one byte
|
||||
@@ -254,7 +252,7 @@ where
|
||||
if let Some(size) = filesize {
|
||||
zfile_data += &format!(" {}", size);
|
||||
}
|
||||
zfile_data += &format!("\0");
|
||||
zfile_data += &"\0".to_string();
|
||||
|
||||
debug!("ZFILE supplied data: {}", zfile_data);
|
||||
write_zlde_data(w, ZCRCW, zfile_data.as_bytes())
|
||||
|
Reference in New Issue
Block a user