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: If9e6c34c48821a7cf8577a2166727ce7db06fadc
Signed-off-by: Jayanth Othayoth <ojayanth@gmail.com>
diff --git a/libpldmresponder/pdr.cpp b/libpldmresponder/pdr.cpp
index 9a149f7..0d2d12a 100644
--- a/libpldmresponder/pdr.cpp
+++ b/libpldmresponder/pdr.cpp
@@ -16,8 +16,8 @@
 {
     uint8_t* pdrData = nullptr;
     uint32_t pdrSize{};
-    auto record = pldm_pdr_find_record_by_type(inRepo.getPdr(), pdrType, NULL,
-                                               &pdrData, &pdrSize);
+    auto record = pldm_pdr_find_record_by_type(inRepo.getPdr(), pdrType,
+                                               nullptr, &pdrData, &pdrSize);
     while (record)
     {
         PdrEntry pdrEntry{};
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index b8ac0f6..2329213 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -241,7 +241,7 @@
     {
         pdr_utils::PdrEntry e;
         auto record = pdr::getRecordByHandle(pdrRepo, recordHandle, e);
-        if (record == NULL)
+        if (record == nullptr)
         {
             return CmdHandler::ccOnlyResponse(
                 request, PLDM_PLATFORM_INVALID_RECORD_HANDLE);
@@ -455,7 +455,7 @@
                                    previousEventState);
 
         // If there are no HOST PDR's, there is no further action
-        if (hostPDRHandler == NULL)
+        if (hostPDRHandler == nullptr)
         {
             return PLDM_SUCCESS;
         }
@@ -866,7 +866,7 @@
     while (pdrRecord)
     {
         pdr = reinterpret_cast<pldm_state_sensor_pdr*>(pdrEntry.data);
-        assert(pdr != NULL);
+        assert(pdr != nullptr);
         if (pdr->sensor_id != sensorId)
         {
             pdr = nullptr;
@@ -938,7 +938,7 @@
     while (pdrRecord)
     {
         pdr = reinterpret_cast<pldm_state_effecter_pdr*>(pdrEntry.data);
-        assert(pdr != NULL);
+        assert(pdr != nullptr);
         if (pdr->effecter_id != effecterId)
         {
             pdr = nullptr;
diff --git a/libpldmresponder/platform_state_sensor.hpp b/libpldmresponder/platform_state_sensor.hpp
index 20973b9..003763f 100644
--- a/libpldmresponder/platform_state_sensor.hpp
+++ b/libpldmresponder/platform_state_sensor.hpp
@@ -110,7 +110,7 @@
     while (pdrRecord)
     {
         pdr = reinterpret_cast<pldm_state_sensor_pdr*>(pdrEntry.data);
-        assert(pdr != NULL);
+        assert(pdr != nullptr);
         if (pdr->sensor_id != sensorId)
         {
             pdr = nullptr;
diff --git a/libpldmresponder/test/libpldmresponder_fru_test.cpp b/libpldmresponder/test/libpldmresponder_fru_test.cpp
index f4a1202..8eba53d 100644
--- a/libpldmresponder/test/libpldmresponder_fru_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_fru_test.cpp
@@ -136,21 +136,21 @@
 
     pldm_entity_node* node =
         pldm_entity_association_tree_find(entityTree.get(), &systemEntity);
-    EXPECT_TRUE(node != NULL);
+    EXPECT_TRUE(node != nullptr);
 
     node = pldm_entity_association_tree_find(entityTree.get(), &chassisEntity);
-    ASSERT_TRUE(node != NULL);
+    ASSERT_TRUE(node != nullptr);
     test_pldm_entity_node* test_node = (test_pldm_entity_node*)node;
     EXPECT_TRUE((test_node->parent).entity_type == systemEntity.entity_type);
 
     node =
         pldm_entity_association_tree_find(entityTree.get(), &motherboardEntity);
-    ASSERT_TRUE(node != NULL);
+    ASSERT_TRUE(node != nullptr);
     test_node = (test_pldm_entity_node*)node;
     EXPECT_TRUE((test_node->parent).entity_type == chassisEntity.entity_type);
 
     node = pldm_entity_association_tree_find(entityTree.get(), &panelEntity);
-    EXPECT_TRUE(node == NULL);
+    EXPECT_TRUE(node == nullptr);
 }
 
 TEST(FruImpl, entityByObjectPath)
diff --git a/oem/ibm/libpldmresponder/file_io_type_pcie.cpp b/oem/ibm/libpldmresponder/file_io_type_pcie.cpp
index a6665f6..099fe3d 100644
--- a/oem/ibm/libpldmresponder/file_io_type_pcie.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_pcie.cpp
@@ -208,7 +208,7 @@
 
     // memory map the topology file into pldm memory
     void* fileInMemory =
-        mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, topologyFd(), 0);
+        mmap(nullptr, sb.st_size, PROT_READ, MAP_PRIVATE, topologyFd(), 0);
     if (MAP_FAILED == fileInMemory)
     {
         error("mmap on topology file failed with error {RC}", "RC", -errno);
@@ -449,7 +449,7 @@
     };
 
     void* fileInMemory =
-        mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, cableInfoFd(), 0);
+        mmap(nullptr, sb.st_size, PROT_READ, MAP_PRIVATE, cableInfoFd(), 0);
 
     if (MAP_FAILED == fileInMemory)
     {
diff --git a/oem/ibm/libpldmresponder/utils.cpp b/oem/ibm/libpldmresponder/utils.cpp
index 6eb26a5..393faab 100644
--- a/oem/ibm/libpldmresponder/utils.cpp
+++ b/oem/ibm/libpldmresponder/utils.cpp
@@ -72,7 +72,7 @@
     int nfd = sock + 1;
     int fd = -1;
 
-    int retval = select(nfd, &rfd, NULL, NULL, &tv);
+    int retval = select(nfd, &rfd, nullptr, nullptr, &tv);
     if (retval < 0)
     {
         error(
@@ -84,7 +84,7 @@
 
     if ((retval > 0) && (FD_ISSET(sock, &rfd)))
     {
-        fd = accept(sock, NULL, NULL);
+        fd = accept(sock, nullptr, nullptr);
         if (fd < 0)
         {
             error(
@@ -114,7 +114,7 @@
         FD_SET(sock, &wfd);
         int nfd = sock + 1;
 
-        int retval = select(nfd, NULL, &wfd, NULL, &tv);
+        int retval = select(nfd, nullptr, &wfd, nullptr, &tv);
         if (retval < 0)
         {
             error(
diff --git a/oem/ibm/requester/dbus_to_file_handler.cpp b/oem/ibm/requester/dbus_to_file_handler.cpp
index 47ddf2c..8ed966c 100644
--- a/oem/ibm/requester/dbus_to_file_handler.cpp
+++ b/oem/ibm/requester/dbus_to_file_handler.cpp
@@ -32,7 +32,7 @@
 
 void DbusToFileHandler::sendNewFileAvailableCmd(uint64_t fileSize)
 {
-    if (instanceIdDb == NULL)
+    if (instanceIdDb == nullptr)
     {
         error(
             "Failed to send resource dump parameters as instance ID DB is not set");
@@ -245,7 +245,7 @@
 void DbusToFileHandler::newFileAvailableSendToHost(
     const uint32_t fileSize, const uint32_t fileHandle, const uint16_t type)
 {
-    if (instanceIdDb == NULL)
+    if (instanceIdDb == nullptr)
     {
         error("Failed to send csr to remote terminus.");
         pldm::utils::reportError(
diff --git a/platform-mc/terminus_manager.cpp b/platform-mc/terminus_manager.cpp
index 7565ee2..56902ad 100644
--- a/platform-mc/terminus_manager.cpp
+++ b/platform-mc/terminus_manager.cpp
@@ -490,7 +490,7 @@
         co_return rc;
     }
 
-    if (responseMsg == NULL || responseLen != PLDM_SET_TID_RESP_BYTES)
+    if (responseMsg == nullptr || responseLen != PLDM_SET_TID_RESP_BYTES)
     {
         lg2::error(
             "Failed to decode response SetTID for Endpoint ID {EID}, error {RC} ",
diff --git a/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index 2352b60..0b6d129 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -175,8 +175,8 @@
 int main(int argc, char** argv)
 {
     bool verbose = false;
-    static struct option long_options[] = {{"verbose", no_argument, 0, 'v'},
-                                           {0, 0, 0, 0}};
+    static struct option long_options[] = {
+        {"verbose", no_argument, nullptr, 'v'}, {nullptr, 0, nullptr, 0}};
 
     auto argflag = getopt_long(argc, argv, "v", long_options, nullptr);
     switch (argflag)
diff --git a/pldmtool/oem/ibm/pldm_oem_ibm.cpp b/pldmtool/oem/ibm/pldm_oem_ibm.cpp
index 317dbfa..5f96654 100644
--- a/pldmtool/oem/ibm/pldm_oem_ibm.cpp
+++ b/pldmtool/oem/ibm/pldm_oem_ibm.cpp
@@ -159,7 +159,7 @@
 
     void printFileAttrTable(uint8_t* data, size_t length)
     {
-        if (data == NULL || length == 0)
+        if (data == nullptr || length == 0)
         {
             return;
         }
diff --git a/pldmtool/pldm_platform_cmd.cpp b/pldmtool/pldm_platform_cmd.cpp
index 0a96274..d2c1c7d 100644
--- a/pldmtool/pldm_platform_cmd.cpp
+++ b/pldmtool/pldm_platform_cmd.cpp
@@ -846,7 +846,7 @@
 
     void printPDRFruRecordSet(uint8_t* data, ordered_json& output)
     {
-        if (data == NULL)
+        if (data == nullptr)
         {
             return;
         }
@@ -874,7 +874,7 @@
             {PLDM_ENTITY_ASSOCIAION_LOGICAL, "Logical"},
         };
 
-        if (data == NULL)
+        if (data == nullptr)
         {
             return;
         }
@@ -1495,7 +1495,7 @@
     void printPDRMsg(uint32_t& nextRecordHndl, const uint16_t respCnt,
                      uint8_t* data, std::optional<uint16_t> terminusHandle)
     {
-        if (data == NULL)
+        if (data == nullptr)
         {
             std::cerr << "Failed to get PDR message" << std::endl;
             return;