Skip to content

Commit

Permalink
Run clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
vinc committed Jul 26, 2024
1 parent 817007e commit bea431e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/sys/syscall/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,17 @@ pub fn dispatcher(
number::ALLOC => {
let size = arg1;
let align = arg2;
service::alloc(size, align) as usize
unsafe {
service::alloc(size, align) as usize
}
}
number::FREE => {
let ptr = arg1 as *mut u8;
let size = arg2;
let align = arg3;
service::free(ptr, size, align);
unsafe {
service::free(ptr, size, align);
}
0
}
_ => {
Expand Down
4 changes: 2 additions & 2 deletions src/sys/syscall/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ pub fn accept(handle: usize) -> Result<IpAddress, ()> {
Err(())
}

pub fn alloc(size: usize, align: usize) -> *mut u8 {
pub unsafe fn alloc(size: usize, align: usize) -> *mut u8 {
if let Ok(layout) = Layout::from_size_align(size, align) {
unsafe { sys::process::alloc(layout) }
} else {
core::ptr::null_mut()
}
}

pub fn free(ptr: *mut u8, size: usize, align: usize) {
pub unsafe fn free(ptr: *mut u8, size: usize, align: usize) {
if let Ok(layout) = Layout::from_size_align(size, align) {
unsafe { sys::process::free(ptr, layout) };
}
Expand Down
4 changes: 2 additions & 2 deletions src/usr/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn search_files(path: &str, options: &mut Options) {
if file.is_dir() {
search_files(&file_path, options);
} else if is_matching_file(&file_path, &options.file) {
if options.line == "" {
if options.line.is_empty() {
println!("{}", file_path.trim_start_matches(&options.trim));
} else {
print_matching_lines(&file_path, options);
Expand All @@ -116,7 +116,7 @@ fn search_files(path: &str, options: &mut Options) {
}

fn is_matching_file(path: &str, pattern: &str) -> bool {
let file = fs::filename(&path);
let file = fs::filename(path);
let re = Regex::from_glob(pattern);
re.is_match(file)
}
Expand Down

0 comments on commit bea431e

Please sign in to comment.