rust: fix clippy warnings for version 1.72.0

Includes using the right prototype for C SRepCatGetByShortname
pull/9438/head
Philippe Antoine 2 years ago committed by Victor Julien
parent a284f01c1d
commit b235e85c68

@ -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

@ -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);
}
}

@ -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)));
}

@ -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;

@ -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)?;

Loading…
Cancel
Save