]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/applayer: use c_int as return type for get_info_by_id 12059/head 12067/head
authorJason Ish <jason.ish@oisf.net>
Tue, 22 Oct 2024 16:46:13 +0000 (10:46 -0600)
committerJason Ish <jason.ish@oisf.net>
Mon, 28 Oct 2024 20:52:04 +0000 (14:52 -0600)
Rust was using i8 as the return type, while C uses int. As of Rust
1.82, the return value is turned to garbage over the FFI boundary.

Ticket: #7338
(cherry picked from commit 45384ef969d180d962f4b50f19556c5e2c5cfccc)

rust/derive/src/applayerevent.rs
rust/src/applayer.rs
rust/src/smb/smb.rs

index 29475fa2d51b596e3ddfbaeda76d0bc0f307612a..990d5e664f8514d379288c2b668e3eb94fec8e25 100644 (file)
@@ -98,7 +98,7 @@ pub fn derive_app_layer_event(input: TokenStream) -> TokenStream {
                 event_id: std::os::raw::c_int,
                 event_name: *mut *const std::os::raw::c_char,
                 event_type: *mut #crate_id::core::AppLayerEventType,
-            ) -> i8 {
+            ) -> std::os::raw::c_int {
                 #crate_id::applayer::get_event_info_by_id::<#name>(event_id, event_name, event_type)
             }
 
index ff19d87632343b33eb84a20d895a2bf474b8de24..113aa238b370231aa7dd5c204accbe4e1f9b6536 100644 (file)
@@ -445,7 +445,7 @@ pub type StateGetTxFn            = unsafe extern "C" fn (*mut c_void, u64) -> *m
 pub type StateGetTxCntFn         = unsafe extern "C" fn (*mut c_void) -> u64;
 pub type StateGetProgressFn = unsafe extern "C" fn (*mut c_void, u8) -> c_int;
 pub type GetEventInfoFn     = unsafe extern "C" fn (*const c_char, *mut c_int, *mut AppLayerEventType) -> c_int;
-pub type GetEventInfoByIdFn = unsafe extern "C" fn (c_int, *mut *const c_char, *mut AppLayerEventType) -> i8;
+pub type GetEventInfoByIdFn = unsafe extern "C" fn (c_int, *mut *const c_char, *mut AppLayerEventType) -> c_int;
 pub type LocalStorageNewFn  = extern "C" fn () -> *mut c_void;
 pub type LocalStorageFreeFn = extern "C" fn (*mut c_void);
 pub type GetTxFilesFn       = unsafe extern "C" fn (*mut c_void, *mut c_void, u8) -> AppLayerGetFileState;
@@ -587,7 +587,7 @@ pub trait AppLayerEvent {
         event_id: std::os::raw::c_int,
         event_name: *mut *const std::os::raw::c_char,
         event_type: *mut core::AppLayerEventType,
-    ) -> i8;
+    ) -> std::os::raw::c_int;
 }
 
 /// Generic `get_info_info` implementation for enums implementing
@@ -631,7 +631,7 @@ pub unsafe fn get_event_info_by_id<T: AppLayerEvent>(
     event_id: std::os::raw::c_int,
     event_name: *mut *const std::os::raw::c_char,
     event_type: *mut core::AppLayerEventType,
-) -> i8 {
+) -> std::os::raw::c_int {
     if let Some(e) = T::from_id(event_id) {
         *event_name = e.to_cstring().as_ptr() as *const std::os::raw::c_char;
         *event_type = core::AppLayerEventType::APP_LAYER_EVENT_TYPE_TRANSACTION;
index e64e0a8e6f0b75854d56d89f4685aa858a4758ce..53058890b1b02e2bccb359390b9cbfe3bafbe1ca 100644 (file)
@@ -2229,7 +2229,7 @@ pub unsafe extern "C" fn rs_smb_state_get_event_info_by_id(
     event_id: std::os::raw::c_int,
     event_name: *mut *const std::os::raw::c_char,
     event_type: *mut AppLayerEventType,
-) -> i8 {
+) -> std::os::raw::c_int {
     SMBEvent::get_event_info_by_id(event_id, event_name, event_type)
 }