]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/mqtt: fix clippy 1.77 warning
authorPhilippe Antoine <pantoine@oisf.net>
Thu, 21 Mar 2024 21:45:41 +0000 (22:45 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 18 Apr 2024 08:30:21 +0000 (10:30 +0200)
error: creating a mutable reference to mutable static is discouraged
   --> src/mqtt/mqtt.rs:752:23
    |
752 |     let max_msg_len = &mut MAX_MSG_LEN;
    |                       ^^^^^^^^^^^^^^^^ mutable reference to mutable static
    |
    = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
    = note: this will be a hard error in the 2024 edition
    = note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior

rust/src/mqtt/mqtt.rs

index 7cd5394d49f784b647c80bcb6b1cc64799478567..5f210be8b90d95be1f7571c05533ea600500b759 100644 (file)
@@ -838,8 +838,7 @@ export_tx_data_get!(rs_mqtt_get_tx_data, MQTTTransaction);
 #[no_mangle]
 pub unsafe extern "C" fn rs_mqtt_register_parser(cfg_max_msg_len: u32) {
     let default_port = CString::new("[1883]").unwrap();
-    let max_msg_len = &mut MAX_MSG_LEN;
-    *max_msg_len = cfg_max_msg_len;
+    MAX_MSG_LEN = cfg_max_msg_len;
     let parser = RustParser {
         name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char,
         default_port: default_port.as_ptr(),