Fix includes using iwyu tool
These changes are done by running iwyu manually under clang14.
IWYU can increase readability, make maintenance easier, and avoid errors
in some cases. See details in
```
https: //github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md.
```
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: Idaaeffd78c9ad7db2b41a057d40f889ade297c55
diff --git a/include/libpldm/bios.h b/include/libpldm/bios.h
index a23a671..c8f480a 100644
--- a/include/libpldm/bios.h
+++ b/include/libpldm/bios.h
@@ -5,13 +5,9 @@
extern "C" {
#endif
-#include <asm/byteorder.h>
#include <stddef.h>
#include <stdint.h>
-#include "base.h"
-#include "utils.h"
-
/* Response lengths are inclusive of completion code */
#define PLDM_GET_DATE_TIME_RESP_BYTES 8
@@ -45,6 +41,9 @@
PLDM_BIOS_ATTR_VAL_TABLE,
};
+struct pldm_msg;
+struct variable_field;
+
struct pldm_bios_string_table_entry {
uint16_t string_handle;
uint16_t string_length;
diff --git a/include/libpldm/bios_table.h b/include/libpldm/bios_table.h
index 284efcb..f4796aa 100644
--- a/include/libpldm/bios_table.h
+++ b/include/libpldm/bios_table.h
@@ -6,10 +6,10 @@
#endif
#include "bios.h"
-#include "utils.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
+struct variable_field;
/** @struct pldm_bios_table_iter
* structure representing bios table iterator
diff --git a/include/libpldm/firmware_update.h b/include/libpldm/firmware_update.h
index 0dc5e4b..eb02558 100644
--- a/include/libpldm/firmware_update.h
+++ b/include/libpldm/firmware_update.h
@@ -4,9 +4,13 @@
#ifdef __cplusplus
extern "C" {
#endif
+
#include "base.h"
+#include "pldm_types.h"
#include "stdbool.h"
-#include "utils.h"
+#include <stddef.h>
+#include <stdint.h>
+struct variable_field;
#define PLDM_FWUP_COMPONENT_BITMAP_MULTIPLE 8
#define PLDM_FWUP_INVALID_COMPONENT_COMPARISON_TIMESTAMP 0xFFFFFFFF
diff --git a/include/libpldm/oem/ibm/libpldm/file_io.h b/include/libpldm/oem/ibm/libpldm/file_io.h
index c78627f..10963bc 100644
--- a/include/libpldm/oem/ibm/libpldm/file_io.h
+++ b/include/libpldm/oem/ibm/libpldm/file_io.h
@@ -8,8 +8,7 @@
#include <stddef.h>
#include <stdint.h>
-#include "base.h"
-
+struct pldm_msg;
/** @brief PLDM Commands in IBM OEM type
*/
enum pldm_fileio_commands {
diff --git a/include/libpldm/oem/ibm/libpldm/platform_oem_ibm.h b/include/libpldm/oem/ibm/libpldm/platform_oem_ibm.h
index f0aafd3..b0c781c 100644
--- a/include/libpldm/oem/ibm/libpldm/platform_oem_ibm.h
+++ b/include/libpldm/oem/ibm/libpldm/platform_oem_ibm.h
@@ -53,4 +53,4 @@
}
#endif
-#endif /* PLATFORM_OEM_IBM_H */
\ No newline at end of file
+#endif /* PLATFORM_OEM_IBM_H */
diff --git a/include/libpldm/platform.h b/include/libpldm/platform.h
index c6f992d..c595052 100644
--- a/include/libpldm/platform.h
+++ b/include/libpldm/platform.h
@@ -10,6 +10,7 @@
#include "base.h"
#include "pdr.h"
+#include "pldm_types.h"
/* Maximum size for request */
#define PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES 19
diff --git a/src/base.c b/src/base.c
index 86bacea..5e652cc 100644
--- a/src/base.c
+++ b/src/base.c
@@ -1,7 +1,8 @@
-#include <endian.h>
-#include <string.h>
-
#include "base.h"
+#include "pldm_types.h"
+#include <endian.h>
+#include <stdint.h>
+#include <string.h>
uint8_t pack_pldm_header(const struct pldm_header_info *hdr,
struct pldm_msg_hdr *msg)
diff --git a/src/bios.c b/src/bios.c
index 8d93a6a..d9c4c3e 100644
--- a/src/bios.c
+++ b/src/bios.c
@@ -1,7 +1,7 @@
#include "bios.h"
+#include "base.h"
#include "utils.h"
#include <endian.h>
-#include <stdbool.h>
#include <string.h>
int encode_get_date_time_req(uint8_t instance_id, struct pldm_msg *msg)
diff --git a/src/bios_table.c b/src/bios_table.c
index ea9f669..d7735e1 100644
--- a/src/bios_table.c
+++ b/src/bios_table.c
@@ -1,3 +1,7 @@
+#include "bios_table.h"
+#include "base.h"
+#include "bios.h"
+#include "utils.h"
#include <assert.h>
#include <endian.h>
#include <stdbool.h>
@@ -5,9 +9,6 @@
#include <stdlib.h>
#include <string.h>
-#include "bios.h"
-#include "bios_table.h"
-
#define POINTER_CHECK(pointer) \
do { \
if (pointer == NULL) \
diff --git a/src/firmware_update.c b/src/firmware_update.c
index 59d1f9d..bd6ed9a 100644
--- a/src/firmware_update.c
+++ b/src/firmware_update.c
@@ -1,5 +1,7 @@
#include "firmware_update.h"
+#include "utils.h"
#include <endian.h>
+#include <stdbool.h>
#include <string.h>
/** @brief Check whether string type value is valid
diff --git a/src/fru.c b/src/fru.c
index fa79f2b..be9d411 100644
--- a/src/fru.c
+++ b/src/fru.c
@@ -1,9 +1,12 @@
#include <assert.h>
#include <endian.h>
#include <stdbool.h>
+#include <stdint.h>
#include <string.h>
+#include "base.h"
#include "fru.h"
+#include "utils.h"
int encode_get_fru_record_table_metadata_req(uint8_t instance_id,
struct pldm_msg *msg,
diff --git a/src/oem/ibm/file_io.c b/src/oem/ibm/file_io.c
index b3464cb..79132a1 100644
--- a/src/oem/ibm/file_io.c
+++ b/src/oem/ibm/file_io.c
@@ -1,4 +1,5 @@
#include "libpldm/file_io.h"
+#include "base.h"
#include <endian.h>
#include <string.h>
diff --git a/src/oem/ibm/host.c b/src/oem/ibm/host.c
index d557a41..5cdcf74 100644
--- a/src/oem/ibm/host.c
+++ b/src/oem/ibm/host.c
@@ -1,4 +1,6 @@
+#include "base.h"
#include <endian.h>
+#include <stdint.h>
#include <string.h>
#include "libpldm/host.h"
diff --git a/src/pdr.c b/src/pdr.c
index b057e3d..fe28aa9 100644
--- a/src/pdr.c
+++ b/src/pdr.c
@@ -1,6 +1,7 @@
#include "pdr.h"
#include "platform.h"
#include <assert.h>
+#include <endian.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/platform.c b/src/platform.c
index 492fe65..00dc019 100644
--- a/src/platform.c
+++ b/src/platform.c
@@ -1,4 +1,7 @@
+#include "base.h"
+#include "pldm_types.h"
#include <endian.h>
+#include <stdint.h>
#include <string.h>
#include "platform.h"
diff --git a/src/requester/pldm.c b/src/requester/pldm.c
index 932f55e..34f0c30 100644
--- a/src/requester/pldm.c
+++ b/src/requester/pldm.c
@@ -1,10 +1,10 @@
#include "pldm.h"
#include "base.h"
-#include <errno.h>
+#include <bits/types/struct_iovec.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/socket.h>
-#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
diff --git a/tests/libpldm_base_test.cpp b/tests/libpldm_base_test.cpp
index cb36663..7d67009 100644
--- a/tests/libpldm_base_test.cpp
+++ b/tests/libpldm_base_test.cpp
@@ -1,10 +1,10 @@
-#include <string.h>
-
#include <array>
+#include <cstdint>
#include <cstring>
#include <vector>
#include "libpldm/base.h"
+#include "pldm_types.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
diff --git a/tests/libpldm_bios_table_test.cpp b/tests/libpldm_bios_table_test.cpp
index a307264..d8df263 100644
--- a/tests/libpldm_bios_table_test.cpp
+++ b/tests/libpldm_bios_table_test.cpp
@@ -1,7 +1,9 @@
#include <endian.h>
-#include <string.h>
+#include <algorithm>
+#include <cstdint>
#include <cstring>
+#include <iterator>
#include <string>
#include <utility>
#include <vector>
diff --git a/tests/libpldm_bios_test.cpp b/tests/libpldm_bios_test.cpp
index 4733f2d..aa95c66 100644
--- a/tests/libpldm_bios_test.cpp
+++ b/tests/libpldm_bios_test.cpp
@@ -1,6 +1,9 @@
+#include <endian.h>
+#include <stdint.h>
#include <string.h>
#include <array>
+#include <memory>
#include "libpldm/base.h"
#include "libpldm/bios.h"
@@ -1090,4 +1093,4 @@
request, requestMsg.size() - hdrSize - sizeof(tableData) - 1,
&retTransferHandle, &retTransferFlag, &retTableType, &table);
EXPECT_EQ(rc, PLDM_ERROR_INVALID_LENGTH);
-}
\ No newline at end of file
+}
diff --git a/tests/libpldm_firmware_update_test.cpp b/tests/libpldm_firmware_update_test.cpp
index 756097f..a9316a7 100644
--- a/tests/libpldm_firmware_update_test.cpp
+++ b/tests/libpldm_firmware_update_test.cpp
@@ -1,8 +1,18 @@
+#include <endian.h>
+
+#include <algorithm>
+#include <array>
#include <bitset>
+#include <cstdint>
#include <cstring>
+#include <string>
+#include <string_view>
+#include <vector>
#include "libpldm/base.h"
#include "libpldm/firmware_update.h"
+#include "pldm_types.h"
+#include "utils.h"
#include <gtest/gtest.h>
@@ -870,12 +880,6 @@
// 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01};
constexpr std::string_view activeCompVersion{"VersionString3"};
constexpr std::string_view pendingCompVersion{"VersionString4"};
- // ComponentActivationMethods
- // DC Power cycle [Bit position 4] & Self-Contained[Bit position 2]
- constexpr std::bitset<16> compActivationMethod{0x12};
- // CapabilitiesDuringUpdate of the firmware component
- // Component downgrade capability [Bit position 2]
- constexpr std::bitset<32> compCapabilities{0x02};
constexpr size_t compParamTableSize =
sizeof(pldm_component_parameter_entry) + activeCompVersion.size() +
diff --git a/tests/libpldm_fru_test.cpp b/tests/libpldm_fru_test.cpp
index 0419826..e1d2a11 100644
--- a/tests/libpldm_fru_test.cpp
+++ b/tests/libpldm_fru_test.cpp
@@ -1,10 +1,13 @@
-#include <string.h>
+#include <endian.h>
#include <array>
+#include <cstdint>
#include <cstring>
+#include <vector>
#include "libpldm/base.h"
#include "libpldm/fru.h"
+#include "utils.h"
#include <gtest/gtest.h>
diff --git a/tests/libpldm_pdr_test.cpp b/tests/libpldm_pdr_test.cpp
index 666145a..8c572fc 100644
--- a/tests/libpldm_pdr_test.cpp
+++ b/tests/libpldm_pdr_test.cpp
@@ -1,4 +1,10 @@
+#include <endian.h>
+#include <stdlib.h>
+#include <string.h>
+
#include <array>
+#include <cstdint>
+#include <vector>
#include "libpldm/pdr.h"
#include "libpldm/platform.h"
diff --git a/tests/libpldm_platform_test.cpp b/tests/libpldm_platform_test.cpp
index 329f4ff..b62125b 100644
--- a/tests/libpldm_platform_test.cpp
+++ b/tests/libpldm_platform_test.cpp
@@ -1,9 +1,13 @@
+#include <endian.h>
#include <string.h>
#include <array>
+#include <cstdint>
+#include <vector>
#include "libpldm/base.h"
#include "libpldm/platform.h"
+#include "pldm_types.h"
#include <gtest/gtest.h>
diff --git a/tests/libpldm_utils_test.cpp b/tests/libpldm_utils_test.cpp
index a6212c0..663a531 100644
--- a/tests/libpldm_utils_test.cpp
+++ b/tests/libpldm_utils_test.cpp
@@ -2,6 +2,7 @@
#include <vector>
#include "libpldm/utils.h"
+#include "pldm_types.h"
#include <gtest/gtest.h>
diff --git a/tests/oem/ibm/libpldm_fileio_test.cpp b/tests/oem/ibm/libpldm_fileio_test.cpp
index f6c94e7..deba7b9 100644
--- a/tests/oem/ibm/libpldm_fileio_test.cpp
+++ b/tests/oem/ibm/libpldm_fileio_test.cpp
@@ -1,6 +1,9 @@
+#include <endian.h>
#include <string.h>
#include <array>
+#include <cstdint>
+#include <vector>
#include "libpldm/base.h"
#include "libpldm/file_io.h"
diff --git a/tests/oem/ibm/libpldm_host_test.cpp b/tests/oem/ibm/libpldm_host_test.cpp
index 26ae5aa..2ab03b7 100644
--- a/tests/oem/ibm/libpldm_host_test.cpp
+++ b/tests/oem/ibm/libpldm_host_test.cpp
@@ -1,7 +1,11 @@
+#include <endian.h>
#include <string.h>
#include <array>
+#include <cstdint>
+#include <vector>
+#include "base.h"
#include "oem/ibm/libpldm/host.h"
#include <gtest/gtest.h>