From 5eaa898e46ccb32951704f0a290603971e62a88b Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Mon, 11 Dec 2023 10:15:03 -0800 Subject: [PATCH] chore(*) add linting to ngx-wasm-rs crate & fix warnings Fix #268 --- .github/workflows/ci.yml | 4 +++- lib/ngx-wasm-rs/lib/wat/src/lib.rs | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 724bae31e..3d74f2a2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -234,7 +234,9 @@ jobs: - run: make lint - name: 'Rust lint' if: ${{ !env.ACT }} - run: cargo clippy --all-features + run: | + cargo clippy --all-features + cd lib/ngx-wasm-rs && cargo clippy --all-features - run: | if [[ $(make reindex 2>&1 | tee reindex.out | grep -c done) -gt 0 ]]; then cat reindex.out >&2 diff --git a/lib/ngx-wasm-rs/lib/wat/src/lib.rs b/lib/ngx-wasm-rs/lib/wat/src/lib.rs index 91cdec419..077ef0bd3 100644 --- a/lib/ngx-wasm-rs/lib/wat/src/lib.rs +++ b/lib/ngx-wasm-rs/lib/wat/src/lib.rs @@ -2,7 +2,6 @@ use ngx_wasm_c_api::*; use regex::Regex; use std::mem; use unescape::unescape; -use wabt; #[macro_use] extern crate lazy_static; @@ -23,7 +22,7 @@ fn extract_message(err: &str) -> Option { } } -fn vec_into_wasm_byte_vec_t(bv: *mut wasm_byte_vec_t, v: Vec) -> () { +fn vec_into_wasm_byte_vec_t(bv: *mut wasm_byte_vec_t, v: Vec) { unsafe { // FIXME Update this when vec_into_raw_parts is stabilized let mut v = mem::ManuallyDrop::new(v); @@ -32,8 +31,11 @@ fn vec_into_wasm_byte_vec_t(bv: *mut wasm_byte_vec_t, v: Vec) -> () { } } +/// # Safety +/// +/// This function should be called with a valid wat wasm_byte_vec_t pointer. #[no_mangle] -pub extern "C" fn ngx_wasm_wat_to_wasm( +pub unsafe extern "C" fn ngx_wasm_wat_to_wasm( wat: *const wasm_byte_vec_t, wasm: *mut wasm_byte_vec_t, ) -> Option> {