Clang-tidy updates for 19
Update to add new checks that are now available to us. Fix the minor
issues we have. A few of our checks that we previously had enabled have
been renamed, so remove those from the file as well.
Change-Id: Idbbfc3cb7ba42ac780e557554d7ae8ab190e7551
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/redfish-core/include/registries.hpp b/redfish-core/include/registries.hpp
index ce6d7b8..a465d6e 100644
--- a/redfish-core/include/registries.hpp
+++ b/redfish-core/include/registries.hpp
@@ -73,7 +73,7 @@
ret += msg.substr(0, stringIndex);
msg.remove_prefix(stringIndex + 1);
size_t number = 0;
- auto it = std::from_chars(msg.data(), &*msg.end(), number);
+ auto it = std::from_chars(&*msg.begin(), &*msg.end(), number);
if (it.ec != std::errc())
{
return "";
diff --git a/redfish-core/lib/manager_logservices_journal.hpp b/redfish-core/lib/manager_logservices_journal.hpp
index 8bc1549..acab53c 100644
--- a/redfish-core/lib/manager_logservices_journal.hpp
+++ b/redfish-core/lib/manager_logservices_journal.hpp
@@ -20,7 +20,7 @@
namespace redfish
{
-inline int getJournalMetadata(sd_journal* journal, std::string_view field,
+inline int getJournalMetadata(sd_journal* journal, const char* field,
std::string_view& contents)
{
const char* data = nullptr;
@@ -30,7 +30,7 @@
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
const void** dataVoid = reinterpret_cast<const void**>(&data);
- ret = sd_journal_get_data(journal, field.data(), dataVoid, &length);
+ ret = sd_journal_get_data(journal, field, dataVoid, &length);
if (ret < 0)
{
return ret;
@@ -41,19 +41,23 @@
return ret;
}
-inline int getJournalMetadataInt(sd_journal* journal, std::string_view field,
- const int& base, long int& contents)
+inline int getJournalMetadataInt(sd_journal* journal, const char* field,
+ const int base, long int& contents)
{
- int ret = 0;
std::string_view metadata;
// Get the metadata from the requested field of the journal entry
- ret = getJournalMetadata(journal, field, metadata);
+ int ret = getJournalMetadata(journal, field, metadata);
if (ret < 0)
{
return ret;
}
- contents = strtol(metadata.data(), nullptr, base);
- return ret;
+ std::from_chars_result res =
+ std::from_chars(&*metadata.begin(), &*metadata.end(), contents, base);
+ if (res.ec != std::error_code{} || res.ptr != &*metadata.end())
+ {
+ return -1;
+ }
+ return 0;
}
inline bool getEntryTimestamp(sd_journal* journal, std::string& entryTimestamp)
@@ -63,7 +67,7 @@
ret = sd_journal_get_realtime_usec(journal, ×tamp);
if (ret < 0)
{
- BMCWEB_LOG_ERROR("Failed to read entry timestamp: {}", strerror(-ret));
+ BMCWEB_LOG_ERROR("Failed to read entry timestamp: {}", ret);
return false;
}
entryTimestamp = redfish::time_utils::getDateTimeUintUs(timestamp);
@@ -88,8 +92,7 @@
ret = getJournalMetadata(journal, "SYSLOG_IDENTIFIER", syslogID);
if (ret < 0)
{
- BMCWEB_LOG_DEBUG("Failed to read SYSLOG_IDENTIFIER field: {}",
- strerror(-ret));
+ BMCWEB_LOG_DEBUG("Failed to read SYSLOG_IDENTIFIER field: {}", ret);
}
if (!syslogID.empty())
{
@@ -100,7 +103,7 @@
ret = getJournalMetadata(journal, "MESSAGE", msg);
if (ret < 0)
{
- BMCWEB_LOG_ERROR("Failed to read MESSAGE field: {}", strerror(-ret));
+ BMCWEB_LOG_ERROR("Failed to read MESSAGE field: {}", ret);
return false;
}
message += std::string(msg);
@@ -110,7 +113,7 @@
ret = getJournalMetadataInt(journal, "PRIORITY", 10, severity);
if (ret < 0)
{
- BMCWEB_LOG_DEBUG("Failed to read PRIORITY field: {}", strerror(-ret));
+ BMCWEB_LOG_DEBUG("Failed to read PRIORITY field: {}", ret);
}
// Get the Created time from the timestamp
@@ -294,7 +297,7 @@
int ret = sd_journal_open(&journalTmp, SD_JOURNAL_LOCAL_ONLY);
if (ret < 0)
{
- BMCWEB_LOG_ERROR("failed to open journal: {}", strerror(-ret));
+ BMCWEB_LOG_ERROR("failed to open journal: {}", ret);
messages::internalError(asyncResp->res);
return;
}
@@ -401,7 +404,7 @@
int ret = sd_journal_open(&journalTmp, SD_JOURNAL_LOCAL_ONLY);
if (ret < 0)
{
- BMCWEB_LOG_ERROR("failed to open journal: {}", strerror(-ret));
+ BMCWEB_LOG_ERROR("failed to open journal: {}", ret);
messages::internalError(asyncResp->res);
return;
}