Skip to content

Commit 6c01f45

Browse files
committed
Fix some more warnings
1 parent a4a1fb5 commit 6c01f45

File tree

5 files changed

+10
-57
lines changed

5 files changed

+10
-57
lines changed

bios/stage-2/src/dap.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use core::arch::asm;
22

33
#[derive(Debug, Clone, Copy)]
4+
#[allow(dead_code)]
45
#[repr(packed)]
56
pub struct DiskAddressPacket {
67
/// Size of the DAP structure

bios/stage-2/src/disk.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ impl Seek for DiskAccess {
6565
self.current_offset = offset;
6666
self.current_offset
6767
}
68-
SeekFrom::Current(offset) => {
69-
self.current_offset = (i64::try_from(self.current_offset).unwrap() + offset)
70-
.try_into()
71-
.unwrap();
72-
self.current_offset
73-
}
7468
}
7569
}
7670
}
@@ -83,7 +77,6 @@ pub trait Read {
8377
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8478
pub enum SeekFrom {
8579
Start(u64),
86-
Current(i64),
8780
}
8881

8982
pub trait Seek {

bios/stage-2/src/fat.rs

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// based on https://crates.io/crates/mini_fat by https://github.com/gridbugs
22

33
use crate::disk::{AlignedBuffer, Read, Seek, SeekFrom};
4-
use core::{char::DecodeUtf16Error, fmt::Write as _};
4+
use core::char::DecodeUtf16Error;
55

66
const DIRECTORY_ENTRY_BYTES: usize = 32;
77
const UNUSED_ENTRY_PREFIX: u8 = 0xE5;
@@ -312,6 +312,7 @@ impl FatType {
312312
}
313313
}
314314

315+
#[allow(dead_code)]
315316
#[derive(Clone)]
316317
pub struct DirectoryEntry<'a> {
317318
short_name: &'a str,
@@ -325,37 +326,6 @@ pub struct DirectoryEntry<'a> {
325326
}
326327

327328
impl<'a> DirectoryEntry<'a> {
328-
pub fn name(&self) -> impl Iterator<Item = Result<char, DecodeUtf16Error>> + 'a {
329-
let mut long_name = {
330-
let iter = self
331-
.long_name_1
332-
.chunks(2)
333-
.chain(self.long_name_2.chunks(2))
334-
.chain(self.long_name_3.chunks(2))
335-
.map(|c| u16::from_le_bytes(c.try_into().unwrap()))
336-
.take_while(|&c| c != 0);
337-
char::decode_utf16(iter).peekable()
338-
};
339-
let short_name = {
340-
let iter = self.short_name.chars();
341-
let extension_iter = {
342-
let raw = ".".chars().chain(self.short_name_extension.chars());
343-
raw.take(if self.short_name_extension.is_empty() {
344-
0
345-
} else {
346-
self.short_name_extension.len() + 1
347-
})
348-
};
349-
iter.chain(extension_iter).map(Ok)
350-
};
351-
352-
if long_name.peek().is_some() {
353-
long_name.chain(short_name.take(0))
354-
} else {
355-
long_name.chain(short_name.take(usize::MAX))
356-
}
357-
}
358-
359329
pub fn is_directory(&self) -> bool {
360330
self.attributes & directory_attributes::DIRECTORY != 0
361331
}
@@ -370,6 +340,7 @@ struct RawDirectoryEntryNormal<'a> {
370340
file_size: u32,
371341
}
372342

343+
#[allow(dead_code)]
373344
#[derive(Debug)]
374345
struct RawDirectoryEntryLongName<'a> {
375346
order: u8,

bios/stage-2/src/main.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![no_main]
33

44
use crate::{
5-
disk::{AlignedBuffer, Read, Seek, SeekFrom},
5+
disk::{Read, Seek, SeekFrom},
66
protected_mode::{
77
copy_to_protected_mode, enter_protected_mode_and_jump_to_stage_3, enter_unreal_mode,
88
},
@@ -28,14 +28,6 @@ const STAGE_3_DST: *mut u8 = 0x0010_0000 as *mut u8; // 1MiB (typically 14MiB ac
2828
const STAGE_4_DST: *mut u8 = 0x0020_0000 as *mut u8; // 2MiB (typically still 13MiB accessible here)
2929
const KERNEL_DST: *mut u8 = 0x0100_0000 as *mut u8; // 16MiB
3030

31-
extern "C" {
32-
static _second_stage_end: u8;
33-
}
34-
35-
fn second_stage_end() -> *const u8 {
36-
unsafe { &_second_stage_end }
37-
}
38-
3931
static mut DISK_BUFFER: AlignedArrayBuffer<0x4000> = AlignedArrayBuffer {
4032
buffer: [0; 0x4000],
4133
};

bios/stage-2/src/screen.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use core::{arch::asm, fmt::Write as _};
1+
use core::{arch::asm, fmt::Write};
22

33
pub fn print_char(c: u8) {
44
let ax = u16::from(c) | 0x0e00;
@@ -20,15 +20,9 @@ pub fn print_str(s: &str) {
2020
}
2121
}
2222

23-
fn hlt() {
24-
unsafe {
25-
asm!("hlt");
26-
}
27-
}
28-
2923
pub struct Writer;
3024

31-
impl core::fmt::Write for Writer {
25+
impl Write for Writer {
3226
fn write_str(&mut self, s: &str) -> core::fmt::Result {
3327
print_str(s);
3428
Ok(())
@@ -41,6 +35,8 @@ pub fn panic(info: &core::panic::PanicInfo) -> ! {
4135
let _ = writeln!(Writer, "\nPANIC: {}", info);
4236

4337
loop {
44-
hlt();
38+
unsafe {
39+
asm!("hlt");
40+
};
4541
}
4642
}

0 commit comments

Comments
 (0)