Skip to content

Commit

Permalink
Many warning fixes (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka committed Aug 3, 2020
1 parent 4ee1cbe commit 283fd24
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 74 deletions.
5 changes: 1 addition & 4 deletions kernel/standalone-builder/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use std::{
error, fs,
io::{self, Write as _},
error,
path::{Path, PathBuf},
process::Command,
str::FromStr,
};
use structopt::StructOpt;
use tempdir::TempDir;

#[derive(Debug, StructOpt)]
#[structopt(
Expand Down
2 changes: 1 addition & 1 deletion kernel/standalone-builder/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use std::{
env, fs, io,
fs, io,
path::{Path, PathBuf},
process::Command,
};
Expand Down
7 changes: 1 addition & 6 deletions kernel/standalone-builder/src/emulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use std::{
fs,
io::{self, Write as _},
path::{Path, PathBuf},
process::Command,
};
use std::{io, path::Path, process::Command};
use tempdir::TempDir;

/// Configuration for running the kernel in an emulator.
Expand Down
2 changes: 1 addition & 1 deletion kernel/standalone-builder/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use std::{
fs,
io::{self, Read, Seek, SeekFrom, Write},
path::{Path, PathBuf},
path::Path,
process::Command,
};
use tempdir::TempDir;
Expand Down
2 changes: 1 addition & 1 deletion kernel/standalone/src/arch/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use core::{
time::Duration,
};
use futures::channel::oneshot;
use hashbrown::{hash_map::Entry, HashMap};
use hashbrown::HashMap;
use redshirt_kernel_log_interface::ffi::{FramebufferFormat, FramebufferInfo, KernelLogMethod};
use spinning_top::Spinlock;
use x86_64::structures::port::{PortRead as _, PortWrite as _};
Expand Down
2 changes: 1 addition & 1 deletion kernel/standalone/src/arch/x86_64/ap_boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ pub unsafe fn boot_associated_processor(
// Write the location of marker 2 into the constant at marker 1.
let ljmp_target_ptr = (ap_boot_marker1_loc.add(2)) as *mut u32;
assert_eq!(ljmp_target_ptr.read_unaligned(), 0xdeaddead);
ljmp_target_ptr.write_unaligned({ u32::try_from(ap_boot_marker2_loc as usize).unwrap() });
ljmp_target_ptr.write_unaligned(u32::try_from(ap_boot_marker2_loc as usize).unwrap());

// Write the value of our `cr3` register to the constant at marker 3.
let pml_addr_ptr = (ap_boot_marker3_loc.add(2)) as *mut u32;
Expand Down
2 changes: 1 addition & 1 deletion kernel/standalone/src/arch/x86_64/apic/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub unsafe fn init() -> LocalApicsControl {
error_interrupt_vector.register_waker(&{
struct ErrWaker;
impl futures::task::ArcWake for ErrWaker {
fn wake_by_ref(arc_self: &Arc<Self>) {
fn wake_by_ref(_: &Arc<Self>) {
unsafe {
// The errors reported are found in the Error Status Register (ESR).
let esr_addr = usize::try_from(APIC_BASE_ADDR + 0xf0).unwrap() as *mut u32;
Expand Down
1 change: 0 additions & 1 deletion kernel/standalone/src/arch/x86_64/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use crate::klog::KLogger;

use alloc::sync::Arc;
use core::fmt::Write as _;
use redshirt_kernel_log_interface::ffi::{FramebufferFormat, FramebufferInfo, KernelLogMethod};
use spinning_top::Spinlock;

/// Modifies the logger to use when printing a panic.
Expand Down
1 change: 0 additions & 1 deletion kernel/standalone/src/hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use crate::{arch::PlatformSpecific, future_channel};

use alloc::{boxed::Box, sync::Arc, vec::Vec};
use core::{convert::TryFrom as _, pin::Pin, sync::atomic, task::Poll};
use crossbeam_queue::SegQueue;
use futures::prelude::*;
use hashbrown::HashMap;
use nohash_hasher::BuildNoHashHasher;
Expand Down
65 changes: 29 additions & 36 deletions kernel/standalone/src/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,10 @@
use crate::arch::PlatformSpecific;

use alloc::{format, string::String, sync::Arc, vec::Vec};
use core::{
convert::TryFrom as _,
pin::Pin,
sync::atomic::{AtomicBool, AtomicU64, Ordering},
};
use core::{convert::TryFrom as _, pin::Pin, sync::atomic::Ordering};
use futures::prelude::*;
use hashbrown::HashSet;
use redshirt_core::{
build_wasm_module, extrinsics::wasi::WasiExtrinsics, module::ModuleHash, System,
};
use redshirt_core::{build_wasm_module, extrinsics::wasi::WasiExtrinsics, System};
use spinning_top::Spinlock;

/// Main struct of this crate. Runs everything.
Expand Down Expand Up @@ -69,34 +63,33 @@ where
// TODO: don't do this on platforms that don't have PCI?
let pci_devices = unsafe { crate::pci::pci::init_cam_pci() };

let mut system_builder =
redshirt_core::system::SystemBuilder::new(WasiExtrinsics::default())
.with_native_program(crate::hardware::HardwareHandler::new(
platform_specific.clone(),
))
.with_native_program(crate::time::TimeHandler::new(platform_specific.clone()))
.with_native_program(crate::random::native::RandomNativeProgram::new(
platform_specific.clone(),
))
.with_native_program(crate::pci::native::PciNativeProgram::new(
pci_devices,
platform_specific.clone(),
))
.with_native_program(crate::klog::KernelLogNativeProgram::new(
platform_specific.clone(),
))
.with_startup_process(build_wasm_module!(
"../../../modules/p2p-loader",
"modules-loader"
))
.with_startup_process(build_wasm_module!("../../../modules/compositor"))
.with_startup_process(build_wasm_module!("../../../modules/pci-printer"))
.with_startup_process(build_wasm_module!("../../../modules/kernel-debug-printer"))
.with_startup_process(build_wasm_module!("../../../modules/log-to-kernel"))
.with_startup_process(build_wasm_module!("../../../modules/http-server"))
.with_startup_process(build_wasm_module!("../../../modules/hello-world"))
.with_startup_process(build_wasm_module!("../../../modules/network-manager"))
.with_startup_process(build_wasm_module!("../../../modules/e1000"));
let system_builder = redshirt_core::system::SystemBuilder::new(WasiExtrinsics::default())
.with_native_program(crate::hardware::HardwareHandler::new(
platform_specific.clone(),
))
.with_native_program(crate::time::TimeHandler::new(platform_specific.clone()))
.with_native_program(crate::random::native::RandomNativeProgram::new(
platform_specific.clone(),
))
.with_native_program(crate::pci::native::PciNativeProgram::new(
pci_devices,
platform_specific.clone(),
))
.with_native_program(crate::klog::KernelLogNativeProgram::new(
platform_specific.clone(),
))
.with_startup_process(build_wasm_module!(
"../../../modules/p2p-loader",
"modules-loader"
))
.with_startup_process(build_wasm_module!("../../../modules/compositor"))
.with_startup_process(build_wasm_module!("../../../modules/pci-printer"))
.with_startup_process(build_wasm_module!("../../../modules/kernel-debug-printer"))
.with_startup_process(build_wasm_module!("../../../modules/log-to-kernel"))
.with_startup_process(build_wasm_module!("../../../modules/http-server"))
.with_startup_process(build_wasm_module!("../../../modules/hello-world"))
.with_startup_process(build_wasm_module!("../../../modules/network-manager"))
.with_startup_process(build_wasm_module!("../../../modules/e1000"));

// TODO: remove the cfg guards once rpi-framebuffer is capable of auto-detecting whether
// it should enable itself
Expand Down
1 change: 0 additions & 1 deletion kernel/standalone/src/klog/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use crate::{arch::PlatformSpecific, future_channel};

use alloc::{boxed::Box, sync::Arc};
use core::{pin::Pin, str, sync::atomic, task::Poll};
use crossbeam_queue::SegQueue;
use futures::prelude::*;
use redshirt_core::native::{DummyMessageIdWrite, NativeProgramEvent, NativeProgramRef};
use redshirt_core::{Encode as _, EncodedMessage, InterfaceHash, MessageId, Pid};
Expand Down
19 changes: 6 additions & 13 deletions kernel/standalone/src/pci/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,9 @@

use crate::{arch::PlatformSpecific, future_channel, pci::pci};

use alloc::{boxed::Box, collections::VecDeque, sync::Arc, vec, vec::Vec};
use core::{
convert::TryFrom as _,
pin::Pin,
sync::atomic,
task::{Context, Poll},
};
use crossbeam_queue::SegQueue;
use alloc::{boxed::Box, collections::VecDeque, sync::Arc, vec::Vec};
use core::{convert::TryFrom as _, pin::Pin, sync::atomic, task::Poll};
use futures::prelude::*;
use rand_core::RngCore as _;
use redshirt_core::native::{DummyMessageIdWrite, NativeProgramEvent, NativeProgramRef};
use redshirt_core::{Decode as _, Encode as _, EncodedMessage, InterfaceHash, MessageId, Pid};
use redshirt_pci_interface::ffi;
Expand Down Expand Up @@ -203,10 +196,10 @@ where
memory_space,
bus_master,
}) => {
let mut locked_devices = self.locked_devices.lock();
if let Some(dev) = locked_devices
.iter_mut()
.find(|dev| dev.owner == emitter_pid && dev.bdf == location)
let locked_devices = self.locked_devices.lock();
if locked_devices
.iter()
.any(|dev| dev.owner == emitter_pid && dev.bdf == location)
{
self.devices
.devices()
Expand Down
5 changes: 2 additions & 3 deletions kernel/standalone/src/pci/pci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
//!
//! See https://en.wikipedia.org/wiki/PCI_configuration_space

use alloc::{borrow::Cow, collections::VecDeque, vec::Vec};
use alloc::{collections::VecDeque, vec::Vec};
use core::{convert::TryFrom as _, iter};
use fnv::FnvBuildHasher;

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
use x86_64::structures::port::{PortRead as _, PortWrite as _};
Expand Down Expand Up @@ -275,7 +274,7 @@ fn scan_function(bdf: &DeviceBdf) -> Option<ScanResult> {
(bytes[0], bytes[1], bytes[2], bytes[3])
};

let (_bist, header_ty, latency, cache_line) = {
let (_bist, header_ty, _latency, _cache_line) = {
let val = pci_cfg_read_u32(bdf, 0xc);
let bytes = val.to_be_bytes();
(bytes[0], bytes[1], bytes[2], bytes[3])
Expand Down
3 changes: 1 addition & 2 deletions kernel/standalone/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use crate::{arch::PlatformSpecific, future_channel};

use alloc::{boxed::Box, sync::Arc};
use core::{pin::Pin, sync::atomic, task::Poll};
use crossbeam_queue::SegQueue;
use futures::{prelude::*, stream::FuturesUnordered};
use redshirt_core::native::{DummyMessageIdWrite, NativeProgramEvent, NativeProgramRef};
use redshirt_core::{Decode as _, Encode as _, EncodedMessage, InterfaceHash, MessageId, Pid};
Expand Down Expand Up @@ -109,7 +108,7 @@ where
self,
interface: InterfaceHash,
message_id: Option<MessageId>,
emitter_pid: Pid,
_emitter_pid: Pid,
message: EncodedMessage,
) {
debug_assert_eq!(interface, INTERFACE);
Expand Down
3 changes: 1 addition & 2 deletions modules/pci-printer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
//! This program is nothing more than a small debugging utility.

use fnv::FnvBuildHasher;
use parity_scale_codec::DecodeAll;
use std::{borrow::Cow, convert::TryFrom as _};
use std::borrow::Cow;

include!(concat!(env!("OUT_DIR"), "/build-pci.rs"));

Expand Down

0 comments on commit 283fd24

Please sign in to comment.