log_manager: fix constexpr string length
'strlen' is not actually defined to be constexpr, but GCC has
an extension which allows it to be calculated at compile-time,
which clang does not support. Switch to use string_view instead.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ic18972a4d97d9ba17ac0530e3914b5f346381c7f
diff --git a/log_manager.cpp b/log_manager.cpp
index 8c4d2ae..29f5955 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -27,6 +27,7 @@
#include <sdbusplus/vtable.hpp>
#include <set>
#include <string>
+#include <string_view>
#include <vector>
#include <xyz/openbmc_project/State/Host/server.hpp>
@@ -91,12 +92,12 @@
// operations. Just skip over them.
if (!IS_UNIT_TEST)
{
- constexpr const auto transactionIdVar = "TRANSACTION_ID";
+ static constexpr auto transactionIdVar =
+ std::string_view{"TRANSACTION_ID"};
// Length of 'TRANSACTION_ID' string.
- constexpr const auto transactionIdVarSize =
- std::strlen(transactionIdVar);
+ static constexpr auto transactionIdVarSize = transactionIdVar.size();
// Length of 'TRANSACTION_ID=' string.
- constexpr const auto transactionIdVarOffset = transactionIdVarSize + 1;
+ static constexpr auto transactionIdVarOffset = transactionIdVarSize + 1;
// Flush all the pending log messages into the journal
journalSync();
@@ -130,8 +131,8 @@
size_t length = 0;
// Look for the transaction id metadata variable
- rc = sd_journal_get_data(j, transactionIdVar, (const void**)&data,
- &length);
+ rc = sd_journal_get_data(j, transactionIdVar.data(),
+ (const void**)&data, &length);
if (rc < 0)
{
// This journal entry does not have the TRANSACTION_ID