mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-20 13:06:33 +00:00
Fix clippy warnings in kernel crate
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
81ba3b645b
commit
f0957d2f54
@ -113,7 +113,7 @@ struct Dirent {
|
||||
name: CString,
|
||||
}
|
||||
|
||||
#[repr(packed)]
|
||||
#[repr(C, packed)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
struct DirentInner {
|
||||
d_ino: u64,
|
||||
@ -172,7 +172,7 @@ struct Dirent64 {
|
||||
name: CString,
|
||||
}
|
||||
|
||||
#[repr(packed)]
|
||||
#[repr(C, packed)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
struct Dirent64Inner {
|
||||
d_ino: u64,
|
||||
|
@ -183,9 +183,9 @@ pub(super) fn access_sched_attr_with<T>(
|
||||
f: impl FnOnce(&SchedAttr) -> Result<T>,
|
||||
) -> Result<T> {
|
||||
match tid {
|
||||
0 => f(&ctx.thread.sched_attr()),
|
||||
0 => f(ctx.thread.sched_attr()),
|
||||
_ if tid > (i32::MAX as u32) => Err(Error::with_message(Errno::EINVAL, "invalid tid")),
|
||||
_ => f(&thread_table::get_thread(tid)
|
||||
_ => f(thread_table::get_thread(tid)
|
||||
.ok_or_else(|| Error::with_message(Errno::ESRCH, "thread does not exist"))?
|
||||
.sched_attr()),
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ pub(super) fn lookup_dentry_for_xattr<'a>(
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn read_xattr_name_cstr_from_user<'a>(
|
||||
pub(super) fn read_xattr_name_cstr_from_user(
|
||||
name_ptr: Vaddr,
|
||||
user_space: &CurrentUserSpace,
|
||||
) -> Result<CString> {
|
||||
@ -170,9 +170,10 @@ pub(super) fn parse_xattr_name(name_str: &str) -> Result<XattrName> {
|
||||
return_errno_with_message!(Errno::ERANGE, "xattr name empty or too long");
|
||||
}
|
||||
|
||||
let xattr_name = XattrName::try_from_full_name(name_str.as_ref()).ok_or(
|
||||
Error::with_message(Errno::EOPNOTSUPP, "invalid xattr namespace"),
|
||||
)?;
|
||||
let xattr_name = XattrName::try_from_full_name(name_str).ok_or(Error::with_message(
|
||||
Errno::EOPNOTSUPP,
|
||||
"invalid xattr namespace",
|
||||
))?;
|
||||
Ok(xattr_name)
|
||||
}
|
||||
|
||||
@ -181,18 +182,14 @@ pub(super) fn check_xattr_namespace(namespace: XattrNamespace, ctx: &Context) ->
|
||||
let permitted_capset = credentials.permitted_capset();
|
||||
let effective_capset = credentials.effective_capset();
|
||||
|
||||
match namespace {
|
||||
XattrNamespace::Trusted => {
|
||||
if !permitted_capset.contains(CapSet::SYS_ADMIN)
|
||||
|| !effective_capset.contains(CapSet::SYS_ADMIN)
|
||||
{
|
||||
return_errno_with_message!(
|
||||
Errno::EPERM,
|
||||
"try to access trusted xattr without CAP_SYS_ADMIN"
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
if namespace == XattrNamespace::Trusted
|
||||
&& (!permitted_capset.contains(CapSet::SYS_ADMIN)
|
||||
|| !effective_capset.contains(CapSet::SYS_ADMIN))
|
||||
{
|
||||
return_errno_with_message!(
|
||||
Errno::EPERM,
|
||||
"try to access trusted xattr without CAP_SYS_ADMIN"
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ impl From<Duration> for StatxTimestamp {
|
||||
fn from(duration: Duration) -> Self {
|
||||
Self {
|
||||
tv_sec: duration.as_secs() as i64,
|
||||
tv_nsec: duration.subsec_nanos() as u32,
|
||||
tv_nsec: duration.subsec_nanos(),
|
||||
__reserved: 0,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user