clean up warnings before merge to main

This commit is contained in:
bunnie 2021-07-28 23:58:15 +08:00
parent f5a9cce4ac
commit 8cdf3c148b
10 changed files with 43 additions and 44 deletions

View file

@ -430,7 +430,7 @@ impl<'a> Menu<'a> {
rawkeys_op,
drop_op
};
let mut buf = Buffer::into_buf(helper_data).expect("couldn't allocate helper data for helper thread");
let buf = Buffer::into_buf(helper_data).expect("couldn't allocate helper data for helper thread");
let (addr, size, offset) = unsafe{buf.to_raw_parts()};
self.helper_data = Some(buf);
xous::create_thread_3(forwarding_thread, addr, size, offset).expect("couldn't spawn a helper thread");

View file

@ -51,14 +51,9 @@ use enum_dispatch::enum_dispatch;
use crate::api::*;
use crate::Gam;
use graphics_server::api::{TextOp, TextView};
use graphics_server::api::{Point, Gid, Line, Rectangle, Circle, RoundedRectangle, TokenClaim};
use graphics_server::api::*;
pub use graphics_server::GlyphStyle;
// menu imports
use graphics_server::api::{PixelColor, TextBounds, DrawStyle};
use xous::{send_message, CID, Message};
use xous_ipc::{String, Buffer};
use num_traits::*;
@ -463,7 +458,7 @@ impl ActionApi for RadioButtons {
tv.bounds_hint = TextBounds::BoundingBox(Rectangle::new(
Point::new(cursor_x, cur_y - emoji_slop), Point::new(cursor_x + 36, cur_y - emoji_slop + 36)
));
write!(tv, "»");
write!(tv, "»").unwrap();
modal.gam.post_textview(&mut tv).expect("couldn't post tv");
do_okay = false;
}
@ -474,7 +469,7 @@ impl ActionApi for RadioButtons {
tv.bounds_hint = TextBounds::BoundingBox(Rectangle::new(
Point::new(select_x, cur_y), Point::new(select_x + 36, cur_y + modal.line_height)
));
write!(tv, "•");
write!(tv, "•").unwrap();
modal.gam.post_textview(&mut tv).expect("couldn't post tv");
}
// draw the text
@ -483,7 +478,7 @@ impl ActionApi for RadioButtons {
tv.bounds_hint = TextBounds::BoundingBox(Rectangle::new(
Point::new(text_x, cur_y), Point::new(modal.canvas_width - modal.margin, cur_y + modal.line_height)
));
write!(tv, "{}", item.as_str());
write!(tv, "{}", item.as_str()).unwrap();
modal.gam.post_textview(&mut tv).expect("couldn't post tv");
cur_line += 1;
@ -497,9 +492,8 @@ impl ActionApi for RadioButtons {
tv.bounds_hint = TextBounds::BoundingBox(Rectangle::new(
Point::new(cursor_x, cur_y - emoji_slop), Point::new(cursor_x + 36, cur_y - emoji_slop + 36)
));
write!(tv, "»"); // right arrow emoji. use unicode numbers, because text editors do funny shit with emojis
write!(tv, "»").unwrap(); // right arrow emoji. use unicode numbers, because text editors do funny shit with emojis
modal.gam.post_textview(&mut tv).expect("couldn't post tv");
do_okay = false;
}
// draw the "OK" line
tv.text.clear();
@ -634,7 +628,7 @@ impl ActionApi for CheckBoxes {
tv.bounds_hint = TextBounds::BoundingBox(Rectangle::new(
Point::new(cursor_x, cur_y - emoji_slop), Point::new(cursor_x + 36, cur_y - emoji_slop + 36)
));
write!(tv, "»");
write!(tv, "»").unwrap();
modal.gam.post_textview(&mut tv).expect("couldn't post tv");
do_okay = false;
}
@ -645,7 +639,7 @@ impl ActionApi for CheckBoxes {
tv.bounds_hint = TextBounds::BoundingBox(Rectangle::new(
Point::new(select_x, cur_y - emoji_slop), Point::new(select_x + 36, cur_y + modal.line_height)
));
write!(tv, "\u{d7}"); // multiplication sign
write!(tv, "\u{d7}").unwrap(); // multiplication sign
modal.gam.post_textview(&mut tv).expect("couldn't post tv");
}
// draw the text
@ -654,7 +648,7 @@ impl ActionApi for CheckBoxes {
tv.bounds_hint = TextBounds::BoundingBox(Rectangle::new(
Point::new(text_x, cur_y), Point::new(modal.canvas_width - modal.margin, cur_y + modal.line_height)
));
write!(tv, "{}", item.as_str());
write!(tv, "{}", item.as_str()).unwrap();
modal.gam.post_textview(&mut tv).expect("couldn't post tv");
cur_line += 1;
@ -668,9 +662,8 @@ impl ActionApi for CheckBoxes {
tv.bounds_hint = TextBounds::BoundingBox(Rectangle::new(
Point::new(cursor_x, cur_y - emoji_slop), Point::new(cursor_x + 36, cur_y - emoji_slop + 36)
));
write!(tv, "»"); // right arrow emoji. use unicode numbers, because text editors do funny shit with emojis
write!(tv, "»").unwrap(); // right arrow emoji. use unicode numbers, because text editors do funny shit with emojis
modal.gam.post_textview(&mut tv).expect("couldn't post tv");
do_okay = false;
}
// draw the "OK" line
tv.text.clear();
@ -765,11 +758,11 @@ impl ActionApi for Slider {
#[enum_dispatch]
trait ActionApi {
fn height(&self, glyph_height: i16, margin: i16) -> i16 {glyph_height + margin * 2}
fn redraw(&self, at_height: i16, modal: &Modal) { unimplemented!() }
fn redraw(&self, _at_height: i16, _modal: &Modal) { unimplemented!() }
fn close(&mut self) {}
fn is_password(&self) -> bool { false }
/// navigation is one of '∴' | '←' | '→' | '↑' | '↓'
fn key_action(&mut self, key: char) -> (Option<xous_ipc::String::<512>>, bool) {(None, true)}
fn key_action(&mut self, _key: char) -> (Option<xous_ipc::String::<512>>, bool) {(None, true)}
}
#[enum_dispatch(ActionApi)]
@ -842,7 +835,7 @@ fn recompute_canvas(modal: &mut Modal, action: ActionType, top_text: Option<&str
top_tv.margin = Point::new(0, 0,); // all margin already accounted for in the raw bounds of the text drawing
top_tv.ellipsis = false;
top_tv.invert = modal.inverted;
write!(top_tv.text, "{}", top_str);
write!(top_tv.text, "{}", top_str).unwrap();
log::trace!("posting top tv: {:?}", top_tv);
modal.gam.bounds_compute_textview(&mut top_tv).expect("couldn't simulate top text size");
@ -858,7 +851,7 @@ fn recompute_canvas(modal: &mut Modal, action: ActionType, top_text: Option<&str
// compute height of action item
log::trace!("step 1 total_height: {}", total_height);
total_height += modal.action.height(modal.line_height, modal.margin);
total_height += action.height(modal.line_height, modal.margin);
total_height += modal.margin;
// compute height of bot_text, if any
@ -874,7 +867,7 @@ fn recompute_canvas(modal: &mut Modal, action: ActionType, top_text: Option<&str
bot_tv.margin = Point::new(0, 0,); // all margin already accounted for in the raw bounds of the text drawing
bot_tv.ellipsis = false;
bot_tv.invert = modal.inverted;
write!(bot_tv.text, "{}", bot_str);
write!(bot_tv.text, "{}", bot_str).unwrap();
log::trace!("posting bot tv: {:?}", bot_tv);
modal.gam.bounds_compute_textview(&mut bot_tv).expect("couldn't simulate bot text size");
@ -971,7 +964,7 @@ impl<'a> Modal<'a> {
rawkeys_op,
drop_op
};
let mut buf = Buffer::into_buf(helper_data).expect("couldn't allocate helper data for helper thread");
let buf = Buffer::into_buf(helper_data).expect("couldn't allocate helper data for helper thread");
let (addr, size, offset) = unsafe{buf.to_raw_parts()};
self.helper_data = Some(buf);
xous::create_thread_3(crate::forwarding_thread, addr, size, offset).expect("couldn't spawn a helper thread");

View file

@ -251,8 +251,8 @@ fn xmain() -> ! {
} else {
checkedwidth
};
let br = Point::new(tl.x + checkedwidth, tl.y + checkedheight);
log::trace!("br: {:?}, comp w: {}, comp h: {}", br, checkedwidth, checkedheight);
let br = Point::new(tl.x + finalwidth, tl.y + checkedheight);
log::trace!("br: {:?}, comp w: {}, comp h: {}", br, finalwidth, checkedheight);
if clip_rect.intersects_point(br) {
tv.bounds_computed = Some(Rectangle::new(
tl,

View file

@ -1,4 +1,5 @@
pub(crate) const SERVER_NAME_KEYS: &str = "_Root key server and update manager_";
#[allow(dead_code)]
pub(crate) const ROOTKEY_MODAL_NAME: &'static str = "rootkeys modal";

View file

@ -1,19 +1,22 @@
use utralib::generated::*;
use crate::api::*;
use log::info;
use core::num::NonZeroUsize;
use num_traits::*;
const KEYROMADR_FPGA_KEY: u32 = 0x00;
const KEYROMADR_SELFSIGN_PRIVKEY: u32 = 0x08;
const KEYROMADR_SELFSIGN_PUBKEY: u32 = 0x10;
const KEYROMADR_DEVELOPER_PUBKEY: u32 = 0x18;
const KEYROMADR_THIRDPARTY_PUBKEY: u32 = 0x20;
const KEYROMADR_USER_KEY: u32 = 0x28;
const KEYROMADR_PEPPER: u32 = 0xf8;
const KEYROMADR_FPGA_REV: u32 = 0xfc;
const KEYROMADR_LOADER_REV: u32 = 0xfd;
const KERYOMADR_CONFIG: u32 = 0xff;
struct KeyRomLocations {}
#[allow(dead_code)]
impl KeyRomLocations {
const FPGA_KEY: u32 = 0x00;
const SELFSIGN_PRIVKEY: u32 = 0x08;
const SELFSIGN_PUBKEY: u32 = 0x10;
const DEVELOPER_PUBKEY: u32 = 0x18;
const THIRDPARTY_PUBKEY: u32 = 0x20;
const USER_KEY: u32 = 0x28;
const PEPPER: u32 = 0xf8;
const FPGA_REV: u32 = 0xfc;
const LOADER_REV: u32 = 0xfd;
const CONFIG: u32 = 0xff;
}
pub struct KeyField {
mask: u32,
@ -31,6 +34,7 @@ impl KeyField {
(value & self.mask) << self.offset
}
}
#[allow(dead_code)]
pub(crate) mod keyrom_config {
use crate::KeyField;
pub const VERSION_MINOR: KeyField = KeyField::new(8, 0 );
@ -114,7 +118,7 @@ impl RootKeys {
xous::MemoryFlags::R | xous::MemoryFlags::W,
).expect("couldn't map sensitive data page");
let mut keys = RootKeys {
let keys = RootKeys {
keyrom: CSR::new(keyrom.as_mut_ptr() as *mut u32),
gateware,
staging,
@ -182,7 +186,7 @@ impl RootKeys {
step += 1;
self.update_progress(progress_cid, step, total, false);
self.keyrom.wfo(utra::keyrom::ADDRESS_ADDRESS, KERYOMADR_CONFIG);
self.keyrom.wfo(utra::keyrom::ADDRESS_ADDRESS, KeyRomLocations::CONFIG);
let config = self.keyrom.rf(utra::keyrom::DATA_DATA);
if config & keyrom_config::INITIALIZED.ms(1) != 0 {
@ -210,7 +214,7 @@ impl RootKeys {
// - pepper
// provision the pepper
for keyword in sensitive_slice[KEYROMADR_PEPPER as usize..(KEYROMADR_PEPPER + 8) as usize].iter_mut() {
for keyword in sensitive_slice[KeyRomLocations::PEPPER as usize..(KeyRomLocations::PEPPER + 8) as usize].iter_mut() {
*keyword = self.trng.get_u32().expect("couldn't get random number");
}

View file

@ -3,7 +3,7 @@
pub mod api;
use api::*;
use xous::{CID, msg_blocking_scalar_unpack, msg_scalar_unpack, send_message, Message};
use xous::{CID, msg_scalar_unpack, send_message, Message};
use num_traits::*;
pub use cipher::{self, BlockCipher, BlockDecrypt, BlockEncrypt, consts::U16};

View file

@ -68,7 +68,7 @@ pub(crate) fn rootkeys_ux_thread() {
};
log::trace!("building ux thread modal");
let mut modal = gam::Modal::new(
crate::ROOTKEY_MODAL_NAME,
crate::api::ROOTKEY_MODAL_NAME,
gam::ActionType::TextEntry(password_action),
Some(t!("rootpass.top", xous::LANG)),
None,

View file

@ -29,6 +29,7 @@ pub struct DateTime {
}
pub(crate) const SERVER_NAME_RTC: &str = "_Real time clock application server_";
#[allow(dead_code)]
pub(crate) const RTC_MODAL_NAME: &'static str = "rtc modal";
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]

View file

@ -613,7 +613,7 @@ fn xmain() -> ! {
rtc_radiobox.add_item(ItemName::new(t!("rtc.sunday", xous::LANG)));
log::trace!("building rtc ux modal");
let mut modal = gam::Modal::new(
crate::RTC_MODAL_NAME,
crate::api::RTC_MODAL_NAME,
gam::ActionType::TextEntry(rtc_textentry),
Some(t!("rtc.month", xous::LANG)),
None,
@ -626,7 +626,7 @@ fn xmain() -> ! {
Opcode::UxQuit.to_u32().unwrap()
);
let gam = gam::Gam::new(&xns).expect("couldn't connect to GAM");
let mut secs: u8 = 0;
let mut secs: u8;
let mut mins: u8 = 0;
let mut hours: u8 = 0;
let mut months: u8 = 0;

View file

@ -264,7 +264,7 @@ pub(crate) const APP_NAME_SHELLCHAT: &str = "shellchat"; // the user-facing name
#[xous::xous_main]
fn xmain() -> ! {
log_server::init_wait().unwrap();
log::set_max_level(log::LevelFilter::Debug);
log::set_max_level(log::LevelFilter::Info);
info!("my PID is {}", xous::process::id());
let xns = xous_names::XousNames::new().unwrap();