Make build on clang
And support clang-tidy rules. The changes are pretty minimal, and were
all done by the clang robot.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I29501aa56de1cd63cda233e06a07641458f89345
diff --git a/src/FruUtils.cpp b/src/FruUtils.cpp
index beeb148..945abf4 100644
--- a/src/FruUtils.cpp
+++ b/src/FruUtils.cpp
@@ -32,10 +32,10 @@
#include <linux/i2c.h>
}
-static constexpr bool DEBUG = false;
+static constexpr bool debug = false;
constexpr size_t fruVersion = 1; // Current FRU spec version number is 1
-const std::tm intelEpoch(void)
+std::tm intelEpoch(void)
{
std::tm val = {};
val.tm_year = 1996 - 1900;
@@ -178,10 +178,7 @@
// Return language flag as non english
return false;
}
- else
- {
- return true;
- }
+ return true;
}
/* This function verifies for other offsets to check if they are not
@@ -339,7 +336,7 @@
result["CHASSIS_TYPE"] =
std::to_string(static_cast<int>(*fruBytesIter));
fruBytesIter += 1;
- fruAreaFieldNames = &CHASSIS_FRU_AREAS;
+ fruAreaFieldNames = &chassisFruAreas;
break;
}
case fruAreas::fruAreaBoard:
@@ -370,7 +367,7 @@
result["BOARD_MANUFACTURE_DATE"] = std::string(timeString);
fruBytesIter += 3;
- fruAreaFieldNames = &BOARD_FRU_AREAS;
+ fruAreaFieldNames = &boardFruAreas;
break;
}
case fruAreas::fruAreaProduct:
@@ -380,7 +377,7 @@
std::to_string(static_cast<int>(lang));
isLangEng = checkLangEng(lang);
fruBytesIter += 1;
- fruAreaFieldNames = &PRODUCT_FRU_AREAS;
+ fruAreaFieldNames = &productFruAreas;
break;
}
default:
@@ -408,7 +405,7 @@
{
name =
std::string(getFruAreaName(area)) + "_" +
- FRU_CUSTOM_FIELD_NAME +
+ fruCustomFieldName +
std::to_string(fieldIndex - fruAreaFieldNames->size() + 1);
}
@@ -527,10 +524,7 @@
{
return -1;
}
- else
- {
- return fruFieldTypeLenValue & typeLenMask;
- }
+ return fruFieldTypeLenValue & typeLenMask;
}
bool validateHeader(const std::array<uint8_t, I2C_SMBUS_BLOCK_MAX>& blockData)
@@ -538,7 +532,7 @@
// ipmi spec format version number is currently at 1, verify it
if (blockData[0] != fruVersion)
{
- if (DEBUG)
+ if (debug)
{
std::cerr << "FRU spec version " << (int)(blockData[0])
<< " not supported. Supported version is "
@@ -550,7 +544,7 @@
// verify pad is set to 0
if (blockData[6] != 0x0)
{
- if (DEBUG)
+ if (debug)
{
std::cerr << "PAD value in header is non zero, value is "
<< (int)(blockData[6]) << "\n";
@@ -583,7 +577,7 @@
if (sum != blockData[7])
{
- if (DEBUG)
+ if (debug)
{
std::cerr << "Checksum " << (int)(blockData[7])
<< " is invalid. calculated checksum is " << (int)(sum)
@@ -595,7 +589,7 @@
}
std::vector<uint8_t> readFRUContents(int flag, int file, uint16_t address,
- ReadBlockFunc readBlock,
+ const ReadBlockFunc& readBlock,
const std::string& errorHelp)
{
std::array<uint8_t, I2C_SMBUS_BLOCK_MAX> blockData;
@@ -609,7 +603,7 @@
// check the header checksum
if (!validateHeader(blockData))
{
- if (DEBUG)
+ if (debug)
{
std::cerr << "Illegal header " << errorHelp << "\n";
}