util: use constexpr string instead of string objects

This handles an initialization order issue found with address
santization testing.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I7b3b6e980e378855e8bda8209dba18c20b67a000
diff --git a/Makefile.am b/Makefile.am
index 42cdcbf..e6c85c5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,7 +39,6 @@
 
 noinst_LTLIBRARIES = libfirmware_common.la
 libfirmware_common_la_SOURCES = \
-	util.cpp \
 	internal/sys.cpp
 libfirmware_common_la_CXXFLAGS = \
 	$(CODE_COVERAGE_CXXFLAGS) \
diff --git a/bmc/firmware_handler.cpp b/bmc/firmware_handler.cpp
index ccd76d3..d71cc9f 100644
--- a/bmc/firmware_handler.cpp
+++ b/bmc/firmware_handler.cpp
@@ -464,18 +464,18 @@
     }
 
     Session* curr;
-    const std::string* active;
+    const char* active;
 
     if (path == hashBlobId)
     {
         /* 2c) are they opening the /flash/hash ? (to start the process) */
         curr = &activeHash;
-        active = &activeHashBlobId;
+        active = activeHashBlobId;
     }
     else
     {
         curr = &activeImage;
-        active = &activeImageBlobId;
+        active = activeImageBlobId;
     }
 
     curr->flags = flags;
@@ -484,7 +484,7 @@
 
     lookup[session] = curr;
 
-    addBlobId(*active);
+    addBlobId(active);
     removeBlobId(verifyBlobId);
 
     changeState(UpdateState::uploadInProgress);
diff --git a/cleanup/Makefile.am b/cleanup/Makefile.am
index 3623f7f..8f20a48 100644
--- a/cleanup/Makefile.am
+++ b/cleanup/Makefile.am
@@ -4,8 +4,7 @@
 noinst_LTLIBRARIES = libfirmwarecleanupblob_common.la
 libfirmwarecleanupblob_common_la_SOURCES = \
 	cleanup.cpp \
-	fs.cpp \
-	$(top_srcdir)/util.cpp
+	fs.cpp
 libfirmwarecleanupblob_common_la_CXXFLAGS = \
 	-flto
 libfirmwarecleanupblob_common_la_LDFLAGS = \
diff --git a/util.cpp b/util.cpp
deleted file mode 100644
index 04ae17f..0000000
--- a/util.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2019 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "util.hpp"
-
-namespace ipmi_flash
-{
-
-const std::string biosBlobId = "/flash/bios";
-const std::string updateBlobId = "/flash/update";
-const std::string verifyBlobId = "/flash/verify";
-const std::string hashBlobId = "/flash/hash";
-const std::string activeImageBlobId = "/flash/active/image";
-const std::string activeHashBlobId = "/flash/active/hash";
-const std::string staticLayoutBlobId = "/flash/image";
-const std::string ubiTarballBlobId = "/flash/tarball";
-const std::string cleanupBlobId = "/flash/cleanup";
-
-} // namespace ipmi_flash
diff --git a/util.hpp b/util.hpp
index 8a386e1..e5197dd 100644
--- a/util.hpp
+++ b/util.hpp
@@ -1,18 +1,16 @@
 #pragma once
 
-#include <string>
-
 namespace ipmi_flash
 {
 
-extern const std::string biosBlobId;
-extern const std::string updateBlobId;
-extern const std::string verifyBlobId;
-extern const std::string hashBlobId;
-extern const std::string activeImageBlobId;
-extern const std::string activeHashBlobId;
-extern const std::string staticLayoutBlobId;
-extern const std::string ubiTarballBlobId;
-extern const std::string cleanupBlobId;
+inline constexpr char biosBlobId[] = "/flash/bios";
+inline constexpr char updateBlobId[] = "/flash/update";
+inline constexpr char verifyBlobId[] = "/flash/verify";
+inline constexpr char hashBlobId[] = "/flash/hash";
+inline constexpr char activeImageBlobId[] = "/flash/active/image";
+inline constexpr char activeHashBlobId[] = "/flash/active/hash";
+inline constexpr char staticLayoutBlobId[] = "/flash/image";
+inline constexpr char ubiTarballBlobId[] = "/flash/tarball";
+inline constexpr char cleanupBlobId[] = "/flash/cleanup";
 
 } // namespace ipmi_flash