Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(xtask): enable clippy for feature = "newlib" #1358

Merged
merged 7 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/arch/riscv64/mm/virtualmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub fn allocate(size: usize) -> Result<VirtAddr, AllocError> {
))
}

#[cfg(not(feature = "newlib"))]
pub fn allocate_aligned(size: usize, align: usize) -> Result<VirtAddr, AllocError> {
assert!(size > 0);
assert!(align > 0);
Expand Down
6 changes: 6 additions & 0 deletions src/synch/recmutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ impl RecursiveMutex {
}
}
}

impl Default for RecursiveMutex {
fn default() -> Self {
Self::new()
}
}
1 change: 1 addition & 0 deletions src/syscalls/entropy.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(not(feature = "newlib"))]
use core::mem::size_of;
use core::slice;

Expand Down
2 changes: 0 additions & 2 deletions src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use core::alloc::{GlobalAlloc, Layout};
use core::ffi::{c_char, CStr};
use core::marker::PhantomData;

#[cfg(feature = "newlib")]
use hermit_sync::InterruptTicketMutex;
use hermit_sync::Lazy;

pub use self::condvar::*;
Expand Down
8 changes: 4 additions & 4 deletions src/syscalls/recmutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::synch::recmutex::RecursiveMutex;

#[hermit_macro::system]
#[no_mangle]
pub extern "C" fn sys_recmutex_init(recmutex: *mut *mut RecursiveMutex) -> i32 {
pub unsafe extern "C" fn sys_recmutex_init(recmutex: *mut *mut RecursiveMutex) -> i32 {
if recmutex.is_null() {
return -EINVAL;
}
Expand All @@ -21,7 +21,7 @@ pub extern "C" fn sys_recmutex_init(recmutex: *mut *mut RecursiveMutex) -> i32 {

#[hermit_macro::system]
#[no_mangle]
pub extern "C" fn sys_recmutex_destroy(recmutex: *mut RecursiveMutex) -> i32 {
pub unsafe extern "C" fn sys_recmutex_destroy(recmutex: *mut RecursiveMutex) -> i32 {
if recmutex.is_null() {
return -EINVAL;
}
Expand All @@ -37,7 +37,7 @@ pub extern "C" fn sys_recmutex_destroy(recmutex: *mut RecursiveMutex) -> i32 {

#[hermit_macro::system]
#[no_mangle]
pub extern "C" fn sys_recmutex_lock(recmutex: *mut RecursiveMutex) -> i32 {
pub unsafe extern "C" fn sys_recmutex_lock(recmutex: *mut RecursiveMutex) -> i32 {
if recmutex.is_null() {
return -EINVAL;
}
Expand All @@ -50,7 +50,7 @@ pub extern "C" fn sys_recmutex_lock(recmutex: *mut RecursiveMutex) -> i32 {

#[hermit_macro::system]
#[no_mangle]
pub extern "C" fn sys_recmutex_unlock(recmutex: *mut RecursiveMutex) -> i32 {
pub unsafe extern "C" fn sys_recmutex_unlock(recmutex: *mut RecursiveMutex) -> i32 {
if recmutex.is_null() {
return -EINVAL;
}
Expand Down
6 changes: 3 additions & 3 deletions src/syscalls/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub extern "C" fn sys_getpid() -> Tid {
#[cfg(feature = "newlib")]
#[hermit_macro::system]
#[no_mangle]
pub extern "C" fn sys_getprio(id: *const Tid) -> i32 {
pub unsafe extern "C" fn sys_getprio(id: *const Tid) -> i32 {
let task = core_scheduler().get_current_task_handle();

if id.is_null() || unsafe { *id } == task.get_id().into() {
Expand All @@ -41,7 +41,7 @@ pub extern "C" fn sys_getprio(id: *const Tid) -> i32 {
#[cfg(feature = "newlib")]
#[hermit_macro::system]
#[no_mangle]
pub extern "C" fn sys_setprio(_id: *const Tid, _prio: i32) -> i32 {
pub unsafe extern "C" fn sys_setprio(_id: *const Tid, _prio: i32) -> i32 {
-ENOSYS
}

Expand Down Expand Up @@ -152,7 +152,7 @@ pub unsafe extern "C" fn sys_nanosleep(rqtp: *const timespec, _rmtp: *mut timesp
#[cfg(feature = "newlib")]
#[hermit_macro::system]
#[no_mangle]
pub extern "C" fn sys_clone(id: *mut Tid, func: extern "C" fn(usize), arg: usize) -> i32 {
pub unsafe extern "C" fn sys_clone(id: *mut Tid, func: extern "C" fn(usize), arg: usize) -> i32 {
let task_id = core_scheduler().clone(func, arg);

if !id.is_null() {
Expand Down
10 changes: 4 additions & 6 deletions xtask/src/clippy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ impl Clippy {
.run()?;
}

// TODO: Enable clippy for newlib
// https://github.com/hermit-os/kernel/issues/470
// cmd!(sh, "cargo clippy --target={triple}")
// .arg("--no-default-features")
// .arg("--features=acpi,fsgsbase,newlib,smp,vga")
// .run()?;
cmd!(sh, "cargo clippy --target={triple}")
.arg("--no-default-features")
.arg("--features=acpi,fsgsbase,newlib,smp,vga")
.run()?;
}

cmd!(sh, "cargo clippy")
Expand Down