From d03d027a542d8610bafa9b30a2a68119a49d25ea Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Wed, 4 Oct 2023 21:52:07 +0200 Subject: [PATCH] cleanup --- Cargo.toml | 1 + rawc/Cargo.toml | 2 +- rawc/src/lib.rs | 3 ++- rawc/src/stdio.rs | 6 +++--- shell.nix | 1 + test_c.sh | 6 +++--- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dd2f850..dc4cd00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,4 @@ panic = "abort" [profile.release] panic = "abort" +lto = "thin" diff --git a/rawc/Cargo.toml b/rawc/Cargo.toml index c54d76a..5bbd979 100644 --- a/rawc/Cargo.toml +++ b/rawc/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] -crate-type = ["staticlib", "rlib"] +crate-type = ["staticlib", "rlib", "cdylib"] [dependencies] diff --git a/rawc/src/lib.rs b/rawc/src/lib.rs index 266853b..9528bfd 100644 --- a/rawc/src/lib.rs +++ b/rawc/src/lib.rs @@ -2,6 +2,7 @@ #![feature(c_variadic)] #![feature(panic_info_message)] #![deny(clippy::no_mangle_with_rust_abi)] +#![warn(rust_2018_idioms)] mod rt; mod stdio; @@ -19,7 +20,7 @@ fn rust_eh_personality() { #[panic_handler] #[cfg(not(test))] -fn handler(arg: &core::panic::PanicInfo) -> ! { +fn handler(arg: &core::panic::PanicInfo<'_>) -> ! { let args = format_args!(""); let payload = arg.message().unwrap_or(&args); libuwuc::io::println!("panicked: {payload}"); diff --git a/rawc/src/stdio.rs b/rawc/src/stdio.rs index b2c8295..ab301b2 100644 --- a/rawc/src/stdio.rs +++ b/rawc/src/stdio.rs @@ -14,7 +14,7 @@ pub unsafe extern "C" fn puts(s: *const c_char) -> i32 { // RAW FD: #[no_mangle] -pub unsafe extern "C" fn open(path: SharedThinCstr, flags: i32) -> Fd { +pub unsafe extern "C" fn open(path: SharedThinCstr<'_>, flags: i32) -> Fd { libuwuc::io::fd::open(path, flags).into_ok_or_errno() } @@ -88,8 +88,8 @@ pub static stderr: &FileStream = &FileStream::from_raw_fd(STDERR); #[no_mangle] pub unsafe extern "C" fn fopen<'a>( - pathname: SharedThinCstr, - mode: SharedThinCstr, + pathname: SharedThinCstr<'_>, + mode: SharedThinCstr<'_>, ) -> Option<&'a FileStream> { libuwuc::io::stream::fopen(pathname, mode) .map_err(|err| libuwuc::error::set_errno(err.0)) diff --git a/shell.nix b/shell.nix index a14e770..ca7b3d9 100644 --- a/shell.nix +++ b/shell.nix @@ -10,5 +10,6 @@ packages = (with pkgs; [ gef rust-bindgen + shellcheck ]); } diff --git a/test_c.sh b/test_c.sh index ef33428..aaca2a8 100755 --- a/test_c.sh +++ b/test_c.sh @@ -11,8 +11,8 @@ clean() { } for test in "$SCRIPT_DIR"/tests/c/*; do - name=$(basename $test .c) - printf "test $name " + name=$(basename "$test" .c) + printf "test %s " "$test" flags=$(grep "//@flags: " "$test" | sed 's#//@flags: ##') @@ -31,7 +31,7 @@ for test in "$SCRIPT_DIR"/tests/c/*; do exit 1 fi - cd "$SCRIPT_DIR/tests" + cd "$SCRIPT_DIR/tests" || exit 1 OUTPUT=$("$test_dir/$name") code="$?" if [ "$code" -ne "0" ]; then