clang-tidy: Replace NULL with nullptr
Replaced all instances of NULL with nullptr to improve type safety
and clarity, as nullptr is the modern C++ standard for null pointers.
Tested: Build verified
Change-Id: I0e0749db217667d9c3f51f8fac6cb58e8915e8d2
Signed-off-by: Jayanth Othayoth <ojayanth@gmail.com>
diff --git a/frup.cpp b/frup.cpp
index fb06e80..7254017 100644
--- a/frup.cpp
+++ b/frup.cpp
@@ -296,7 +296,7 @@
while (area_offset < areabuflen &&
areabufptr[area_offset] != IPMI_FRU_SENTINEL_VALUE)
{
- ipmi_fru_field_t* field_ptr = NULL;
+ ipmi_fru_field_t* field_ptr = nullptr;
if (chassis_custom_fields && chassis_custom_fields_len)
{
@@ -424,7 +424,7 @@
while (area_offset < areabuflen &&
areabufptr[area_offset] != IPMI_FRU_SENTINEL_VALUE)
{
- ipmi_fru_field_t* field_ptr = NULL;
+ ipmi_fru_field_t* field_ptr = nullptr;
if (board_custom_fields && board_custom_fields_len)
{
@@ -562,7 +562,7 @@
while (area_offset < areabuflen &&
areabufptr[area_offset] != IPMI_FRU_SENTINEL_VALUE)
{
- ipmi_fru_field_t* field_ptr = NULL;
+ ipmi_fru_field_t* field_ptr = nullptr;
if (product_custom_fields && product_custom_fields_len)
{
@@ -666,7 +666,7 @@
if (bin_in_ascii)
{
free(bin_in_ascii);
- bin_in_ascii = NULL;
+ bin_in_ascii = nullptr;
}
}
@@ -734,7 +734,7 @@
printf("Board : Buf len = [%d]\n", len);
#endif
ipmi_fru_board_info_area(
- (uint8_t*)msgbuf + 2, len, NULL, &mfg_date_time,
+ (uint8_t*)msgbuf + 2, len, nullptr, &mfg_date_time,
&vpd_info[OPENBMC_VPD_KEY_BOARD_MFR],
&vpd_info[OPENBMC_VPD_KEY_BOARD_NAME],
&vpd_info[OPENBMC_VPD_KEY_BOARD_SERIAL_NUM],
@@ -766,7 +766,7 @@
printf("Product : Buf len = [%d]\n", len);
#endif
ipmi_fru_product_info_area(
- (uint8_t*)msgbuf + 2, len, NULL,
+ (uint8_t*)msgbuf + 2, len, nullptr,
&vpd_info[OPENBMC_VPD_KEY_PRODUCT_MFR],
&vpd_info[OPENBMC_VPD_KEY_PRODUCT_NAME],
&vpd_info[OPENBMC_VPD_KEY_PRODUCT_PART_MODEL_NUM],
diff --git a/strgfnhandler.cpp b/strgfnhandler.cpp
index e917783..39499db 100644
--- a/strgfnhandler.cpp
+++ b/strgfnhandler.cpp
@@ -23,12 +23,12 @@
ipmi_response_t response, ipmi_data_len_t dataLen,
ipmi_context_t /*context*/)
{
- FILE* fp = NULL;
+ FILE* fp = nullptr;
char fruFilename[16] = {0};
size_t offset = 0;
size_t len = 0;
ipmi_ret_t rc = IPMI_CC_INVALID;
- const char* mode = NULL;
+ const char* mode = nullptr;
// From the payload, extract the header that has fruid and the offsets
auto reqptr = static_cast<write_fru_data_t*>(request);
@@ -61,7 +61,7 @@
mode = "rb+";
}
- if ((fp = std::fopen(fruFilename, mode)) != NULL)
+ if ((fp = std::fopen(fruFilename, mode)) != nullptr)
{
if (std::fseek(fp, offset, SEEK_SET))
{
@@ -116,6 +116,6 @@
std::printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n", NETFUN_STORAGE,
IPMI_CMD_WRITE_FRU_DATA);
- ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_WRITE_FRU_DATA, NULL,
+ ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_WRITE_FRU_DATA, nullptr,
ipmiStorageWriteFruData, SYSTEM_INTERFACE);
}
diff --git a/writefrudata.cpp b/writefrudata.cpp
index 44117ae..a4d5509 100644
--- a/writefrudata.cpp
+++ b/writefrudata.cpp
@@ -44,7 +44,7 @@
*/
int cleanupError(FILE* fruFilePointer, FruAreaVector& fruAreaVec)
{
- if (fruFilePointer != NULL)
+ if (fruFilePointer != nullptr)
{
std::fclose(fruFilePointer);
}
@@ -653,7 +653,7 @@
}
FILE* fruFilePointer = std::fopen(fruFilename, "rb");
- if (fruFilePointer == NULL)
+ if (fruFilePointer == nullptr)
{
log<level::ERR>("Unable to open FRU file",
entry("FILE=%s", fruFilename),
@@ -687,7 +687,7 @@
// We are done reading.
std::fclose(fruFilePointer);
- fruFilePointer = NULL;
+ fruFilePointer = nullptr;
rc = ipmiValidateCommonHeader(fruData.data(), dataLen);
if (rc < 0)