clang-format: copy latest and re-format
clang-format-16 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest .clang-format from the docs repository[1] and reformat
the repository.
[1] https://gerrit.openbmc.org/c/openbmc/docs/+/63441
Further, shift the fixup for C's `_Static_assert` into src/msgbuf.h to
prevent a clang-tidy-16 error:
```
/data0/jenkins/workspace/ci-repository/openbmc/libpldm/src/msgbuf.h:315:2: error: '_Static_assert' is a C11 extension [clang-diagnostic-c11-extensions,-warnings-as-errors]
_Static_assert(sizeof(*dst) == sizeof(ldst),
^
```
And fix up the function prototype in the definition of `pldm_open()`:
```
../src/requester/pldm.c:128:16: error: a function declaration without a prototype is deprecated in all versions of C [clang-diagnostic-strict-prototypes,-warnings-as-errors]
void pldm_close()
^
void
```
Change-Id: I57b53f51914e39237e733d024e62ab41b3d306c1
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/src/oem/ibm/file_io.c b/src/oem/ibm/file_io.c
index 79132a1..10af817 100644
--- a/src/oem/ibm/file_io.c
+++ b/src/oem/ibm/file_io.c
@@ -17,7 +17,7 @@
}
struct pldm_read_write_file_memory_req *request =
- (struct pldm_read_write_file_memory_req *)msg->payload;
+ (struct pldm_read_write_file_memory_req *)msg->payload;
*file_handle = le32toh(request->file_handle);
*offset = le32toh(request->offset);
@@ -35,7 +35,7 @@
return PLDM_ERROR_INVALID_LENGTH;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_RESPONSE;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -46,7 +46,7 @@
}
struct pldm_read_write_file_memory_resp *response =
- (struct pldm_read_write_file_memory_resp *)msg->payload;
+ (struct pldm_read_write_file_memory_resp *)msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
response->length = htole32(length);
@@ -64,7 +64,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_REQUEST;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -75,7 +75,7 @@
}
struct pldm_read_write_file_memory_req *req =
- (struct pldm_read_write_file_memory_req *)msg->payload;
+ (struct pldm_read_write_file_memory_req *)msg->payload;
req->file_handle = htole32(file_handle);
req->offset = htole32(offset);
req->length = htole32(length);
@@ -96,7 +96,7 @@
}
struct pldm_read_write_file_memory_resp *response =
- (struct pldm_read_write_file_memory_resp *)msg->payload;
+ (struct pldm_read_write_file_memory_resp *)msg->payload;
*completion_code = response->completion_code;
if (*completion_code == PLDM_SUCCESS) {
*length = le32toh(response->length);
@@ -119,7 +119,7 @@
}
struct pldm_get_file_table_req *request =
- (struct pldm_get_file_table_req *)msg->payload;
+ (struct pldm_get_file_table_req *)msg->payload;
*transfer_handle = le32toh(request->transfer_handle);
*transfer_opflag = request->operation_flag;
@@ -137,7 +137,7 @@
return PLDM_ERROR_INVALID_LENGTH;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_RESPONSE;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -148,7 +148,7 @@
}
struct pldm_get_file_table_resp *response =
- (struct pldm_get_file_table_resp *)msg->payload;
+ (struct pldm_get_file_table_resp *)msg->payload;
response->completion_code = completion_code;
if (completion_code == PLDM_SUCCESS) {
@@ -168,7 +168,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_REQUEST;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -179,7 +179,7 @@
}
struct pldm_get_file_table_req *request =
- (struct pldm_get_file_table_req *)msg->payload;
+ (struct pldm_get_file_table_req *)msg->payload;
request->transfer_handle = htole32(transfer_handle);
request->operation_flag = transfer_opflag;
@@ -211,7 +211,7 @@
}
struct pldm_get_file_table_resp *response =
- (struct pldm_get_file_table_resp *)msg->payload;
+ (struct pldm_get_file_table_resp *)msg->payload;
*next_transfer_handle = le32toh(response->next_transfer_handle);
*transfer_flag = response->transfer_flag;
@@ -219,7 +219,7 @@
sizeof(*next_transfer_handle) +
sizeof(*transfer_flag);
*file_table_length =
- payload_length - PLDM_GET_FILE_TABLE_MIN_RESP_BYTES;
+ payload_length - PLDM_GET_FILE_TABLE_MIN_RESP_BYTES;
return PLDM_SUCCESS;
}
@@ -238,7 +238,7 @@
}
struct pldm_read_file_req *request =
- (struct pldm_read_file_req *)msg->payload;
+ (struct pldm_read_file_req *)msg->payload;
*file_handle = le32toh(request->file_handle);
*offset = le32toh(request->offset);
@@ -258,7 +258,7 @@
return PLDM_ERROR_INVALID_LENGTH;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_REQUEST;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -269,7 +269,7 @@
}
struct pldm_read_file_req *request =
- (struct pldm_read_file_req *)msg->payload;
+ (struct pldm_read_file_req *)msg->payload;
request->file_handle = htole32(file_handle);
request->offset = htole32(offset);
@@ -291,7 +291,7 @@
}
struct pldm_read_file_resp *response =
- (struct pldm_read_file_resp *)msg->payload;
+ (struct pldm_read_file_resp *)msg->payload;
*completion_code = response->completion_code;
if (*completion_code == PLDM_SUCCESS) {
@@ -312,7 +312,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_RESPONSE;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -323,7 +323,7 @@
}
struct pldm_read_file_resp *response =
- (struct pldm_read_file_resp *)msg->payload;
+ (struct pldm_read_file_resp *)msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
@@ -346,7 +346,7 @@
}
struct pldm_write_file_req *request =
- (struct pldm_write_file_req *)msg->payload;
+ (struct pldm_write_file_req *)msg->payload;
*file_handle = le32toh(request->file_handle);
*offset = le32toh(request->offset);
@@ -355,7 +355,7 @@
return PLDM_ERROR_INVALID_LENGTH;
}
*file_data_offset =
- sizeof(*file_handle) + sizeof(*offset) + sizeof(*length);
+ sizeof(*file_handle) + sizeof(*offset) + sizeof(*length);
return PLDM_SUCCESS;
}
@@ -372,7 +372,7 @@
return PLDM_ERROR_INVALID_LENGTH;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_REQUEST;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -383,7 +383,7 @@
}
struct pldm_write_file_req *request =
- (struct pldm_write_file_req *)msg->payload;
+ (struct pldm_write_file_req *)msg->payload;
request->file_handle = htole32(file_handle);
request->offset = htole32(offset);
@@ -404,7 +404,7 @@
}
struct pldm_write_file_resp *response =
- (struct pldm_write_file_resp *)msg->payload;
+ (struct pldm_write_file_resp *)msg->payload;
*completion_code = le32toh(response->completion_code);
if (response->completion_code == PLDM_SUCCESS) {
@@ -421,7 +421,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_RESPONSE;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -432,7 +432,7 @@
}
struct pldm_write_file_resp *response =
- (struct pldm_write_file_resp *)msg->payload;
+ (struct pldm_write_file_resp *)msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
@@ -458,7 +458,7 @@
}
struct pldm_read_write_file_by_type_memory_req *request =
- (struct pldm_read_write_file_by_type_memory_req *)msg->payload;
+ (struct pldm_read_write_file_by_type_memory_req *)msg->payload;
*file_type = le16toh(request->file_type);
*file_handle = le32toh(request->file_handle);
*offset = le32toh(request->offset);
@@ -476,7 +476,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_RESPONSE;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -487,7 +487,7 @@
}
struct pldm_read_write_file_by_type_memory_resp *response =
- (struct pldm_read_write_file_by_type_memory_resp *)msg->payload;
+ (struct pldm_read_write_file_by_type_memory_resp *)msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
response->length = htole32(length);
@@ -505,7 +505,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_REQUEST;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -516,7 +516,7 @@
}
struct pldm_read_write_file_by_type_memory_req *req =
- (struct pldm_read_write_file_by_type_memory_req *)msg->payload;
+ (struct pldm_read_write_file_by_type_memory_req *)msg->payload;
req->file_type = htole16(file_type);
req->file_handle = htole32(file_handle);
req->offset = htole32(offset);
@@ -540,7 +540,7 @@
}
struct pldm_read_write_file_by_type_memory_resp *response =
- (struct pldm_read_write_file_by_type_memory_resp *)msg->payload;
+ (struct pldm_read_write_file_by_type_memory_resp *)msg->payload;
*completion_code = response->completion_code;
if (*completion_code == PLDM_SUCCESS) {
*length = le32toh(response->length);
@@ -563,7 +563,7 @@
}
struct pldm_new_file_req *request =
- (struct pldm_new_file_req *)msg->payload;
+ (struct pldm_new_file_req *)msg->payload;
*file_type = le16toh(request->file_type);
*file_handle = le32toh(request->file_handle);
*length = le64toh(request->length);
@@ -578,7 +578,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_RESPONSE;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -589,7 +589,7 @@
}
struct pldm_new_file_resp *response =
- (struct pldm_new_file_resp *)msg->payload;
+ (struct pldm_new_file_resp *)msg->payload;
response->completion_code = completion_code;
return PLDM_SUCCESS;
@@ -603,7 +603,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_REQUEST;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -614,7 +614,7 @@
}
struct pldm_new_file_req *req =
- (struct pldm_new_file_req *)msg->payload;
+ (struct pldm_new_file_req *)msg->payload;
req->file_type = htole16(file_type);
req->file_handle = htole32(file_handle);
req->length = htole64(length);
@@ -634,7 +634,7 @@
}
struct pldm_new_file_resp *response =
- (struct pldm_new_file_resp *)msg->payload;
+ (struct pldm_new_file_resp *)msg->payload;
*completion_code = response->completion_code;
return PLDM_SUCCESS;
@@ -655,7 +655,7 @@
}
struct pldm_read_write_file_by_type_req *request =
- (struct pldm_read_write_file_by_type_req *)msg->payload;
+ (struct pldm_read_write_file_by_type_req *)msg->payload;
*file_type = le16toh(request->file_type);
*file_handle = le32toh(request->file_handle);
*offset = le32toh(request->offset);
@@ -676,7 +676,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_RESPONSE;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -687,7 +687,7 @@
}
struct pldm_read_write_file_by_type_resp *response =
- (struct pldm_read_write_file_by_type_resp *)msg->payload;
+ (struct pldm_read_write_file_by_type_resp *)msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
response->length = htole32(length);
@@ -709,7 +709,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_REQUEST;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -720,7 +720,7 @@
}
struct pldm_read_write_file_by_type_req *req =
- (struct pldm_read_write_file_by_type_req *)msg->payload;
+ (struct pldm_read_write_file_by_type_req *)msg->payload;
req->file_type = htole16(file_type);
req->file_handle = htole32(file_handle);
req->offset = htole32(offset);
@@ -742,7 +742,7 @@
}
struct pldm_read_write_file_by_type_resp *response =
- (struct pldm_read_write_file_by_type_resp *)msg->payload;
+ (struct pldm_read_write_file_by_type_resp *)msg->payload;
*completion_code = response->completion_code;
if (*completion_code == PLDM_SUCCESS) {
*length = le32toh(response->length);
@@ -764,7 +764,7 @@
}
struct pldm_file_ack_req *request =
- (struct pldm_file_ack_req *)msg->payload;
+ (struct pldm_file_ack_req *)msg->payload;
*file_type = le16toh(request->file_type);
*file_handle = le32toh(request->file_handle);
*file_status = request->file_status;
@@ -779,7 +779,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_RESPONSE;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -790,7 +790,7 @@
}
struct pldm_file_ack_resp *response =
- (struct pldm_file_ack_resp *)msg->payload;
+ (struct pldm_file_ack_resp *)msg->payload;
response->completion_code = completion_code;
return PLDM_SUCCESS;
@@ -804,7 +804,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_REQUEST;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -815,7 +815,7 @@
}
struct pldm_file_ack_req *req =
- (struct pldm_file_ack_req *)msg->payload;
+ (struct pldm_file_ack_req *)msg->payload;
req->file_type = htole16(file_type);
req->file_handle = htole32(file_handle);
req->file_status = file_status;
@@ -835,22 +835,23 @@
}
struct pldm_file_ack_resp *response =
- (struct pldm_file_ack_resp *)msg->payload;
+ (struct pldm_file_ack_resp *)msg->payload;
*completion_code = response->completion_code;
return PLDM_SUCCESS;
}
int encode_file_ack_with_meta_data_req(
- uint8_t instance_id, uint16_t file_type, uint32_t file_handle,
- uint8_t file_status, uint32_t file_meta_data_1, uint32_t file_meta_data_2,
- uint32_t file_meta_data_3, uint32_t file_meta_data_4, struct pldm_msg *msg)
+ uint8_t instance_id, uint16_t file_type, uint32_t file_handle,
+ uint8_t file_status, uint32_t file_meta_data_1,
+ uint32_t file_meta_data_2, uint32_t file_meta_data_3,
+ uint32_t file_meta_data_4, struct pldm_msg *msg)
{
if (msg == NULL) {
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_REQUEST;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -861,7 +862,7 @@
}
struct pldm_file_ack_with_meta_data_req *req =
- (struct pldm_file_ack_with_meta_data_req *)msg->payload;
+ (struct pldm_file_ack_with_meta_data_req *)msg->payload;
req->file_type = htole16(file_type);
req->file_handle = htole32(file_handle);
req->file_status = file_status;
@@ -886,17 +887,17 @@
}
struct pldm_file_ack_with_meta_data_resp *response =
- (struct pldm_file_ack_with_meta_data_resp *)msg->payload;
+ (struct pldm_file_ack_with_meta_data_resp *)msg->payload;
*completion_code = response->completion_code;
return PLDM_SUCCESS;
}
int decode_file_ack_with_meta_data_req(
- const struct pldm_msg *msg, size_t payload_length, uint16_t *file_type,
- uint32_t *file_handle, uint8_t *file_status, uint32_t *file_meta_data_1,
- uint32_t *file_meta_data_2, uint32_t *file_meta_data_3,
- uint32_t *file_meta_data_4)
+ const struct pldm_msg *msg, size_t payload_length, uint16_t *file_type,
+ uint32_t *file_handle, uint8_t *file_status, uint32_t *file_meta_data_1,
+ uint32_t *file_meta_data_2, uint32_t *file_meta_data_3,
+ uint32_t *file_meta_data_4)
{
if (msg == NULL || file_type == NULL || file_handle == NULL) {
return PLDM_ERROR_INVALID_DATA;
@@ -907,7 +908,7 @@
}
struct pldm_file_ack_with_meta_data_req *request =
- (struct pldm_file_ack_with_meta_data_req *)msg->payload;
+ (struct pldm_file_ack_with_meta_data_req *)msg->payload;
*file_type = le16toh(request->file_type);
*file_handle = le32toh(request->file_handle);
*file_status = request->file_status;
@@ -927,7 +928,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_RESPONSE;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -938,22 +939,25 @@
}
struct pldm_file_ack_with_meta_data_resp *response =
- (struct pldm_file_ack_with_meta_data_resp *)msg->payload;
+ (struct pldm_file_ack_with_meta_data_resp *)msg->payload;
response->completion_code = completion_code;
return PLDM_SUCCESS;
}
-int encode_new_file_with_metadata_req(
- uint8_t instance_id, uint16_t file_type, uint32_t file_handle,
- uint64_t length, uint32_t file_meta_data_1, uint32_t file_meta_data_2,
- uint32_t file_meta_data_3, uint32_t file_meta_data_4, struct pldm_msg *msg)
+int encode_new_file_with_metadata_req(uint8_t instance_id, uint16_t file_type,
+ uint32_t file_handle, uint64_t length,
+ uint32_t file_meta_data_1,
+ uint32_t file_meta_data_2,
+ uint32_t file_meta_data_3,
+ uint32_t file_meta_data_4,
+ struct pldm_msg *msg)
{
if (msg == NULL) {
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_REQUEST;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -964,7 +968,7 @@
}
struct pldm_new_file_with_metadata_req *req =
- (struct pldm_new_file_with_metadata_req *)msg->payload;
+ (struct pldm_new_file_with_metadata_req *)msg->payload;
req->file_type = htole16(file_type);
req->file_handle = htole32(file_handle);
req->length = htole64(length);
@@ -990,7 +994,7 @@
}
struct pldm_new_file_with_metadata_resp *response =
- (struct pldm_new_file_with_metadata_resp *)msg->payload;
+ (struct pldm_new_file_with_metadata_resp *)msg->payload;
*completion_code = msg->payload[0];
if (*completion_code == PLDM_SUCCESS) {
@@ -1000,10 +1004,10 @@
}
int decode_new_file_with_metadata_req(
- const struct pldm_msg *msg, size_t payload_length, uint16_t *file_type,
- uint32_t *file_handle, uint64_t *length, uint32_t *file_meta_data_1,
- uint32_t *file_meta_data_2, uint32_t *file_meta_data_3,
- uint32_t *file_meta_data_4)
+ const struct pldm_msg *msg, size_t payload_length, uint16_t *file_type,
+ uint32_t *file_handle, uint64_t *length, uint32_t *file_meta_data_1,
+ uint32_t *file_meta_data_2, uint32_t *file_meta_data_3,
+ uint32_t *file_meta_data_4)
{
if (msg == NULL || file_type == NULL || file_handle == NULL ||
length == NULL) {
@@ -1016,7 +1020,7 @@
}
struct pldm_new_file_with_metadata_req *request =
- (struct pldm_new_file_with_metadata_req *)msg->payload;
+ (struct pldm_new_file_with_metadata_req *)msg->payload;
*file_type = le16toh(request->file_type);
*file_handle = le32toh(request->file_handle);
*length = le64toh(request->length);
@@ -1036,7 +1040,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = PLDM_RESPONSE;
header.instance = instance_id;
header.pldm_type = PLDM_OEM;
@@ -1047,7 +1051,7 @@
}
struct pldm_new_file_with_metadata_resp *response =
- (struct pldm_new_file_with_metadata_resp *)msg->payload;
+ (struct pldm_new_file_with_metadata_resp *)msg->payload;
if (response->completion_code == PLDM_SUCCESS) {
response->completion_code = completion_code;