clang-tidy: Enable modernize-deprecated-headers check
Some headers from C library were deprecated in C++ and are no
longer welcome in C++ codebases. Some have no effect in C++ [1].
[1]: https://releases.llvm.org/13.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/modernize-deprecated-headers.html
Change-Id: Ia3b1df10175e2e661c8fffb82e357c9db81b2e9c
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/.clang-tidy b/.clang-tidy
index 166b63d..3470782 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -147,6 +147,7 @@
misc-throw-by-value-catch-by-reference,
misc-unconventional-assign-operator,
misc-uniqueptr-reset-release,
+modernize-deprecated-headers,
modernize-deprecated-ios-base-aliases,
modernize-make-shared,
modernize-make-unique,
diff --git a/common/transport.hpp b/common/transport.hpp
index 0601488..e9e1808 100644
--- a/common/transport.hpp
+++ b/common/transport.hpp
@@ -3,7 +3,8 @@
#include <libpldm/base.h>
#include <libpldm/pldm.h>
#include <poll.h>
-#include <stddef.h>
+
+#include <cstddef>
struct pldm_transport_mctp_demux;
struct pldm_transport_af_mctp;
diff --git a/common/types.hpp b/common/types.hpp
index 2a911c6..a1c1c51 100644
--- a/common/types.hpp
+++ b/common/types.hpp
@@ -1,10 +1,9 @@
#pragma once
-#include <stdint.h>
-
#include <sdbusplus/message/types.hpp>
#include <bitset>
+#include <cstdint>
#include <map>
#include <set>
#include <string>
diff --git a/common/utils.hpp b/common/utils.hpp
index 6c17191..7df5f81 100644
--- a/common/utils.hpp
+++ b/common/utils.hpp
@@ -8,7 +8,6 @@
#include <libpldm/pdr.h>
#include <libpldm/platform.h>
#include <libpldm/utils.h>
-#include <stdint.h>
#include <systemd/sd-bus.h>
#include <unistd.h>
@@ -18,6 +17,7 @@
#include <xyz/openbmc_project/Logging/Entry/server.hpp>
#include <xyz/openbmc_project/ObjectMapper/client.hpp>
+#include <cstdint>
#include <deque>
#include <exception>
#include <filesystem>
diff --git a/host-bmc/host_pdr_handler.cpp b/host-bmc/host_pdr_handler.cpp
index 4bcdb7c..40bb057 100644
--- a/host-bmc/host_pdr_handler.cpp
+++ b/host-bmc/host_pdr_handler.cpp
@@ -6,8 +6,6 @@
#endif
#include "dbus/custom_dbus.hpp"
-#include <assert.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/lg2.hpp>
#include <sdeventplus/clock.hpp>
@@ -15,6 +13,7 @@
#include <sdeventplus/source/io.hpp>
#include <sdeventplus/source/time.hpp>
+#include <cassert>
#include <fstream>
#include <type_traits>
diff --git a/libpldmresponder/base.hpp b/libpldmresponder/base.hpp
index b0829c4..e46b32c 100644
--- a/libpldmresponder/base.hpp
+++ b/libpldmresponder/base.hpp
@@ -3,10 +3,10 @@
#include "libpldmresponder/platform.hpp"
#include <libpldm/base.h>
-#include <stdint.h>
#include <sdeventplus/source/event.hpp>
+#include <cstdint>
#include <vector>
using namespace pldm::responder;
diff --git a/libpldmresponder/bios.cpp b/libpldmresponder/bios.cpp
index 1f3d536..57668d8 100644
--- a/libpldmresponder/bios.cpp
+++ b/libpldmresponder/bios.cpp
@@ -2,8 +2,6 @@
#include "common/utils.hpp"
-#include <time.h>
-
#include <phosphor-logging/lg2.hpp>
#include <array>
diff --git a/libpldmresponder/bios.hpp b/libpldmresponder/bios.hpp
index 8cb18c0..eab143e 100644
--- a/libpldmresponder/bios.hpp
+++ b/libpldmresponder/bios.hpp
@@ -9,8 +9,8 @@
#include <libpldm/bios.h>
#include <libpldm/bios_table.h>
-#include <stdint.h>
+#include <cstdint>
#include <ctime>
#include <functional>
#include <map>
diff --git a/libpldmresponder/bios_table.hpp b/libpldmresponder/bios_table.hpp
index 8b5f8bc..40839ae 100644
--- a/libpldmresponder/bios_table.hpp
+++ b/libpldmresponder/bios_table.hpp
@@ -2,8 +2,8 @@
#include <libpldm/bios.h>
#include <libpldm/bios_table.h>
-#include <stdint.h>
+#include <cstdint>
#include <filesystem>
#include <optional>
#include <string>
diff --git a/libpldmresponder/pdr.hpp b/libpldmresponder/pdr.hpp
index ea12655..edd8810 100644
--- a/libpldmresponder/pdr.hpp
+++ b/libpldmresponder/pdr.hpp
@@ -3,7 +3,7 @@
#include "common/utils.hpp"
#include "libpldmresponder/pdr_utils.hpp"
-#include <stdint.h>
+#include <cstdint>
namespace pldm
{
diff --git a/libpldmresponder/pdr_utils.hpp b/libpldmresponder/pdr_utils.hpp
index a5374aa..e56cc24 100644
--- a/libpldmresponder/pdr_utils.hpp
+++ b/libpldmresponder/pdr_utils.hpp
@@ -4,12 +4,12 @@
#include "common/utils.hpp"
#include <libpldm/pdr.h>
-#include <stdint.h>
#include <nlohmann/json.hpp>
#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <cstdint>
#include <filesystem>
#include <fstream>
#include <functional>
diff --git a/libpldmresponder/platform.hpp b/libpldmresponder/platform.hpp
index 47c9ecf..97e5aa5 100644
--- a/libpldmresponder/platform.hpp
+++ b/libpldmresponder/platform.hpp
@@ -14,10 +14,10 @@
#include <libpldm/pdr.h>
#include <libpldm/platform.h>
#include <libpldm/states.h>
-#include <stdint.h>
#include <phosphor-logging/lg2.hpp>
+#include <cstdint>
#include <map>
PHOSPHOR_LOG2_USING;
diff --git a/libpldmresponder/platform_numeric_effecter.hpp b/libpldmresponder/platform_numeric_effecter.hpp
index afb24fe..79a746f 100644
--- a/libpldmresponder/platform_numeric_effecter.hpp
+++ b/libpldmresponder/platform_numeric_effecter.hpp
@@ -7,11 +7,11 @@
#include <libpldm/platform.h>
#include <libpldm/states.h>
-#include <math.h>
-#include <stdint.h>
#include <phosphor-logging/lg2.hpp>
+#include <cmath>
+#include <cstdint>
#include <map>
#include <optional>
diff --git a/libpldmresponder/test/libpldmresponder_base_test.cpp b/libpldmresponder/test/libpldmresponder_base_test.cpp
index 4656882..539d2cf 100644
--- a/libpldmresponder/test/libpldmresponder_base_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_base_test.cpp
@@ -4,11 +4,11 @@
#include "test/test_instance_id.hpp"
#include <libpldm/base.h>
-#include <string.h>
#include <sdeventplus/event.hpp>
#include <array>
+#include <cstring>
#include <gtest/gtest.h>
diff --git a/libpldmresponder/test/libpldmresponder_bios_table_test.cpp b/libpldmresponder/test/libpldmresponder_bios_table_test.cpp
index 47764ee..7aa143e 100644
--- a/libpldmresponder/test/libpldmresponder_bios_table_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_bios_table_test.cpp
@@ -1,8 +1,7 @@
#include "libpldmresponder/bios_table.hpp"
-#include <stdlib.h>
-
#include <algorithm>
+#include <cstdlib>
#include <vector>
#include <gtest/gtest.h>
diff --git a/libpldmresponder/test/libpldmresponder_bios_test.cpp b/libpldmresponder/test/libpldmresponder_bios_test.cpp
index 2b9e49a..c229caa 100644
--- a/libpldmresponder/test/libpldmresponder_bios_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_bios_test.cpp
@@ -3,7 +3,6 @@
#include <libpldm/base.h>
#include <libpldm/bios.h>
-#include <string.h>
#include <array>
#include <cstring>
diff --git a/oem/ibm/libpldmresponder/file_io.hpp b/oem/ibm/libpldmresponder/file_io.hpp
index eab731b..cccd919 100644
--- a/oem/ibm/libpldmresponder/file_io.hpp
+++ b/oem/ibm/libpldmresponder/file_io.hpp
@@ -10,13 +10,13 @@
#include <libpldm/base.h>
#include <libpldm/oem/ibm/file_io.h>
#include <libpldm/oem/ibm/host.h>
-#include <stdint.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <phosphor-logging/lg2.hpp>
+#include <cstdint>
#include <filesystem>
#include <iostream>
#include <vector>
diff --git a/oem/ibm/libpldmresponder/file_io_by_type.cpp b/oem/ibm/libpldmresponder/file_io_by_type.cpp
index bed64f1..388f866 100644
--- a/oem/ibm/libpldmresponder/file_io_by_type.cpp
+++ b/oem/ibm/libpldmresponder/file_io_by_type.cpp
@@ -12,12 +12,12 @@
#include <libpldm/base.h>
#include <libpldm/oem/ibm/file_io.h>
-#include <stdint.h>
#include <unistd.h>
#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Logging/Entry/server.hpp>
+#include <cstdint>
#include <exception>
#include <filesystem>
#include <fstream>
diff --git a/oem/ibm/libpldmresponder/file_io_type_cert.cpp b/oem/ibm/libpldmresponder/file_io_type_cert.cpp
index 402a003..e655027 100644
--- a/oem/ibm/libpldmresponder/file_io_type_cert.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_cert.cpp
@@ -4,10 +4,11 @@
#include <libpldm/base.h>
#include <libpldm/oem/ibm/file_io.h>
-#include <stdint.h>
#include <phosphor-logging/lg2.hpp>
+#include <cstdint>
+
PHOSPHOR_LOG2_USING;
namespace pldm
diff --git a/oem/ibm/libpldmresponder/file_io_type_dump.cpp b/oem/ibm/libpldmresponder/file_io_type_dump.cpp
index 2abd726..e936acb 100644
--- a/oem/ibm/libpldmresponder/file_io_type_dump.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_dump.cpp
@@ -6,7 +6,6 @@
#include <libpldm/base.h>
#include <libpldm/oem/ibm/file_io.h>
-#include <stdint.h>
#include <systemd/sd-bus.h>
#include <unistd.h>
@@ -14,6 +13,7 @@
#include <sdbusplus/server.hpp>
#include <xyz/openbmc_project/Dump/NewDump/server.hpp>
+#include <cstdint>
#include <exception>
#include <filesystem>
#include <type_traits>
diff --git a/oem/ibm/libpldmresponder/file_io_type_pcie.cpp b/oem/ibm/libpldmresponder/file_io_type_pcie.cpp
index 0c165aa..a6665f6 100644
--- a/oem/ibm/libpldmresponder/file_io_type_pcie.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_pcie.cpp
@@ -2,10 +2,11 @@
#include <libpldm/base.h>
#include <libpldm/oem/ibm/file_io.h>
-#include <stdint.h>
#include <phosphor-logging/lg2.hpp>
+#include <cstdint>
+
PHOSPHOR_LOG2_USING;
namespace pldm
diff --git a/oem/ibm/libpldmresponder/file_io_type_pel.cpp b/oem/ibm/libpldmresponder/file_io_type_pel.cpp
index 685bff2..6c480ae 100644
--- a/oem/ibm/libpldmresponder/file_io_type_pel.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_pel.cpp
@@ -5,7 +5,6 @@
#include <libpldm/base.h>
#include <libpldm/oem/ibm/file_io.h>
-#include <stdint.h>
#include <systemd/sd-bus.h>
#include <unistd.h>
@@ -14,6 +13,7 @@
#include <sdbusplus/server.hpp>
#include <xyz/openbmc_project/Logging/Entry/server.hpp>
+#include <cstdint>
#include <exception>
#include <filesystem>
#include <fstream>
diff --git a/oem/ibm/libpldmresponder/file_io_type_vpd.cpp b/oem/ibm/libpldmresponder/file_io_type_vpd.cpp
index fede599..697ad98 100644
--- a/oem/ibm/libpldmresponder/file_io_type_vpd.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_vpd.cpp
@@ -4,10 +4,11 @@
#include <libpldm/base.h>
#include <libpldm/oem/ibm/file_io.h>
-#include <stdint.h>
#include <phosphor-logging/lg2.hpp>
+#include <cstdint>
+
PHOSPHOR_LOG2_USING;
typedef uint8_t byte;
diff --git a/oem/ibm/libpldmresponder/file_table.hpp b/oem/ibm/libpldmresponder/file_table.hpp
index 502e714..76ac959 100644
--- a/oem/ibm/libpldmresponder/file_table.hpp
+++ b/oem/ibm/libpldmresponder/file_table.hpp
@@ -1,10 +1,10 @@
#pragma once
#include <libpldm/pldm_types.h>
-#include <stdint.h>
#include <nlohmann/json.hpp>
+#include <cstdint>
#include <filesystem>
#include <vector>
diff --git a/oem/ibm/test/host_bmc_lamp_test.cpp b/oem/ibm/test/host_bmc_lamp_test.cpp
index 26dc4fc..15c62c0 100644
--- a/oem/ibm/test/host_bmc_lamp_test.cpp
+++ b/oem/ibm/test/host_bmc_lamp_test.cpp
@@ -2,7 +2,7 @@
#include "pldmd/dbus_impl_requester.hpp"
#include "test/test_instance_id.hpp"
-#include <string.h>
+#include <cstring>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
diff --git a/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index 8941418..46c216a 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -19,7 +19,6 @@
#include <libpldm/platform.h>
#include <libpldm/transport.h>
#include <poll.h>
-#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
@@ -32,6 +31,7 @@
#include <stdplus/signal.hpp>
#include <cstdio>
+#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
diff --git a/pldmtool/oem/ibm/oem_ibm_state_set.hpp b/pldmtool/oem/ibm/oem_ibm_state_set.hpp
index 2d1ee25..b467b35 100644
--- a/pldmtool/oem/ibm/oem_ibm_state_set.hpp
+++ b/pldmtool/oem/ibm/oem_ibm_state_set.hpp
@@ -1,8 +1,8 @@
#include <libpldm/entity.h>
#include <libpldm/oem/ibm/entity.h>
#include <libpldm/oem/ibm/state_set.h>
-#include <stdint.h>
+#include <cstdint>
#include <map>
#include <string>
diff --git a/test/test_instance_id.hpp b/test/test_instance_id.hpp
index fee0000..2ca9d7b 100644
--- a/test/test_instance_id.hpp
+++ b/test/test_instance_id.hpp
@@ -2,9 +2,9 @@
#include "common/instance_id.hpp"
-#include <string.h>
#include <unistd.h>
+#include <cstring>
#include <filesystem>
static constexpr uintmax_t pldmMaxInstanceIds = 32;