]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
NoNewGlobals for MapLabel (#1746)
authorFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Thu, 21 Mar 2024 02:22:37 +0000 (02:22 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 21 Mar 2024 02:22:40 +0000 (02:22 +0000)
Detected by Coverity. CID 1554668: Initialization or destruction
ordering is unspecified (GLOBAL_INIT_ORDER).

src/Transients.cc

index e33659138c9b98143b04134a3efedbc0b76d8f21..0eab8f767ad1e5e726a92cfebce75880fe1068d0 100644 (file)
 #include <limits>
 
 /// shared memory segment path to use for Transients map
-static const SBuf MapLabel("transients_map");
+static const auto &
+MapLabel()
+{
+    static const auto label = new SBuf("transients_map");
+    return *label;
+}
 
 Transients::Transients(): map(nullptr), locals(nullptr)
 {
@@ -45,7 +50,7 @@ Transients::init()
     assert(entryLimit > 0);
 
     Must(!map);
-    map = new TransientsMap(MapLabel);
+    map = new TransientsMap(MapLabel());
     map->cleaner = this;
     map->disableHitValidation(); // Transients lacks slices to validate
 
@@ -179,12 +184,12 @@ Transients::findCollapsed(const sfileno index)
         return nullptr;
 
     if (StoreEntry *oldE = locals->at(index)) {
-        debugs(20, 5, "found " << *oldE << " at " << index << " in " << MapLabel);
+        debugs(20, 5, "found " << *oldE << " at " << index << " in " << MapLabel());
         assert(oldE->mem_obj && oldE->mem_obj->xitTable.index == index);
         return oldE;
     }
 
-    debugs(20, 3, "no entry at " << index << " in " << MapLabel);
+    debugs(20, 3, "no entry at " << index << " in " << MapLabel());
     return nullptr;
 }
 
@@ -410,7 +415,7 @@ TransientsRr::create()
         return; // no SMP configured or a misconfiguration
 
     Must(!mapOwner);
-    mapOwner = TransientsMap::Init(MapLabel, entryLimit);
+    mapOwner = TransientsMap::Init(MapLabel(), entryLimit);
 }
 
 TransientsRr::~TransientsRr()