]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: fix clippy warnings for version 1.72.0
authorPhilippe Antoine <pantoine@oisf.net>
Wed, 30 Aug 2023 09:24:24 +0000 (11:24 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 4 Sep 2023 15:33:27 +0000 (17:33 +0200)
Includes using the right prototype for C SRepCatGetByShortname

rust/src/applayer.rs
rust/src/detect/byte_math.rs
rust/src/detect/iprep.rs
rust/src/ffi/base64.rs
rust/src/pgsql/parser.rs

index 33fa83a92d006c53fbbc6c2ca4e8fcc3a9197640..255fa1593c2bcf8b4afe06a6b7ca0d9438065d4e 100644 (file)
@@ -44,7 +44,7 @@ impl StreamSlice {
     #[cfg(test)]
     pub fn from_slice(slice: &[u8], flags: u8, offset: u64) -> Self {
         Self {
-            input: slice.as_ptr() as *const u8,
+            input: slice.as_ptr(),
             input_len: slice.len() as u32,
             flags,
             offset
index 0cc60e52bfd705ba4107f418d8b92cf34eb68a3b..80bd3d5ee178bbef5801dc52436081fe887b0618 100644 (file)
@@ -432,7 +432,7 @@ pub unsafe extern "C" fn ScByteMathParse(c_arg: *const c_char) -> *mut DetectByt
         }
     };
     match parse_bytemath(arg) {
-        Ok((_, detect)) => return Box::into_raw(Box::new(detect)) as *mut DetectByteMathData,
+        Ok((_, detect)) => return Box::into_raw(Box::new(detect)),
         Err(_) => return std::ptr::null_mut(),
     }
 }
@@ -440,7 +440,7 @@ pub unsafe extern "C" fn ScByteMathParse(c_arg: *const c_char) -> *mut DetectByt
 #[no_mangle]
 pub unsafe extern "C" fn ScByteMathFree(ptr: *mut DetectByteMathData) {
     if !ptr.is_null() {
-        let _ = Box::from_raw(ptr as *mut DetectByteMathData);
+        let _ = Box::from_raw(ptr);
     }
 }
 
index 4018ea97a45edbd412a1f8945acec802454b1cb2..16f5d9d5d15eaed5ba2a6a79a110f09904f08454 100644 (file)
@@ -24,6 +24,7 @@ use nom7::Err;
 use nom7::IResult;
 
 use std::ffi::{CStr, CString};
+use std::os::raw::c_char;
 use std::str::FromStr;
 
 #[repr(u8)]
@@ -71,7 +72,7 @@ pub fn is_alphanumeric_or_slash(chr: char) -> bool {
 }
 
 extern "C" {
-    pub fn SRepCatGetByShortname(name: *const i8) -> u8;
+    pub fn SRepCatGetByShortname(name: *const c_char) -> u8;
 }
 
 pub fn detect_parse_iprep(i: &str) -> IResult<&str, DetectIPRepData> {
@@ -84,7 +85,7 @@ pub fn detect_parse_iprep(i: &str) -> IResult<&str, DetectIPRepData> {
     let (i, name) = take_while(is_alphanumeric_or_slash)(i)?;
     // copy as to have final zero
     let namez = CString::new(name).unwrap();
-    let cat = unsafe { SRepCatGetByShortname(namez.as_ptr() as *const i8) };
+    let cat = unsafe { SRepCatGetByShortname(namez.as_ptr()) };
     if cat == 0 {
         return Err(Err::Error(make_error(i, ErrorKind::MapOpt)));
     }
index 0019a6ff2b6f1e8f9ccd27fe91d34f96e4363820..ea72a344c393cb327b768c01be38446635dc36e2 100644 (file)
@@ -46,7 +46,7 @@ pub unsafe extern "C" fn Base64Encode(
     if encoded.len() + 1 > *output_len as usize {
         return Base64ReturnCode::SC_BASE64_OVERFLOW;
     }
-    let output = std::slice::from_raw_parts_mut(&mut *(output as *mut u8), *output_len as usize);
+    let output = std::slice::from_raw_parts_mut(&mut *output, *output_len as usize);
     output[0..encoded.len()].copy_from_slice(encoded.as_bytes());
     output[encoded.len()] = 0;
     *output_len = encoded.len() as c_ulong;
index bb1a9ea09e3539cb91c4116b66fd8c6480460a61..ae07d5d5a0788400ccb1c2ff4eec705614baa893 100644 (file)
@@ -593,7 +593,7 @@ pub fn pgsql_parse_startup_packet(i: &[u8]) -> IResult<&[u8], PgsqlFEMessage> {
     let (i, b) = take(len - PGSQL_LENGTH_FIELD)(i)?;
     let (_, message) =
         match proto_major {
-            1 | 2 | 3 => {
+            1..=3 => {
                 let (b, proto_major) = be_u16(b)?;
                 let (b, proto_minor) = be_u16(b)?;
                 let (b, params) = pgsql_parse_startup_parameters(b)?;