mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
start a cleanup pass on warnings
This commit is contained in:
parent
11c22b6d19
commit
b4bfaefa64
5 changed files with 68 additions and 9 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
{
|
{
|
||||||
"rust-analyzer.checkOnSave.allTargets": false
|
"rust-analyzer.checkOnSave.allTargets": false,
|
||||||
|
"rust-analyzer.cargo.target":"riscv32imac-unknown-xous-elf"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,9 @@ pub(crate) enum PddbRetcode {
|
||||||
Ok = 1,
|
Ok = 1,
|
||||||
BasisLost = 2,
|
BasisLost = 2,
|
||||||
AccessDenied = 3,
|
AccessDenied = 3,
|
||||||
|
UnexpectedEof = 4,
|
||||||
|
InternalError = 5,
|
||||||
|
DiskFull = 6,
|
||||||
}
|
}
|
||||||
/// PddbBuf is a C-representation of a page of memory that's used
|
/// PddbBuf is a C-representation of a page of memory that's used
|
||||||
/// to shuttle data for streaming channels. It must be exactly one
|
/// to shuttle data for streaming channels. It must be exactly one
|
||||||
|
|
|
||||||
|
|
@ -1319,7 +1319,7 @@ impl BasisCacheEntry {
|
||||||
if let Some(dict) = self.dicts.get_mut(&String::from(name)) {
|
if let Some(dict) = self.dicts.get_mut(&String::from(name)) {
|
||||||
let dict_offset = VirtAddr::new(dict.index.get() as u64 * DICT_VSIZE).unwrap();
|
let dict_offset = VirtAddr::new(dict.index.get() as u64 * DICT_VSIZE).unwrap();
|
||||||
if !dict.clean {
|
if !dict.clean {
|
||||||
let mut dict_name = DictName::try_from_str(name).or(Err(Error::new(ErrorKind::InvalidInput, "dictionary name invalid: invalid utf-8 or length")))?;
|
let dict_name = DictName::try_from_str(name).or(Err(Error::new(ErrorKind::InvalidInput, "dictionary name invalid: invalid utf-8 or length")))?;
|
||||||
let dict_disk = Dictionary {
|
let dict_disk = Dictionary {
|
||||||
flags: dict.flags,
|
flags: dict.flags,
|
||||||
age: dict.age,
|
age: dict.age,
|
||||||
|
|
@ -1385,7 +1385,7 @@ impl BasisCacheEntry {
|
||||||
log::debug!("merging in key {}", key_name);
|
log::debug!("merging in key {}", key_name);
|
||||||
// key is within the current page, add it to the target list
|
// key is within the current page, add it to the target list
|
||||||
let mut dk_entry = DictKeyEntry::default();
|
let mut dk_entry = DictKeyEntry::default();
|
||||||
let mut kn = KeyName::try_from_str(key_name).or(Err(Error::new(ErrorKind::InvalidInput, "key name invalid: invalid utf-8 or length")))?;
|
let kn = KeyName::try_from_str(key_name).or(Err(Error::new(ErrorKind::InvalidInput, "key name invalid: invalid utf-8 or length")))?;
|
||||||
let key_desc = KeyDescriptor {
|
let key_desc = KeyDescriptor {
|
||||||
start: key.start,
|
start: key.start,
|
||||||
len: key.len,
|
len: key.len,
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ impl<'a> Write for PddbKey<'a> {
|
||||||
match FromPrimitive::from_u8(rcode as u8) {
|
match FromPrimitive::from_u8(rcode as u8) {
|
||||||
Some(PddbRetcode::Ok) => Ok(()),
|
Some(PddbRetcode::Ok) => Ok(()),
|
||||||
Some(PddbRetcode::BasisLost) => Err(Error::new(ErrorKind::BrokenPipe, "Basis lost")),
|
Some(PddbRetcode::BasisLost) => Err(Error::new(ErrorKind::BrokenPipe, "Basis lost")),
|
||||||
|
Some(PddbRetcode::DiskFull) => Err(Error::new(ErrorKind::OutOfMemory, "Out of disk space, some data lost on sync")),
|
||||||
_ => Err(Error::new(ErrorKind::Interrupted, "Flush failed for unspecified reasons")),
|
_ => Err(Error::new(ErrorKind::Interrupted, "Flush failed for unspecified reasons")),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -399,6 +399,7 @@ struct TokenRecord {
|
||||||
pub dict: String,
|
pub dict: String,
|
||||||
pub key: String,
|
pub key: String,
|
||||||
pub basis: Option<String>,
|
pub basis: Option<String>,
|
||||||
|
pub alloc_hint: Option<usize>,
|
||||||
pub conn: xous::CID, // callback connection
|
pub conn: xous::CID, // callback connection
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -724,6 +725,7 @@ fn xmain() -> ! {
|
||||||
key: String::from(key),
|
key: String::from(key),
|
||||||
basis: if let Some(name) = bname {Some(String::from(name))} else {None},
|
basis: if let Some(name) = bname {Some(String::from(name))} else {None},
|
||||||
conn: cid,
|
conn: cid,
|
||||||
|
alloc_hint: if let Some(hint) = req.alloc_hint {Some(hint as usize)} else {None},
|
||||||
};
|
};
|
||||||
token_dict.insert(token, token_record);
|
token_dict.insert(token, token_record);
|
||||||
req.token = Some(token);
|
req.token = Some(token);
|
||||||
|
|
@ -948,7 +950,7 @@ fn xmain() -> ! {
|
||||||
Some(Opcode::GetDictNameAtIndex) => {
|
Some(Opcode::GetDictNameAtIndex) => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut req = buffer.to_original::<PddbDictRequest, _>().unwrap();
|
let mut req = buffer.to_original::<PddbDictRequest, _>().unwrap();
|
||||||
if let Some(token) = key_token {
|
if let Some(token) = dict_token {
|
||||||
if req.token != token {
|
if req.token != token {
|
||||||
req.code = PddbRequestCode::AccessDenied;
|
req.code = PddbRequestCode::AccessDenied;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -970,14 +972,66 @@ fn xmain() -> ! {
|
||||||
buffer.replace(req).unwrap();
|
buffer.replace(req).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::ReadKey) => {
|
Some(Opcode::ReadKey) => {
|
||||||
// placeholder
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
|
let pbuf = PddbBuf::from_slice_mut(buffer.as_mut()); // direct translation, no serialization necessary for performance
|
||||||
|
let token = pbuf.token;
|
||||||
|
if let Some(rec) = token_dict.get(&token) {
|
||||||
|
match basis_cache.key_read(&mut pddb_os,
|
||||||
|
&rec.dict, &rec.key,
|
||||||
|
&mut pbuf.data[..pbuf.len as usize], Some(pbuf.position as usize),
|
||||||
|
if let Some (name) = &rec.basis {Some(&name)} else {None}) {
|
||||||
|
Ok(readlen) => {
|
||||||
|
pbuf.len = readlen as u16;
|
||||||
|
pbuf.retcode = PddbRetcode::Ok;
|
||||||
|
}
|
||||||
|
Err(e) => match e.kind() {
|
||||||
|
std::io::ErrorKind::NotFound => pbuf.retcode = PddbRetcode::BasisLost,
|
||||||
|
std::io::ErrorKind::UnexpectedEof => pbuf.retcode = PddbRetcode::UnexpectedEof,
|
||||||
|
std::io::ErrorKind::OutOfMemory => pbuf.retcode = PddbRetcode::DiskFull,
|
||||||
|
_ => pbuf.retcode = PddbRetcode::InternalError,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pbuf.retcode = PddbRetcode::BasisLost;
|
||||||
|
}
|
||||||
|
// we don't nede a "replace" operation because all ops happen in-place
|
||||||
}
|
}
|
||||||
Some(Opcode::WriteKey) => {
|
Some(Opcode::WriteKey) => {
|
||||||
// placeholder
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
}
|
let pbuf = PddbBuf::from_slice_mut(buffer.as_mut()); // direct translation, no serialization necessary for performance
|
||||||
Some(Opcode::WriteKeyFlush) => {
|
let token = pbuf.token;
|
||||||
// placeholder
|
if let Some(rec) = token_dict.get(&token) {
|
||||||
|
match basis_cache.key_update(&mut pddb_os,
|
||||||
|
&rec.dict, &rec.key,
|
||||||
|
&pbuf.data[..pbuf.len as usize], Some(pbuf.position as usize),
|
||||||
|
rec.alloc_hint, if let Some (name) = &rec.basis {Some(&name)} else {None},
|
||||||
|
false
|
||||||
|
) {
|
||||||
|
Ok(_) => {
|
||||||
|
pbuf.retcode = PddbRetcode::Ok;
|
||||||
|
}
|
||||||
|
Err(e) => match e.kind() {
|
||||||
|
std::io::ErrorKind::NotFound => pbuf.retcode = PddbRetcode::BasisLost,
|
||||||
|
std::io::ErrorKind::UnexpectedEof => pbuf.retcode = PddbRetcode::UnexpectedEof,
|
||||||
|
std::io::ErrorKind::OutOfMemory => pbuf.retcode = PddbRetcode::DiskFull,
|
||||||
|
_ => pbuf.retcode = PddbRetcode::InternalError,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pbuf.retcode = PddbRetcode::BasisLost;
|
||||||
|
}
|
||||||
|
// we don't nede a "replace" operation because all ops happen in-place
|
||||||
}
|
}
|
||||||
|
Some(Opcode::WriteKeyFlush) => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||||
|
match basis_cache.sync(&mut pddb_os, None) {
|
||||||
|
Ok(_) => xous::return_scalar(msg.sender, PddbRetcode::Ok.to_usize().unwrap()).unwrap(),
|
||||||
|
Err(e) => match e.kind() {
|
||||||
|
std::io::ErrorKind::OutOfMemory => xous::return_scalar(msg.sender, PddbRetcode::DiskFull.to_usize().unwrap()).unwrap(),
|
||||||
|
std::io::ErrorKind::NotFound => xous::return_scalar(msg.sender, PddbRetcode::BasisLost.to_usize().unwrap()).unwrap(),
|
||||||
|
_ => xous::return_scalar(msg.sender, PddbRetcode::InternalError.to_usize().unwrap()).unwrap(),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}),
|
||||||
Some(Opcode::Quit) => {
|
Some(Opcode::Quit) => {
|
||||||
log::warn!("quitting the PDDB server");
|
log::warn!("quitting the PDDB server");
|
||||||
send_message(
|
send_message(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue