Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Code formatting #54

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on: [push, pull_request]

name: Code formatting check

jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
3 changes: 2 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ fn main() {
fs::copy(
format!("bin/{}.a", target),
out_dir.join(format!("lib{}.a", name)),
).unwrap();
)
.unwrap();

println!("cargo:rustc-link-lib=static={}", name);
println!("cargo:rustc-link-search={}", out_dir.display());
Expand Down
9 changes: 3 additions & 6 deletions src/hio.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Host I/O

use core::{fmt, slice};
use crate::nr;
use core::{fmt, slice};

/// Host's standard error
#[derive(Clone, Copy)]
Expand Down Expand Up @@ -57,8 +57,7 @@ pub fn hstdout() -> Result<HStdout, ()> {

fn open(name: &str, mode: usize) -> Result<usize, ()> {
let name = name.as_bytes();
match unsafe { syscall!(OPEN, name.as_ptr(), mode, name.len() - 1) } as
isize {
match unsafe { syscall!(OPEN, name.as_ptr(), mode, name.len() - 1) } as isize {
-1 => Err(()),
fd => Ok(fd as usize),
}
Expand All @@ -72,9 +71,7 @@ fn write_all(fd: usize, mut buffer: &[u8]) -> Result<(), ()> {
// `n` bytes were not written
n if n <= buffer.len() => {
let offset = (buffer.len() - n) as isize;
buffer = unsafe {
slice::from_raw_parts(buffer.as_ptr().offset(offset), n)
}
buffer = unsafe { slice::from_raw_parts(buffer.as_ptr().offset(offset), n) }
}
#[cfg(feature = "jlink-quirks")]
// Error (-1) - should be an error but JLink can return -1, -2, -3,...
Expand Down
9 changes: 5 additions & 4 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ macro_rules! syscall {
$crate::syscall($crate::nr::$nr, &[$a1 as usize, $a2 as usize])
};
($nr:ident, $a1:expr, $a2:expr, $a3:expr) => {
$crate::syscall($crate::nr::$nr, &[$a1 as usize, $a2 as usize,
$a3 as usize])
$crate::syscall($crate::nr::$nr, &[$a1 as usize, $a2 as usize, $a3 as usize])
};
($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr) => {
$crate::syscall($crate::nr::$nr, &[$a1 as usize, $a2 as usize,
$a3 as usize, $a4 as usize])
$crate::syscall(
$crate::nr::$nr,
&[$a1 as usize, $a2 as usize, $a3 as usize, $a4 as usize],
)
};
}

Expand Down