From: Philippe Antoine Date: Mon, 17 Jun 2024 13:53:42 +0000 (+0200) Subject: rust: remove unnecessary nested unsafe X-Git-Tag: suricata-8.0.0-beta1~1151 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5bb5b4f46f08dd1fae744d8822ff29f621586793;p=thirdparty%2Fsuricata.git rust: remove unnecessary nested unsafe --- diff --git a/rust/src/dhcp/detect.rs b/rust/src/dhcp/detect.rs index 73cf925386..7c458da4e9 100644 --- a/rust/src/dhcp/detect.rs +++ b/rust/src/dhcp/detect.rs @@ -175,15 +175,13 @@ pub unsafe extern "C" fn ScDetectDHCPRegister() { Free: Some(dhcp_detect_time_free), flags: 0, }; - unsafe { - G_DHCP_LEASE_TIME_KW_ID = DetectHelperKeywordRegister(&kw); - G_DHCP_LEASE_TIME_BUFFER_ID = DetectHelperBufferRegister( - b"dhcp.leasetime\0".as_ptr() as *const libc::c_char, - ALPROTO_DHCP, - true, - true, - ); - } + G_DHCP_LEASE_TIME_KW_ID = DetectHelperKeywordRegister(&kw); + G_DHCP_LEASE_TIME_BUFFER_ID = DetectHelperBufferRegister( + b"dhcp.leasetime\0".as_ptr() as *const libc::c_char, + ALPROTO_DHCP, + true, + true, + ); let kw = SCSigTableElmt { name: b"dhcp.rebinding_time\0".as_ptr() as *const libc::c_char, desc: b"match DHCP rebinding time\0".as_ptr() as *const libc::c_char, @@ -193,15 +191,13 @@ pub unsafe extern "C" fn ScDetectDHCPRegister() { Free: Some(dhcp_detect_time_free), flags: 0, }; - unsafe { - G_DHCP_REBINDING_TIME_KW_ID = DetectHelperKeywordRegister(&kw); - G_DHCP_REBINDING_TIME_BUFFER_ID = DetectHelperBufferRegister( - b"dhcp.rebinding-time\0".as_ptr() as *const libc::c_char, - ALPROTO_DHCP, - true, - true, - ); - } + G_DHCP_REBINDING_TIME_KW_ID = DetectHelperKeywordRegister(&kw); + G_DHCP_REBINDING_TIME_BUFFER_ID = DetectHelperBufferRegister( + b"dhcp.rebinding-time\0".as_ptr() as *const libc::c_char, + ALPROTO_DHCP, + true, + true, + ); let kw = SCSigTableElmt { name: b"dhcp.renewal_time\0".as_ptr() as *const libc::c_char, desc: b"match DHCP renewal time\0".as_ptr() as *const libc::c_char, @@ -211,13 +207,11 @@ pub unsafe extern "C" fn ScDetectDHCPRegister() { Free: Some(dhcp_detect_time_free), flags: 0, }; - unsafe { - G_DHCP_RENEWAL_TIME_KW_ID = DetectHelperKeywordRegister(&kw); - G_DHCP_RENEWAL_TIME_BUFFER_ID = DetectHelperBufferRegister( - b"dhcp.renewal-time\0".as_ptr() as *const libc::c_char, - ALPROTO_DHCP, - true, - true, - ); - } + G_DHCP_RENEWAL_TIME_KW_ID = DetectHelperKeywordRegister(&kw); + G_DHCP_RENEWAL_TIME_BUFFER_ID = DetectHelperBufferRegister( + b"dhcp.renewal-time\0".as_ptr() as *const libc::c_char, + ALPROTO_DHCP, + true, + true, + ); } diff --git a/rust/src/enip/detect.rs b/rust/src/enip/detect.rs index dde0af841f..46361680a9 100644 --- a/rust/src/enip/detect.rs +++ b/rust/src/enip/detect.rs @@ -1343,15 +1343,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(cipservice_free), flags: 0, }; - unsafe { - G_ENIP_CIPSERVICE_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_CIPSERVICE_BUFFER_ID = DetectHelperBufferRegister( - b"cip\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_CIPSERVICE_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_CIPSERVICE_BUFFER_ID = DetectHelperBufferRegister( + b"cip\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.capabilities\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP capabilities\0".as_ptr() as *const libc::c_char, @@ -1361,15 +1359,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(capabilities_free), flags: 0, }; - unsafe { - G_ENIP_CAPABILITIES_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_CAPABILITIES_BUFFER_ID = DetectHelperBufferRegister( - b"enip.capabilities\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_CAPABILITIES_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_CAPABILITIES_BUFFER_ID = DetectHelperBufferRegister( + b"enip.capabilities\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.cip_attribute\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP cip_attribute\0".as_ptr() as *const libc::c_char, @@ -1379,15 +1375,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(cip_attribute_free), flags: 0, }; - unsafe { - G_ENIP_CIP_ATTRIBUTE_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_CIP_ATTRIBUTE_BUFFER_ID = DetectHelperBufferRegister( - b"enip.cip_attribute\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_CIP_ATTRIBUTE_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_CIP_ATTRIBUTE_BUFFER_ID = DetectHelperBufferRegister( + b"enip.cip_attribute\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.cip_class\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP cip_class\0".as_ptr() as *const libc::c_char, @@ -1397,15 +1391,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(cip_class_free), flags: 0, }; - unsafe { - G_ENIP_CIP_CLASS_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_CIP_CLASS_BUFFER_ID = DetectHelperBufferRegister( - b"enip.cip_class\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_CIP_CLASS_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_CIP_CLASS_BUFFER_ID = DetectHelperBufferRegister( + b"enip.cip_class\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.vendor_id\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP vendor_id\0".as_ptr() as *const libc::c_char, @@ -1415,15 +1407,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(vendor_id_free), flags: 0, }; - unsafe { - G_ENIP_VENDOR_ID_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_VENDOR_ID_BUFFER_ID = DetectHelperBufferRegister( - b"enip.vendor_id\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_VENDOR_ID_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_VENDOR_ID_BUFFER_ID = DetectHelperBufferRegister( + b"enip.vendor_id\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.status\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP status\0".as_ptr() as *const libc::c_char, @@ -1433,15 +1423,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(status_free), flags: 0, }; - unsafe { - G_ENIP_STATUS_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_STATUS_BUFFER_ID = DetectHelperBufferRegister( - b"enip.status\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_STATUS_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_STATUS_BUFFER_ID = DetectHelperBufferRegister( + b"enip.status\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.state\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP state\0".as_ptr() as *const libc::c_char, @@ -1451,15 +1439,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(state_free), flags: 0, }; - unsafe { - G_ENIP_STATE_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_STATE_BUFFER_ID = DetectHelperBufferRegister( - b"enip.state\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_STATE_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_STATE_BUFFER_ID = DetectHelperBufferRegister( + b"enip.state\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.serial\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP serial\0".as_ptr() as *const libc::c_char, @@ -1469,15 +1455,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(serial_free), flags: 0, }; - unsafe { - G_ENIP_SERIAL_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_SERIAL_BUFFER_ID = DetectHelperBufferRegister( - b"enip.serial\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_SERIAL_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_SERIAL_BUFFER_ID = DetectHelperBufferRegister( + b"enip.serial\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.revision\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP revision\0".as_ptr() as *const libc::c_char, @@ -1487,15 +1471,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(revision_free), flags: 0, }; - unsafe { - G_ENIP_REVISION_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_REVISION_BUFFER_ID = DetectHelperBufferRegister( - b"enip.revision\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_REVISION_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_REVISION_BUFFER_ID = DetectHelperBufferRegister( + b"enip.revision\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.protocol_version\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP protocol_version\0".as_ptr() as *const libc::c_char, @@ -1505,15 +1487,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(protocol_version_free), flags: 0, }; - unsafe { - G_ENIP_PROTOCOL_VERSION_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_PROTOCOL_VERSION_BUFFER_ID = DetectHelperBufferRegister( - b"enip.protocol_version\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_PROTOCOL_VERSION_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_PROTOCOL_VERSION_BUFFER_ID = DetectHelperBufferRegister( + b"enip.protocol_version\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.product_code\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP product_code\0".as_ptr() as *const libc::c_char, @@ -1523,15 +1503,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(product_code_free), flags: 0, }; - unsafe { - G_ENIP_PRODUCT_CODE_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_PRODUCT_CODE_BUFFER_ID = DetectHelperBufferRegister( - b"enip.product_code\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_PRODUCT_CODE_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_PRODUCT_CODE_BUFFER_ID = DetectHelperBufferRegister( + b"enip.product_code\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip_command\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP command\0".as_ptr() as *const libc::c_char, @@ -1541,15 +1519,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(command_free), flags: 0, }; - unsafe { - G_ENIP_COMMAND_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_COMMAND_BUFFER_ID = DetectHelperBufferRegister( - b"enip.command\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_COMMAND_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_COMMAND_BUFFER_ID = DetectHelperBufferRegister( + b"enip.command\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.identity_status\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP identity_status\0".as_ptr() as *const libc::c_char, @@ -1559,15 +1535,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(identity_status_free), flags: 0, }; - unsafe { - G_ENIP_IDENTITY_STATUS_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_IDENTITY_STATUS_BUFFER_ID = DetectHelperBufferRegister( - b"enip.identity_status\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_IDENTITY_STATUS_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_IDENTITY_STATUS_BUFFER_ID = DetectHelperBufferRegister( + b"enip.identity_status\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.device_type\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP device_type\0".as_ptr() as *const libc::c_char, @@ -1577,15 +1551,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(device_type_free), flags: 0, }; - unsafe { - G_ENIP_DEVICE_TYPE_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_DEVICE_TYPE_BUFFER_ID = DetectHelperBufferRegister( - b"enip.device_type\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_DEVICE_TYPE_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_DEVICE_TYPE_BUFFER_ID = DetectHelperBufferRegister( + b"enip.device_type\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip_command\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP command\0".as_ptr() as *const libc::c_char, @@ -1595,15 +1567,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(command_free), flags: 0, }; - unsafe { - G_ENIP_COMMAND_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_COMMAND_BUFFER_ID = DetectHelperBufferRegister( - b"enip.command\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_COMMAND_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_COMMAND_BUFFER_ID = DetectHelperBufferRegister( + b"enip.command\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.cip_status\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP cip_status\0".as_ptr() as *const libc::c_char, @@ -1613,15 +1583,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(cip_status_free), flags: 0, }; - unsafe { - G_ENIP_CIP_STATUS_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_CIP_STATUS_BUFFER_ID = DetectHelperBufferRegister( - b"enip.cip_status\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_CIP_STATUS_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_CIP_STATUS_BUFFER_ID = DetectHelperBufferRegister( + b"enip.cip_status\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.cip_instance\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP cip_instance\0".as_ptr() as *const libc::c_char, @@ -1631,15 +1599,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(cip_instance_free), flags: 0, }; - unsafe { - G_ENIP_CIP_INSTANCE_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_CIP_INSTANCE_BUFFER_ID = DetectHelperBufferRegister( - b"enip.cip_instance\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_CIP_INSTANCE_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_CIP_INSTANCE_BUFFER_ID = DetectHelperBufferRegister( + b"enip.cip_instance\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.cip_extendedstatus\0".as_ptr() as *const libc::c_char, desc: b"rules for detecting EtherNet/IP cip_extendedstatus\0".as_ptr() @@ -1650,15 +1616,13 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { Free: Some(cip_extendedstatus_free), flags: 0, }; - unsafe { - G_ENIP_CIP_EXTENDEDSTATUS_KW_ID = DetectHelperKeywordRegister(&kw); - G_ENIP_CIP_EXTENDEDSTATUS_BUFFER_ID = DetectHelperBufferRegister( - b"enip.cip_extendedstatus\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - ); - } + G_ENIP_CIP_EXTENDEDSTATUS_KW_ID = DetectHelperKeywordRegister(&kw); + G_ENIP_CIP_EXTENDEDSTATUS_BUFFER_ID = DetectHelperBufferRegister( + b"enip.cip_extendedstatus\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + ); let kw = SCSigTableElmt { name: b"enip.product_name\0".as_ptr() as *const libc::c_char, desc: b"sticky buffer to match EtherNet/IP product name\0".as_ptr() as *const libc::c_char, @@ -1668,17 +1632,15 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { AppLayerTxMatch: None, Free: None, }; - unsafe { - let _g_enip_product_name_kw_id = DetectHelperKeywordRegister(&kw); - G_ENIP_PRODUCT_NAME_BUFFER_ID = DetectHelperBufferMpmRegister( - b"enip.product_name\0".as_ptr() as *const libc::c_char, - b"ENIP product name\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - product_name_get_data, - ); - } + let _g_enip_product_name_kw_id = DetectHelperKeywordRegister(&kw); + G_ENIP_PRODUCT_NAME_BUFFER_ID = DetectHelperBufferMpmRegister( + b"enip.product_name\0".as_ptr() as *const libc::c_char, + b"ENIP product name\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + product_name_get_data, + ); let kw = SCSigTableElmt { name: b"enip.service_name\0".as_ptr() as *const libc::c_char, desc: b"sticky buffer to match EtherNet/IP service name\0".as_ptr() as *const libc::c_char, @@ -1688,17 +1650,15 @@ pub unsafe extern "C" fn ScDetectEnipRegister() { AppLayerTxMatch: None, Free: None, }; - unsafe { - let _g_enip_service_name_kw_id = DetectHelperKeywordRegister(&kw); - G_ENIP_SERVICE_NAME_BUFFER_ID = DetectHelperBufferMpmRegister( - b"enip.service_name\0".as_ptr() as *const libc::c_char, - b"ENIP service name\0".as_ptr() as *const libc::c_char, - ALPROTO_ENIP, - true, - true, - service_name_get_data, - ); - } + let _g_enip_service_name_kw_id = DetectHelperKeywordRegister(&kw); + G_ENIP_SERVICE_NAME_BUFFER_ID = DetectHelperBufferMpmRegister( + b"enip.service_name\0".as_ptr() as *const libc::c_char, + b"ENIP service name\0".as_ptr() as *const libc::c_char, + ALPROTO_ENIP, + true, + true, + service_name_get_data, + ); } #[cfg(test)] diff --git a/rust/src/snmp/detect.rs b/rust/src/snmp/detect.rs index 7dee00a707..2f9851bbdf 100644 --- a/rust/src/snmp/detect.rs +++ b/rust/src/snmp/detect.rs @@ -193,15 +193,13 @@ pub unsafe extern "C" fn ScDetectSNMPRegister() { Free: Some(snmp_detect_version_free), flags: 0, }; - unsafe { - G_SNMP_VERSION_KW_ID = DetectHelperKeywordRegister(&kw); - G_SNMP_VERSION_BUFFER_ID = DetectHelperBufferRegister( - b"snmp.version\0".as_ptr() as *const libc::c_char, - ALPROTO_SNMP, - true, - true, - ); - } + G_SNMP_VERSION_KW_ID = DetectHelperKeywordRegister(&kw); + G_SNMP_VERSION_BUFFER_ID = DetectHelperBufferRegister( + b"snmp.version\0".as_ptr() as *const libc::c_char, + ALPROTO_SNMP, + true, + true, + ); let kw = SCSigTableElmt { name: b"snmp.pdu_type\0".as_ptr() as *const libc::c_char, @@ -212,15 +210,13 @@ pub unsafe extern "C" fn ScDetectSNMPRegister() { Free: Some(snmp_detect_pdutype_free), flags: 0, }; - unsafe { - G_SNMP_PDUTYPE_KW_ID = DetectHelperKeywordRegister(&kw); - G_SNMP_PDUTYPE_BUFFER_ID = DetectHelperBufferRegister( - b"snmp.pdu_type\0".as_ptr() as *const libc::c_char, - ALPROTO_SNMP, - true, - true, - ); - } + G_SNMP_PDUTYPE_KW_ID = DetectHelperKeywordRegister(&kw); + G_SNMP_PDUTYPE_BUFFER_ID = DetectHelperBufferRegister( + b"snmp.pdu_type\0".as_ptr() as *const libc::c_char, + ALPROTO_SNMP, + true, + true, + ); let kw = SCSigTableElmt { name: b"snmp.usm\0".as_ptr() as *const libc::c_char, @@ -231,17 +227,15 @@ pub unsafe extern "C" fn ScDetectSNMPRegister() { AppLayerTxMatch: None, Free: None, }; - unsafe { - let _g_snmp_usm_kw_id = DetectHelperKeywordRegister(&kw); - G_SNMP_USM_BUFFER_ID = DetectHelperBufferMpmRegister( - b"snmp.usm\0".as_ptr() as *const libc::c_char, - b"SNMP USM\0".as_ptr() as *const libc::c_char, - ALPROTO_SNMP, - true, - true, - snmp_detect_usm_get_data, - ); - } + let _g_snmp_usm_kw_id = DetectHelperKeywordRegister(&kw); + G_SNMP_USM_BUFFER_ID = DetectHelperBufferMpmRegister( + b"snmp.usm\0".as_ptr() as *const libc::c_char, + b"SNMP USM\0".as_ptr() as *const libc::c_char, + ALPROTO_SNMP, + true, + true, + snmp_detect_usm_get_data, + ); let kw = SCSigTableElmt { name: b"snmp.community\0".as_ptr() as *const libc::c_char, @@ -253,15 +247,13 @@ pub unsafe extern "C" fn ScDetectSNMPRegister() { AppLayerTxMatch: None, Free: None, }; - unsafe { - let _g_snmp_community_kw_id = DetectHelperKeywordRegister(&kw); - G_SNMP_COMMUNITY_BUFFER_ID = DetectHelperBufferMpmRegister( - b"snmp.community\0".as_ptr() as *const libc::c_char, - b"SNMP Community identifier\0".as_ptr() as *const libc::c_char, - ALPROTO_SNMP, - true, - true, - snmp_detect_community_get_data, - ); - } + let _g_snmp_community_kw_id = DetectHelperKeywordRegister(&kw); + G_SNMP_COMMUNITY_BUFFER_ID = DetectHelperBufferMpmRegister( + b"snmp.community\0".as_ptr() as *const libc::c_char, + b"SNMP Community identifier\0".as_ptr() as *const libc::c_char, + ALPROTO_SNMP, + true, + true, + snmp_detect_community_get_data, + ); } diff --git a/rust/src/websocket/detect.rs b/rust/src/websocket/detect.rs index b4457125a6..f7f3cc9d46 100644 --- a/rust/src/websocket/detect.rs +++ b/rust/src/websocket/detect.rs @@ -287,15 +287,13 @@ pub unsafe extern "C" fn ScDetectWebsocketRegister() { Free: Some(websocket_detect_opcode_free), flags: 0, }; - unsafe { - G_WEBSOCKET_OPCODE_KW_ID = DetectHelperKeywordRegister(&kw); - G_WEBSOCKET_OPCODE_BUFFER_ID = DetectHelperBufferRegister( - b"websocket.opcode\0".as_ptr() as *const libc::c_char, - ALPROTO_WEBSOCKET, - true, - true, - ); - } + G_WEBSOCKET_OPCODE_KW_ID = DetectHelperKeywordRegister(&kw); + G_WEBSOCKET_OPCODE_BUFFER_ID = DetectHelperBufferRegister( + b"websocket.opcode\0".as_ptr() as *const libc::c_char, + ALPROTO_WEBSOCKET, + true, + true, + ); let kw = SCSigTableElmt { name: b"websocket.mask\0".as_ptr() as *const libc::c_char, desc: b"match WebSocket mask\0".as_ptr() as *const libc::c_char, @@ -305,15 +303,13 @@ pub unsafe extern "C" fn ScDetectWebsocketRegister() { Free: Some(websocket_detect_mask_free), flags: 0, }; - unsafe { - G_WEBSOCKET_MASK_KW_ID = DetectHelperKeywordRegister(&kw); - G_WEBSOCKET_MASK_BUFFER_ID = DetectHelperBufferRegister( - b"websocket.mask\0".as_ptr() as *const libc::c_char, - ALPROTO_WEBSOCKET, - true, - true, - ); - } + G_WEBSOCKET_MASK_KW_ID = DetectHelperKeywordRegister(&kw); + G_WEBSOCKET_MASK_BUFFER_ID = DetectHelperBufferRegister( + b"websocket.mask\0".as_ptr() as *const libc::c_char, + ALPROTO_WEBSOCKET, + true, + true, + ); let kw = SCSigTableElmt { name: b"websocket.flags\0".as_ptr() as *const libc::c_char, desc: b"match WebSocket flags\0".as_ptr() as *const libc::c_char, @@ -323,15 +319,13 @@ pub unsafe extern "C" fn ScDetectWebsocketRegister() { Free: Some(websocket_detect_flags_free), flags: 0, }; - unsafe { - G_WEBSOCKET_FLAGS_KW_ID = DetectHelperKeywordRegister(&kw); - G_WEBSOCKET_FLAGS_BUFFER_ID = DetectHelperBufferRegister( - b"websocket.flags\0".as_ptr() as *const libc::c_char, - ALPROTO_WEBSOCKET, - true, - true, - ); - } + G_WEBSOCKET_FLAGS_KW_ID = DetectHelperKeywordRegister(&kw); + G_WEBSOCKET_FLAGS_BUFFER_ID = DetectHelperBufferRegister( + b"websocket.flags\0".as_ptr() as *const libc::c_char, + ALPROTO_WEBSOCKET, + true, + true, + ); let kw = SCSigTableElmt { name: b"websocket.payload\0".as_ptr() as *const libc::c_char, desc: b"match WebSocket payload\0".as_ptr() as *const libc::c_char, @@ -341,15 +335,13 @@ pub unsafe extern "C" fn ScDetectWebsocketRegister() { AppLayerTxMatch: None, Free: None, }; - unsafe { - let _g_ws_payload_kw_id = DetectHelperKeywordRegister(&kw); - G_WEBSOCKET_PAYLOAD_BUFFER_ID = DetectHelperBufferMpmRegister( - b"websocket.payload\0".as_ptr() as *const libc::c_char, - b"WebSocket payload\0".as_ptr() as *const libc::c_char, - ALPROTO_WEBSOCKET, - true, - true, - websocket_detect_payload_get_data, - ); - } + let _g_ws_payload_kw_id = DetectHelperKeywordRegister(&kw); + G_WEBSOCKET_PAYLOAD_BUFFER_ID = DetectHelperBufferMpmRegister( + b"websocket.payload\0".as_ptr() as *const libc::c_char, + b"WebSocket payload\0".as_ptr() as *const libc::c_char, + ALPROTO_WEBSOCKET, + true, + true, + websocket_detect_payload_get_data, + ); }