]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
smb: wrap read access to static mutables in function
authorJason Ish <jason.ish@oisf.net>
Wed, 26 Feb 2025 15:29:40 +0000 (09:29 -0600)
committerVictor Julien <victor@inliniac.net>
Thu, 27 Feb 2025 05:57:44 +0000 (06:57 +0100)
Simply wrapping in a function removes static_mut_refs compiler
warning.

Ticket: #7417

rust/src/smb/smb.rs

index 2ff1ad15ea43d7eec439dde6ed8a5f330471cdfe..b60cf364208256b3ed80886db02f80ffd2e61f6a 100644 (file)
@@ -2525,11 +2525,60 @@ pub unsafe extern "C" fn rs_smb_register_parser() {
             }
         }
         SCLogConfig!("read: max record size: {}, max queued chunks {}, max queued size {}",
-                SMB_CFG_MAX_READ_SIZE, SMB_CFG_MAX_READ_QUEUE_CNT, SMB_CFG_MAX_READ_QUEUE_SIZE);
+                cfg_max_read_size(), cfg_max_read_queue_cnt(), cfg_max_read_queue_size());
         SCLogConfig!("write: max record size: {}, max queued chunks {}, max queued size {}",
-                SMB_CFG_MAX_WRITE_SIZE, SMB_CFG_MAX_WRITE_QUEUE_CNT, SMB_CFG_MAX_WRITE_QUEUE_SIZE);
-        SCLogConfig!("guid: max cache size: {}", SMB_CFG_MAX_GUID_CACHE_SIZE);
+                cfg_max_write_size(), cfg_max_write_queue_cnt(), cfg_max_write_queue_size());
+        SCLogConfig!("guid: max cache size: {}", cfg_max_guid_cache_size());
     } else {
         SCLogDebug!("Protocol detector and parser disabled for SMB.");
     }
 }
+
+// Wrapper function around static mutable to prevent refs to static
+// mutables.
+#[inline(always)]
+fn cfg_max_read_size() -> u32 {
+    unsafe { SMB_CFG_MAX_READ_SIZE }
+}
+
+// Wrapper function around static mutable to prevent refs to static
+// mutables.
+#[inline(always)]
+fn cfg_max_read_queue_cnt() -> u32 {
+    unsafe { SMB_CFG_MAX_READ_QUEUE_CNT }
+}
+
+// Wrapper function around static mutable to prevent refs to static
+// mutables.
+#[inline(always)]
+fn cfg_max_read_queue_size() -> u32 {
+    unsafe { SMB_CFG_MAX_READ_QUEUE_SIZE }
+}
+
+// Wrapper function around static mutable to prevent refs to static
+// mutables.
+#[inline(always)]
+fn cfg_max_write_size() -> u32 {
+    unsafe { SMB_CFG_MAX_WRITE_SIZE }
+}
+
+// Wrapper function around static mutable to prevent refs to static
+// mutables.
+#[inline(always)]
+fn cfg_max_write_queue_cnt() -> u32 {
+    unsafe { SMB_CFG_MAX_WRITE_QUEUE_CNT }
+}
+
+// Wrapper function around static mutable to prevent refs to static
+// mutables.
+#[inline(always)]
+fn cfg_max_write_queue_size() -> u32 {
+    unsafe { SMB_CFG_MAX_WRITE_QUEUE_SIZE }
+}
+
+// Wrapper function around static mutable to prevent refs to static
+// mutables.
+#[inline(always)]
+fn cfg_max_guid_cache_size() -> usize {
+    unsafe { SMB_CFG_MAX_GUID_CACHE_SIZE }
+}