From 87e6fe2c50e77f10dc1aab6d361894a30626179f Mon Sep 17 00:00:00 2001 From: Francesco Chemolli <5175948+kinkie@users.noreply.github.com> Date: Thu, 21 Mar 2024 02:22:37 +0000 Subject: [PATCH] NoNewGlobals for MapLabel (#1746) Detected by Coverity. CID 1554668: Initialization or destruction ordering is unspecified (GLOBAL_INIT_ORDER). --- src/Transients.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Transients.cc b/src/Transients.cc index e33659138c..0eab8f767a 100644 --- a/src/Transients.cc +++ b/src/Transients.cc @@ -25,7 +25,12 @@ #include /// 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() -- 2.39.2