Skip to content

Commit

Permalink
fix: compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
llenotre committed Aug 20, 2024
1 parent ff0a671 commit 66a2972
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 25 deletions.
17 changes: 6 additions & 11 deletions kernel/src/device/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use core::{cmp::min, mem::ManuallyDrop, num::NonZeroU64};
use utils::{errno, errno::EResult};

/// Device which does nothing.
#[derive(Default)]
pub struct NullDeviceHandle;

impl DeviceIO for NullDeviceHandle {
Expand All @@ -52,7 +51,6 @@ impl DeviceIO for NullDeviceHandle {
}

/// Device returning only null bytes.
#[derive(Default)]
pub struct ZeroDeviceHandle;

impl DeviceIO for ZeroDeviceHandle {
Expand All @@ -77,7 +75,6 @@ impl DeviceIO for ZeroDeviceHandle {
/// Device allows to get random bytes.
///
/// This device will block reading until enough entropy is available.
#[derive(Default)]
pub struct RandomDeviceHandle;

impl DeviceIO for RandomDeviceHandle {
Expand Down Expand Up @@ -115,7 +112,6 @@ impl DeviceIO for RandomDeviceHandle {
///
/// If not enough entropy is available, the output might not have a sufficient
/// quality.
#[derive(Default)]
pub struct URandomDeviceHandle;

impl DeviceIO for URandomDeviceHandle {
Expand Down Expand Up @@ -149,7 +145,6 @@ impl DeviceIO for URandomDeviceHandle {
}

/// Device allowing to read or write kernel logs.
#[derive(Default)]
pub struct KMsgDeviceHandle;

impl DeviceIO for KMsgDeviceHandle {
Expand Down Expand Up @@ -191,7 +186,7 @@ pub(super) fn create() -> EResult<()> {
},
null_path,
0o666,
NullDeviceHandle::default(),
NullDeviceHandle,
)?;
device::register(null_device)?;

Expand All @@ -204,7 +199,7 @@ pub(super) fn create() -> EResult<()> {
},
zero_path,
0o666,
ZeroDeviceHandle::default(),
ZeroDeviceHandle,
)?;
device::register(zero_device)?;

Expand All @@ -217,7 +212,7 @@ pub(super) fn create() -> EResult<()> {
},
random_path,
0o666,
RandomDeviceHandle::default(),
RandomDeviceHandle,
)?;
device::register(random_device)?;

Expand All @@ -230,7 +225,7 @@ pub(super) fn create() -> EResult<()> {
},
urandom_path,
0o666,
URandomDeviceHandle::default(),
URandomDeviceHandle,
)?;
device::register(urandom_device)?;

Expand All @@ -243,7 +238,7 @@ pub(super) fn create() -> EResult<()> {
},
kmsg_path,
0o600,
KMsgDeviceHandle::default(),
KMsgDeviceHandle,
)?;
device::register(kmsg_device)?;

Expand All @@ -258,7 +253,7 @@ pub(super) fn create() -> EResult<()> {
},
current_tty_path,
0o666,
TTYDeviceHandle::default(),
TTYDeviceHandle,
)?;
device::register(current_tty_device)?;

Expand Down
1 change: 0 additions & 1 deletion kernel/src/device/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use core::{ffi::c_void, num::NonZeroU64};
use utils::{errno, errno::EResult};

/// A TTY device's handle.
#[derive(Default)]
pub struct TTYDeviceHandle;

impl TTYDeviceHandle {
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/file/buffer/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl NodeOps for PipeBuffer {
}

fn write_content(&self, _loc: &FileLocation, _off: u64, buf: &[u8]) -> EResult<usize> {
if unlikely(buf.len() == 0) {
if unlikely(buf.is_empty()) {
return Ok(0);
}
let mut inner = self.inner.lock();
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/file/fs/ext2/dirent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl Dirent {
// If the type could not be retrieved from the entry itself, get it from the inode
match ent_type {
Some(t) => Ok(t),
None => Ok(Ext2INode::read(self.inode, superblock, &*io)?.get_type()),
None => Ok(Ext2INode::read(self.inode, superblock, io)?.get_type()),
}
}

Expand Down
4 changes: 2 additions & 2 deletions kernel/src/file/fs/ext2/inode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ impl Ext2INode {
let blk_off = (off + cur as u64) / blk_size as u64;
let blk_inner_off = ((off + cur as u64) % blk_size as u64) as usize;
let len = min(max - cur, (blk_size - blk_inner_off as u32) as usize);
let dst = &mut buff[(cur as usize)..((cur + len) as usize)];
let dst = &mut buff[cur..(cur + len)];
// Get disk block offset
if let Some(blk_off) = self.translate_blk_off(blk_off as _, superblock, io)? {
// A content block is present, copy
Expand Down Expand Up @@ -739,7 +739,7 @@ impl Ext2INode {
let mut off = 0;
while let Some(ent) = next_dirent(self, superblock, io, &mut buf, off)? {
if !ent.is_free() && ent.get_name(superblock) == name {
return Ok(Some((ent.inode, ent.get_type(superblock, &*io)?, off)));
return Ok(Some((ent.inode, ent.get_type(superblock, io)?, off)));
}
off += ent.rec_len as u64;
}
Expand Down
10 changes: 5 additions & 5 deletions kernel/src/process/mem_space/residence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ impl MapResidence {

/// Adds a value of `pages` pages to the offset of the residence, if applicable.
pub fn offset_add(&mut self, pages: usize) {
match self {
Self::File {
off, ..
} => *off += pages as u64 * memory::PAGE_SIZE as u64,
_ => {}
if let Self::File {
off, ..
} = self
{
*off += pages as u64 * memory::PAGE_SIZE as u64
}
}

Expand Down
2 changes: 1 addition & 1 deletion kernel/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ impl Process {
regs: self.regs.clone(),
syscalling: false,

handled_signal: self.handled_signal.clone(),
handled_signal: self.handled_signal,
sigreturn_regs: self.sigreturn_regs.clone(),
waitable: false,

Expand Down
2 changes: 1 addition & 1 deletion kernel/src/process/signal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl SignalHandler {
return_regs.set_syscall_return(Err(errno!(EINTR)));
}
debug_assert!(return_regs.eip.0 < crate::memory::PROCESS_END as usize);
process.signal_save(signal.clone(), return_regs);
process.signal_save(signal, return_regs);
// Prepare registers for the handler
let signal_trampoline = signal_trampoline as *const c_void;
process.regs.esp.0 = signal_esp as _;
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/syscall/execve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ fn build_image(
argv,
envp,
};
exec::build_image(&file, exec_info)
exec::build_image(file, exec_info)
}

pub fn execve(
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/syscall/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ mod open;
mod openat;
mod pipe;
mod pipe2;
pub mod poll;
mod poll;
mod preadv;
mod preadv2;
mod prlimit64;
Expand Down
1 change: 1 addition & 0 deletions kernel/src/tty/termios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ pub struct Termios {

impl Termios {
/// Creates a new instance with the default values.
#[allow(clippy::new_without_default)]
pub const fn new() -> Self {
use consts::*;
let mut t = Self {
Expand Down

0 comments on commit 66a2972

Please sign in to comment.