Remove one level of indirection for Context::name.

This commit is contained in:
4lDO2
2023-05-27 14:27:34 +02:00
parent 34894e3d73
commit 58c0c5d040
14 changed files with 25 additions and 35 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ pub fn resource() -> Result<Vec<u8>> {
let contexts = context::contexts();
for (id, context_lock) in contexts.iter() {
let context = context_lock.read();
rows.push((*id, context.name.read().clone(), context.status_reason));
rows.push((*id, context.name.clone(), context.status_reason));
}
}
+1 -1
View File
@@ -116,7 +116,7 @@ pub fn resource() -> Result<Vec<u8>> {
affinity,
cpu_time_string,
memory_string,
*context.name.read()));
context.name));
}
}
+3 -14
View File
@@ -1,19 +1,8 @@
use alloc::{
boxed::Box,
vec::Vec,
};
use alloc::vec::Vec;
use crate::context;
use crate::syscall::error::{Error, ESRCH, Result};
use crate::syscall::error::Result;
pub fn resource() -> Result<Vec<u8>> {
let name = {
let contexts = context::contexts();
let context_lock = contexts.current().ok_or(Error::new(ESRCH))?;
let context = context_lock.read();
let name = context.name.read();
let name_bytes: Box<[u8]> = name.clone().into();
name_bytes.into_vec()
};
Ok(name)
Ok(context::current()?.read().name.clone().into_owned().into_bytes())
}
+1 -1
View File
@@ -16,7 +16,7 @@ pub fn resource() -> Result<Vec<u8>> {
let contexts = context::contexts();
for (id, context_lock) in contexts.iter() {
let context = context_lock.read();
rows.push((*id, context.name.read().clone(), context.files.read().clone()));
rows.push((*id, context.name.clone(), context.files.read().clone()));
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ pub fn resource() -> Result<Vec<u8>> {
let contexts = context::contexts();
for (id, context_lock) in contexts.iter() {
let context = context_lock.read();
rows.push((*id, context.name.read().clone(), context.syscall));
rows.push((*id, context.name.clone(), context.syscall));
}
}