pub(super) unsafe extern "C" fn get_alstate_progress(tx: *mut std::os::raw::c_void, direction: u8
)-> std::os::raw::c_int {
let tx = cast_pointer!(tx, DCERPCTransaction);
- if direction == Direction::ToServer.into() && tx.req_done {
+ if direction == u8::from(Direction::ToServer) && tx.req_done {
SCLogDebug!("tx {} TOSERVER progress 1 => {:?}", tx.call_id, tx);
return 1;
- } else if direction == Direction::ToClient.into() && tx.resp_done {
+ } else if direction == u8::from(Direction::ToClient) && tx.resp_done {
SCLogDebug!("tx {} TOCLIENT progress 1 => {:?}", tx.call_id, tx);
return 1;
}
let mult = val
.parse::<u32>()
.map_err(|_| make_error(format!("invalid multiplier value: {}", val)))?;
- if mult == 0 || mult > u16::MAX.into() {
+ if mult == 0 || mult > u32::from(u16::MAX) {
return Err(make_error(format!(
"invalid multiplier value: must be between 0 and {}: {}",
u16::MAX,
let (_, res) = parse_var(val)?;
match res {
ResultValue::Numeric(val) => {
- if val >= u32::MIN.into() && val <= u32::MAX.into() {
+ if val >= u64::from(u32::MIN) && val <= u64::from(u32::MAX) {
byte_math.rvalue = val as u32
} else {
return Err(make_error(format!(
let (_, res) = parse_var(val)?;
match res {
ResultValue::Numeric(val) => {
- if val <= u16::MAX.into() {
+ if val <= u64::from(u16::MAX) {
transform_base64.offset = val as u32
} else {
return Err(make_error(format!(
let (_, res) = parse_var(val)?;
match res {
ResultValue::Numeric(val) => {
- if val as u32 <= u16::MAX.into() {
+ if val as u32 <= u32::from(u16::MAX) {
transform_base64.nbytes = val as u32
} else {
return Err(make_error(format!(
SCLogError!("XOR transform key's length must be an even number");
return None;
}
- if i.len() / 2 > u8::MAX.into() {
+ if i.len() / 2 > usize::from(u8::MAX) {
SCLogError!("Key length too big for XOR transform");
return None;
}
} else {
Direction::ToClient
};
- if (direction & DIR_BOTH) != dir.into() {
+ if (direction & DIR_BOTH) != u8::from(dir) {
*rdir = dir as u8;
}
return ALPROTO_DNS;
match &req.payload {
EnipCipRequestPayload::GetAttributeList(ga) => {
for attrg in ga.attr_list.iter() {
- if attr == (*attrg).into() {
+ if attr == u32::from(*attrg) {
return 1;
}
}
}
EnipCipRequestPayload::SetAttributeList(sa) => {
if let Some(val) = sa.first_attr {
- if attr == val.into() {
+ if attr == u32::from(val) {
return 1;
}
}
pub unsafe extern "C" fn rs_http2_tx_get_cookie(
tx: &mut HTTP2Transaction, direction: u8, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
- if direction == Direction::ToServer.into() {
+ if direction == u8::from(Direction::ToServer) {
if let Ok(value) = http2_frames_get_header_value(tx, Direction::ToServer, "cookie") {
*buffer = value.as_ptr(); //unsafe
*buffer_len = value.len() as u32;
let (i, spi_size) = be_u8(i)?;
let (i, number_transforms) = be_u8(i)?;
let (i, spi) = take(spi_size as usize)(i)?;
- let (i, payload_data) = cond((start_i.len() - 4) >= spi_size.into(), |b| {
+ let (i, payload_data) = cond((start_i.len() - 4) >= usize::from(spi_size), |b| {
take((start_i.len() - 4) - spi_size as usize)(b)
})(i)?;
let payload = ProposalPayload {
) {
if !ctx.filename.is_empty() {
*buffer = ctx.filename.as_ptr();
- if ctx.filename.len() < u16::MAX.into() {
+ if ctx.filename.len() < usize::from(u16::MAX) {
*filename_len = ctx.filename.len() as u16;
} else {
*filename_len = u16::MAX;
) {
if !ctx.filename.is_empty() {
*buffer = ctx.filename.as_ptr();
- if ctx.filename.len() < u16::MAX.into() {
+ if ctx.filename.len() < usize::from(u16::MAX) {
*filename_len = ctx.filename.len() as u16;
} else {
*filename_len = u16::MAX;
-> std::os::raw::c_int
{
let tx = cast_pointer!(tx, NFSTransaction);
- if direction == Direction::ToServer.into() && tx.request_done {
+ if direction == u8::from(Direction::ToServer) && tx.request_done {
SCLogDebug!("TOSERVER progress 1");
return 1;
- } else if direction == Direction::ToClient.into() && tx.response_done {
+ } else if direction == u8::from(Direction::ToClient) && tx.response_done {
SCLogDebug!("TOCLIENT progress 1");
return 1;
} else {
let mut adirection : u8 = 0;
match nfs_probe_dir(slice, &mut adirection) {
1 => {
- if adirection == Direction::ToServer.into() {
+ if adirection == u8::from(Direction::ToServer) {
SCLogDebug!("nfs_probe_dir said Direction::ToServer");
} else {
SCLogDebug!("nfs_probe_dir said Direction::ToClient");
if offset < tdf.file_tracker.tracked {
set_event_fileoverlap = true;
}
- if max_queue_size != 0 && tdf.file_tracker.get_inflight_size() + rd.len as u64 > max_queue_size.into() {
+ if max_queue_size != 0 && tdf.file_tracker.get_inflight_size() + rd.len as u64 > u64::from(max_queue_size) {
state.set_event(SMBEvent::ReadQueueSizeExceeded);
state.set_skip(Direction::ToClient, nbss_remaining);
} else if max_queue_cnt != 0 && tdf.file_tracker.get_inflight_cnt() >= max_queue_cnt as usize {
if offset < tdf.file_tracker.tracked {
set_event_fileoverlap = true;
}
- if max_queue_size != 0 && tdf.file_tracker.get_inflight_size() + rd.len as u64 > max_queue_size.into() {
+ if max_queue_size != 0 && tdf.file_tracker.get_inflight_size() + rd.len as u64 > u64::from(max_queue_size) {
state.set_event(SMBEvent::ReadQueueSizeExceeded);
state.set_skip(Direction::ToClient, nbss_remaining);
} else if max_queue_cnt != 0 && tdf.file_tracker.get_inflight_cnt() >= max_queue_cnt as usize {
if wr.wr_offset < tdf.file_tracker.tracked {
set_event_fileoverlap = true;
}
- if max_queue_size != 0 && tdf.file_tracker.get_inflight_size() + wr.wr_len as u64 > max_queue_size.into() {
+ if max_queue_size != 0 && tdf.file_tracker.get_inflight_size() + wr.wr_len as u64 > u64::from(max_queue_size) {
state.set_event(SMBEvent::WriteQueueSizeExceeded);
state.set_skip(Direction::ToServer, nbss_remaining);
} else if max_queue_cnt != 0 && tdf.file_tracker.get_inflight_cnt() >= max_queue_cnt as usize {
set_event_fileoverlap = true;
}
- if max_queue_size != 0 && tdf.file_tracker.get_inflight_size() + wr.wr_len as u64 > max_queue_size.into() {
+ if max_queue_size != 0 && tdf.file_tracker.get_inflight_size() + wr.wr_len as u64 > u64::from(max_queue_size) {
state.set_event(SMBEvent::WriteQueueSizeExceeded);
state.set_skip(Direction::ToServer, nbss_remaining);
} else if max_queue_cnt != 0 && tdf.file_tracker.get_inflight_cnt() >= max_queue_cnt as usize {
let record: Smb2CreateRequestRecord = result.1;
assert_eq!(record.disposition, 2); // FILE_CREATE: 2
assert_eq!(record.create_options, 0x200021);
- assert_eq!(record.data, &[]);
+ assert_eq!(record.data, &[] as &[u8]);
let del = record.create_options & 0x0000_1000 != 0;
let dir = record.create_options & 0x0000_0001 != 0;
assert!(!del);
);
assert!(!record.is_pipe);
assert_eq!(record.function, 0x1401fc);
- assert_eq!(record.data, &[]);
+ assert_eq!(record.data, &[] as &[u8]);
}
}
tx: *mut std::os::raw::c_void, direction: u8,
) -> SSHConnectionState {
let tx = cast_pointer!(tx, SSHTransaction);
- if direction == Direction::ToServer.into() {
+ if direction == u8::from(Direction::ToServer) {
return tx.cli_hdr.flags;
} else {
return tx.srv_hdr.flags;
return SSHConnectionState::SshStateFinished as i32;
}
- if direction == Direction::ToServer.into() {
+ if direction == u8::from(Direction::ToServer) {
if tx.cli_hdr.flags >= SSHConnectionState::SshStateBannerDone {
return SSHConnectionState::SshStateBannerDone as i32;
}
};
// we limit payload_len to u32, so as to build on 32-bit system
// where we cannot take(usize) with a u64
- let (to_skip, payload_len) = if payload_len < max_pl_size.into() {
+ let (to_skip, payload_len) = if payload_len < u64::from(max_pl_size) {
(0, payload_len as u32)
} else {
(payload_len - (max_pl_size as u64), max_pl_size)
if let Ok(Some(sans)) = san_list {
// SAN length in a certificate is kept u16 following discussions at
// https://community.letsencrypt.org/t/why-sans-are-limited-to-100-domains-only
- debug_validate_bug_on!(sans.value.general_names.len() == u16::MAX.into());
+ debug_validate_bug_on!(sans.value.general_names.len() == usize::from(u16::MAX));
return sans.value.general_names.len() as u16;
}
return 0;