Skip to content

Commit

Permalink
Merge pull request #124 from DLR-FT/fix-rustfmt-config
Browse files Browse the repository at this point in the history
style: fix rustfmt config and rerun it
  • Loading branch information
sevenautumns authored Jul 16, 2024
2 parents c0053ce + e0e00dd commit 94e4436
Show file tree
Hide file tree
Showing 23 changed files with 45 additions and 61 deletions.
1 change: 0 additions & 1 deletion .rustfmt.toml

This file was deleted.

6 changes: 2 additions & 4 deletions core/src/mfd.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//! Implementation of a memory fd
use std::{
io::{Read, Seek, SeekFrom, Write},
os::fd::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd},
};
use std::io::{Read, Seek, SeekFrom, Write};
use std::os::fd::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd};

use anyhow::{bail, Result};
use memfd::{FileSeal, Memfd, MemfdOptions};
Expand Down
3 changes: 1 addition & 2 deletions core/src/queuing.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::fmt::Debug;
use std::mem;
use std::mem::size_of;
use std::os::fd::RawFd;
use std::os::fd::{AsRawFd, OwnedFd};
use std::os::fd::{AsRawFd, OwnedFd, RawFd};
use std::ptr::slice_from_raw_parts;
use std::time::Instant;

Expand Down
4 changes: 3 additions & 1 deletion examples/dev_random/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ fn main() {

#[partition(a653rs_linux::partition::ApexLinuxPartition)]
mod dev_random {
use std::fs::*;
use std::io::Read;

use log::info;
use std::{fs::*, io::Read};

#[start(cold)]
fn cold_start(mut ctx: start::Context) {
Expand Down
3 changes: 1 addition & 2 deletions examples/fuel_tank/controller/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

use a653rs::partition;
use a653rs::prelude::PartitionExt;
use log::LevelFilter;

use a653rs_linux::partition::ApexLogger;
use log::LevelFilter;

fn main() {
ApexLogger::install_panic_hook();
Expand Down
6 changes: 4 additions & 2 deletions examples/hello_part_no_macros/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
//! This makes misuse of the API (as in attempting to create a port/process
//! during `NORMAL`) impossible.
use core::{str::FromStr, time::Duration};
use core::str::FromStr;
use core::time::Duration;

use a653rs::{bindings::ApexPartitionP4, prelude::*};
use a653rs::bindings::ApexPartitionP4;
use a653rs::prelude::*;
use a653rs_linux::partition::ApexLogger;
use a653rs_postcard::sampling::{SamplingPortDestinationExt, SamplingPortSourceExt};
use humantime::format_duration;
Expand Down
4 changes: 2 additions & 2 deletions examples/ping/client/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use a653rs::partition;
use a653rs::prelude::PartitionExt;
use log::LevelFilter;

use a653rs_linux::partition::ApexLogger;
use log::LevelFilter;

fn main() {
ApexLogger::install_panic_hook();
Expand All @@ -14,6 +13,7 @@ fn main() {
#[partition(a653rs_linux::partition::ApexLinuxPartition)]
mod ping_client {
use core::time::Duration;

use log::{info, warn};

#[sampling_out(name = "PingReq", msg_size = "16B")]
Expand Down
3 changes: 1 addition & 2 deletions examples/ping/server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use a653rs::partition;
use a653rs::prelude::PartitionExt;
use log::LevelFilter;

use a653rs_linux::partition::ApexLogger;
use log::LevelFilter;

fn main() {
ApexLogger::install_panic_hook();
Expand Down
4 changes: 2 additions & 2 deletions examples/ping_queue/client/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use a653rs::partition;
use a653rs::prelude::PartitionExt;
use log::LevelFilter;

use a653rs_linux::partition::ApexLogger;
use log::LevelFilter;

fn main() {
ApexLogger::install_panic_hook();
Expand All @@ -14,6 +13,7 @@ fn main() {
#[partition(a653rs_linux::partition::ApexLinuxPartition)]
mod ping_queue_client {
use core::time::Duration;

use log::{info, warn};

#[queuing_out(
Expand Down
3 changes: 1 addition & 2 deletions examples/ping_queue/server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use a653rs::partition;
use a653rs::prelude::PartitionExt;
use log::LevelFilter;

use a653rs_linux::partition::ApexLogger;
use log::LevelFilter;

fn main() {
ApexLogger::install_panic_hook();
Expand Down
3 changes: 2 additions & 1 deletion examples/redirect_stdio/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ fn main() {

#[partition(a653rs_linux::partition::ApexLinuxPartition)]
mod redirect_stdio {
use log::info;
use std::io::BufRead;

use log::info;

#[start(cold)]
fn cold_start(mut ctx: start::Context) {
// create and start an aperiodic process
Expand Down
5 changes: 2 additions & 3 deletions hypervisor/src/hypervisor/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ use std::path::PathBuf;
use std::time::Duration;

use a653rs::bindings::PartitionId;
use anyhow::anyhow;
use serde::{Deserialize, Serialize};

use a653rs_linux_core::channel::{QueuingChannelConfig, SamplingChannelConfig};
use a653rs_linux_core::error::{ResultExt, SystemError, TypedResult};
use a653rs_linux_core::health::{ModuleInitHMTable, ModuleRunHMTable, PartitionHMTable};
use anyhow::anyhow;
use serde::{Deserialize, Serialize};

use crate::hypervisor::scheduler::{PartitionSchedule, ScheduledTimeframe};

Expand Down
12 changes: 6 additions & 6 deletions hypervisor/src/hypervisor/partition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ use std::process::{Command, Stdio};
use std::thread::sleep;
use std::time::{Duration, Instant};

use super::config::PosixSocket;
use super::scheduler::Timeout;
use crate::hypervisor::config::Partition as PartitionConfig;
use crate::hypervisor::SYSTEM_START_TIME;
use crate::problem;

use a653rs::bindings::{PartitionId, PortDirection};
use a653rs::prelude::{OperatingMode, StartCondition};
use a653rs_linux_core::cgroup::{self, CGroup};
Expand All @@ -37,6 +31,12 @@ use polling::{Event, Events, Poller};
use procfs::process::Process;
use tempfile::{tempdir, TempDir};

use super::config::PosixSocket;
use super::scheduler::Timeout;
use crate::hypervisor::config::Partition as PartitionConfig;
use crate::hypervisor::SYSTEM_START_TIME;
use crate::problem;

mod mounting;

#[derive(Debug, Clone, Copy)]
Expand Down
1 change: 0 additions & 1 deletion hypervisor/src/hypervisor/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::time::Instant;

use a653rs::bindings::PartitionId;
use a653rs::prelude::OperatingMode;

use a653rs_linux_core::error::{LeveledResult, TypedResult};
use a653rs_linux_core::queuing::Queuing;
use a653rs_linux_core::sampling::Sampling;
Expand Down
8 changes: 3 additions & 5 deletions hypervisor/src/hypervisor/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ use std::num::NonZeroUsize;
use std::os::fd::{AsRawFd, BorrowedFd, FromRawFd, OwnedFd, RawFd};
use std::time::{Duration, Instant};

use a653rs_linux_core::mfd::{Mfd, Seals};
use a653rs_linux_core::syscall::{SyscallRequest, SyscallResponse};
use anyhow::{anyhow, bail, Result};
use libc::EINTR;
use nix::sys::socket::{recvmsg, ControlMessageOwned, MsgFlags};
use nix::{cmsg_space, unistd};
use polling::{Event, Events, Poller};

use a653rs_linux_core::mfd::{Mfd, Seals};
use a653rs_linux_core::syscall::{SyscallRequest, SyscallResponse};

/// Receives an FD triple from fd
// TODO: Use generics here
fn recv_fd_triple(fd: BorrowedFd) -> Result<[OwnedFd; 3]> {
Expand Down Expand Up @@ -110,13 +109,12 @@ mod tests {
use std::io::IoSlice;
use std::os::fd::{AsFd, AsRawFd};

use a653rs_linux_core::syscall::ApexSyscall;
use nix::sys::eventfd::EventFd;
use nix::sys::socket::{
sendmsg, socketpair, AddressFamily, ControlMessage, SockFlag, SockType,
};

use a653rs_linux_core::syscall::ApexSyscall;

use super::*;

#[test]
Expand Down
10 changes: 4 additions & 6 deletions hypervisor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ use std::fs::File;
use std::io::Write;
use std::path::PathBuf;

use anyhow::anyhow;
use clap::Parser;
use nix::sys::signal::*;

use a653rs_linux_core::cgroup;
use a653rs_linux_core::error::{ErrorLevel, LeveledResult, ResultExt, SystemError, TypedResultExt};
use a653rs_linux_core::health::ModuleRecoveryAction;
use anyhow::anyhow;
use clap::Parser;
use hypervisor::config::Config;
use nix::sys::signal::*;

use crate::hypervisor::Hypervisor;

Expand Down Expand Up @@ -161,9 +160,8 @@ macro_rules! problem {

#[cfg(test)]
mod test {
use anyhow::anyhow;

use a653rs_linux_core::error::{SystemError, TypedError, TypedResult};
use anyhow::anyhow;

fn problem_manual() -> TypedResult<()> {
let extra_info = "problem";
Expand Down
3 changes: 1 addition & 2 deletions hypervisor/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#[macro_use]
extern crate log;

use log::LevelFilter;

use a653rs_linux_hypervisor::run_hypervisor;
use log::LevelFilter;

/// Helper to print top-level errors through [log::error]
#[quit::main]
Expand Down
3 changes: 1 addition & 2 deletions partition/src/apex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ use std::thread::sleep;

use a653rs::bindings::*;
use a653rs::prelude::{Name, SystemTime};
use nix::libc::EAGAIN;

use a653rs_linux_core::error::SystemError;
use a653rs_linux_core::queuing::{QueuingDestination, QueuingSource};
use a653rs_linux_core::sampling::{SamplingDestination, SamplingSource};
use nix::libc::EAGAIN;

use crate::partition::ApexLinuxPartition;
use crate::process::Process as LinuxProcess;
Expand Down
6 changes: 2 additions & 4 deletions partition/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ extern crate log;
use std::net::{TcpStream, UdpSocket};
#[cfg(feature = "socket")]
use std::os::fd::FromRawFd;

#[cfg(feature = "socket")]
use a653rs_linux_core::ipc::IoReceiver;

use std::os::fd::{AsRawFd, OwnedFd};
use std::sync::Arc;
use std::time::{Duration, Instant};

use a653rs::prelude::OperatingMode;
use a653rs_linux_core::file::{get_memfd, TempFile};
use a653rs_linux_core::health_event::PartitionCall;
#[cfg(feature = "socket")]
use a653rs_linux_core::ipc::IoReceiver;
use a653rs_linux_core::ipc::{self, IpcSender};
use a653rs_linux_core::partition::*;
use a653rs_linux_core::syscall::SYSCALL_SOCKET_PATH;
Expand Down
2 changes: 0 additions & 2 deletions partition/src/partition.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::cmp::min;

#[cfg(feature = "socket")]
use std::{
fmt::Display,
Expand All @@ -13,7 +12,6 @@ use a653rs_linux_core::health_event::PartitionCall;
use log::{set_logger, set_max_level, LevelFilter, Record, SetLoggerError};

use crate::{CONSTANTS, SENDER};

#[cfg(feature = "socket")]
use crate::{TCP_SOCKETS, UDP_SOCKETS};

Expand Down
5 changes: 2 additions & 3 deletions partition/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ use std::thread::Builder;

use a653rs::bindings::*;
use a653rs::prelude::{ProcessAttribute, SystemTime};
use anyhow::anyhow;
use nix::unistd::{gettid, Pid};

use a653rs_linux_core::cgroup;
use a653rs_linux_core::cgroup::CGroup;
use a653rs_linux_core::error::{
ErrorLevel, LeveledResult, ResultExt, SystemError, TypedResult, TypedResultExt,
};
use a653rs_linux_core::partition::PartitionConstants;
use anyhow::anyhow;
use nix::unistd::{gettid, Pid};

use crate::{APERIODIC_PROCESS, PERIODIC_PROCESS};

Expand Down
8 changes: 3 additions & 5 deletions partition/src/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ use std::io::IoSlice;
use std::num::NonZeroUsize;
use std::os::fd::{AsFd, AsRawFd, BorrowedFd};

use a653rs_linux_core::mfd::{Mfd, Seals};
use a653rs_linux_core::syscall::{SyscallRequest, SyscallResponse};
use anyhow::Result;
use nix::libc::EINTR;
use nix::sys::eventfd::EventFd;
use nix::sys::socket::{sendmsg, ControlMessage, MsgFlags};
use polling::{Event, Events, Poller};

use a653rs_linux_core::mfd::{Mfd, Seals};
use a653rs_linux_core::syscall::{SyscallRequest, SyscallResponse};

use crate::SYSCALL;

/// Sends a vector of file descriptors through a Unix socket
Expand Down Expand Up @@ -84,13 +83,12 @@ mod tests {
use std::io::IoSliceMut;
use std::os::fd::{FromRawFd, OwnedFd, RawFd};

use a653rs_linux_core::syscall::ApexSyscall;
use nix::sys::socket::{
recvmsg, socketpair, AddressFamily, ControlMessageOwned, SockFlag, SockType,
};
use nix::{cmsg_space, unistd};

use a653rs_linux_core::syscall::ApexSyscall;

use super::*;

#[test]
Expand Down
3 changes: 2 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
group_imports = "StdExternalCrate"
imports_granularity = "Module"
imports_granularity = "Module"
wrap_comments = true

0 comments on commit 94e4436

Please sign in to comment.