From: Jason Ish Date: Wed, 9 Apr 2025 16:45:50 +0000 (-0600) Subject: rust: fix clippy warnings for unspecified extern ABI X-Git-Tag: suricata-7.0.11~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1504dcea4ab50a8d973b2fe81e8fb2be49d21fd6;p=thirdparty%2Fsuricata.git rust: fix clippy warnings for unspecified extern ABI Fix done by clippy --fix. Ticket: #7652 --- diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index 023d169585..da36b6cf04 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -475,7 +475,7 @@ pub type GetFrameNameById = unsafe extern "C" fn(u8) -> *const c_char; // Defined in app-layer-register.h /// cbindgen:ignore -extern { +extern "C" { pub fn AppLayerRegisterProtocolDetection(parser: *const RustParser, enable_default: c_int) -> AppProto; pub fn AppLayerRegisterParserAlias(parser_name: *const c_char, alias_name: *const c_char); } @@ -487,7 +487,7 @@ pub unsafe fn AppLayerRegisterParser(parser: *const RustParser, alproto: AppProt // Defined in app-layer-detect-proto.h /// cbindgen:ignore -extern { +extern "C" { pub fn AppLayerProtoDetectPPRegister(ipproto: u8, portstr: *const c_char, alproto: AppProto, min_depth: u16, max_depth: u16, dir: u8, pparser1: ProbeFn, pparser2: ProbeFn); @@ -522,7 +522,7 @@ pub const APP_LAYER_PARSER_OPT_ACCEPT_GAPS: u32 = BIT_U32!(0); pub const APP_LAYER_TX_SKIP_INSPECT_FLAG: u64 = BIT_U64!(62); /// cbindgen:ignore -extern { +extern "C" { pub fn AppLayerParserStateSetFlag(state: *mut c_void, flag: u16); pub fn AppLayerParserStateIssetFlag(state: *mut c_void, flag: u16) -> u16; pub fn AppLayerParserSetStreamDepth(ipproto: u8, alproto: AppProto, stream_depth: u32); diff --git a/rust/src/conf.rs b/rust/src/conf.rs index 50cc072570..9ef58747eb 100644 --- a/rust/src/conf.rs +++ b/rust/src/conf.rs @@ -32,7 +32,7 @@ use nom7::{ }; /// cbindgen:ignore -extern { +extern "C" { fn ConfGet(key: *const c_char, res: *mut *const c_char) -> i8; fn ConfGetChildValue(conf: *const c_void, key: *const c_char, vptr: *mut *const c_char) -> i8; @@ -141,7 +141,6 @@ impl ConfNode { } return false; } - } const BYTE: u64 = 1; diff --git a/rust/src/core.rs b/rust/src/core.rs index 61d391e11b..be164e6734 100644 --- a/rust/src/core.rs +++ b/rust/src/core.rs @@ -129,7 +129,7 @@ pub const FLOW_DIR_REVERSED: u32 = BIT_U32!(26); // Defined in app-layer-protos.h /// cbindgen:ignore -extern { +extern "C" { pub fn StringToAppProto(proto_name: *const u8) -> AppProto; } @@ -224,7 +224,7 @@ pub struct SuricataContext { pub FileAppendGAP: SCFileAppendGAPById, pub FileContainerRecycle: SCFileContainerRecycle, - pub AppLayerRegisterParser: extern fn(parser: *const crate::applayer::RustParser, alproto: AppProto) -> std::os::raw::c_int, + pub AppLayerRegisterParser: extern "C" fn(parser: *const crate::applayer::RustParser, alproto: AppProto) -> std::os::raw::c_int, } #[allow(non_snake_case)] @@ -234,7 +234,7 @@ pub struct SuricataFileContext { } /// cbindgen:ignore -extern { +extern "C" { pub fn SCGetContext() -> &'static mut SuricataContext; pub fn SCLogGetLogLevel() -> i32; } @@ -301,7 +301,7 @@ pub enum Flow {} // Extern functions operating on Flow. /// cbindgen:ignore -extern { +extern "C" { pub fn FlowGetLastTimeAsParts(flow: &Flow, secs: *mut u64, usecs: *mut u64); pub fn FlowGetFlags(flow: &Flow) -> u32; pub fn FlowGetSourcePort(flow: &Flow) -> u16; diff --git a/rust/src/filecontainer.rs b/rust/src/filecontainer.rs index 28d10cf05c..2db0b40cc6 100644 --- a/rust/src/filecontainer.rs +++ b/rust/src/filecontainer.rs @@ -24,7 +24,7 @@ use crate::core::*; // Defined in util-file.h /// cbindgen:ignore -extern { +extern "C" { pub fn FileFlowFlagsToFlags(flow_file_flags: u16, flags: u8) -> u16; } diff --git a/rust/src/frames.rs b/rust/src/frames.rs index 3496caa694..b1208daddb 100644 --- a/rust/src/frames.rs +++ b/rust/src/frames.rs @@ -31,7 +31,7 @@ struct CFrame { // Defined in app-layer-register.h /// cbindgen:ignore -extern { +extern "C" { #[cfg(not(test))] fn AppLayerFrameNewByRelativeOffset( flow: *const Flow, stream_slice: *const StreamSlice, frame_start_rel: u32, len: i64, diff --git a/rust/src/lua.rs b/rust/src/lua.rs index a8cfc74175..2f5ddc4ff9 100644 --- a/rust/src/lua.rs +++ b/rust/src/lua.rs @@ -31,7 +31,7 @@ type LuaInteger = i32; pub enum CLuaState {} /// cbindgen:ignore -extern { +extern "C" { fn lua_createtable(lua: *mut CLuaState, narr: c_int, nrec: c_int); fn lua_settable(lua: *mut CLuaState, idx: c_long); fn lua_pushlstring(lua: *mut CLuaState, s: *const c_char, len: usize);