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/fru.c b/src/fru.c
index be9d411..684a559 100644
--- a/src/fru.c
+++ b/src/fru.c
@@ -20,7 +20,7 @@
return PLDM_ERROR_INVALID_LENGTH;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.instance = instance_id;
header.msg_type = PLDM_REQUEST;
header.pldm_type = PLDM_FRU;
@@ -30,11 +30,11 @@
}
int decode_get_fru_record_table_metadata_resp(
- const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
- uint8_t *fru_data_major_version, uint8_t *fru_data_minor_version,
- uint32_t *fru_table_maximum_size, uint32_t *fru_table_length,
- uint16_t *total_record_set_identifiers, uint16_t *total_table_records,
- uint32_t *checksum)
+ const struct pldm_msg *msg, size_t payload_length,
+ uint8_t *completion_code, uint8_t *fru_data_major_version,
+ uint8_t *fru_data_minor_version, uint32_t *fru_table_maximum_size,
+ uint32_t *fru_table_length, uint16_t *total_record_set_identifiers,
+ uint16_t *total_table_records, uint32_t *checksum)
{
if (msg == NULL || completion_code == NULL ||
fru_data_major_version == NULL || fru_data_minor_version == NULL ||
@@ -54,14 +54,14 @@
}
struct pldm_get_fru_record_table_metadata_resp *response =
- (struct pldm_get_fru_record_table_metadata_resp *)msg->payload;
+ (struct pldm_get_fru_record_table_metadata_resp *)msg->payload;
*fru_data_major_version = response->fru_data_major_version;
*fru_data_minor_version = response->fru_data_minor_version;
*fru_table_maximum_size = le32toh(response->fru_table_maximum_size);
*fru_table_length = le32toh(response->fru_table_length);
*total_record_set_identifiers =
- le16toh(response->total_record_set_identifiers);
+ le16toh(response->total_record_set_identifiers);
*total_table_records = le16toh(response->total_table_records);
*checksum = le32toh(response->checksum);
@@ -69,17 +69,17 @@
}
int encode_get_fru_record_table_metadata_resp(
- uint8_t instance_id, uint8_t completion_code,
- uint8_t fru_data_major_version, uint8_t fru_data_minor_version,
- uint32_t fru_table_maximum_size, uint32_t fru_table_length,
- uint16_t total_record_set_identifiers, uint16_t total_table_records,
- uint32_t checksum, struct pldm_msg *msg)
+ uint8_t instance_id, uint8_t completion_code,
+ uint8_t fru_data_major_version, uint8_t fru_data_minor_version,
+ uint32_t fru_table_maximum_size, uint32_t fru_table_length,
+ uint16_t total_record_set_identifiers, uint16_t total_table_records,
+ uint32_t checksum, 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_RESPONSE;
header.instance = instance_id;
header.pldm_type = PLDM_FRU;
@@ -91,16 +91,16 @@
}
struct pldm_get_fru_record_table_metadata_resp *response =
- (struct pldm_get_fru_record_table_metadata_resp *)msg->payload;
+ (struct pldm_get_fru_record_table_metadata_resp *)msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
response->fru_data_major_version = fru_data_major_version;
response->fru_data_minor_version = fru_data_minor_version;
response->fru_table_maximum_size =
- htole32(fru_table_maximum_size);
+ htole32(fru_table_maximum_size);
response->fru_table_length = htole32(fru_table_length);
response->total_record_set_identifiers =
- htole16(total_record_set_identifiers);
+ htole16(total_record_set_identifiers);
response->total_table_records = htole16(total_table_records);
response->checksum = htole32(checksum);
}
@@ -123,7 +123,7 @@
}
struct pldm_get_fru_record_table_req *req =
- (struct pldm_get_fru_record_table_req *)msg->payload;
+ (struct pldm_get_fru_record_table_req *)msg->payload;
*data_transfer_handle = le32toh(req->data_transfer_handle);
*transfer_operation_flag = req->transfer_operation_flag;
@@ -141,7 +141,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_FRU;
@@ -153,14 +153,13 @@
}
struct pldm_get_fru_record_table_resp *resp =
- (struct pldm_get_fru_record_table_resp *)msg->payload;
+ (struct pldm_get_fru_record_table_resp *)msg->payload;
resp->completion_code = completion_code;
if (resp->completion_code == PLDM_SUCCESS) {
-
resp->next_data_transfer_handle =
- htole32(next_data_transfer_handle);
+ htole32(next_data_transfer_handle);
resp->transfer_flag = transfer_flag;
}
@@ -183,7 +182,7 @@
}
struct pldm_fru_record_data_format *record =
- (struct pldm_fru_record_data_format *)(fru_table + *curr_size);
+ (struct pldm_fru_record_data_format *)(fru_table + *curr_size);
record->record_set_id = htole16(record_set_id);
record->record_type = record_type;
record->num_fru_fields = num_frus;
@@ -211,7 +210,7 @@
uint16_t rsi, uint8_t rt, uint8_t ft)
{
const struct pldm_fru_record_data_format *record_data_src =
- (const struct pldm_fru_record_data_format *)table;
+ (const struct pldm_fru_record_data_format *)table;
struct pldm_fru_record_data_format *record_data_dest;
int count = 0;
@@ -228,10 +227,11 @@
i++) {
len = sizeof(*tlv) - 1 + tlv->length;
tlv = (const struct pldm_fru_record_tlv
- *)((char *)tlv + len);
+ *)((char *)tlv + len);
}
record_data_src =
- (const struct pldm_fru_record_data_format *)(tlv);
+ (const struct pldm_fru_record_data_format
+ *)(tlv);
continue;
}
@@ -259,19 +259,18 @@
}
record_data_dest->num_fru_fields = count;
record_data_src =
- (const struct pldm_fru_record_data_format *)(tlv);
+ (const struct pldm_fru_record_data_format *)(tlv);
}
*record_size = pos - record_table;
}
int encode_get_fru_record_by_option_req(
- uint8_t instance_id, uint32_t data_transfer_handle,
- uint16_t fru_table_handle, uint16_t record_set_identifier,
- uint8_t record_type, uint8_t field_type, uint8_t transfer_op_flag,
- struct pldm_msg *msg, size_t payload_length)
+ uint8_t instance_id, uint32_t data_transfer_handle,
+ uint16_t fru_table_handle, uint16_t record_set_identifier,
+ uint8_t record_type, uint8_t field_type, uint8_t transfer_op_flag,
+ struct pldm_msg *msg, size_t payload_length)
{
-
if (msg == NULL) {
return PLDM_ERROR_INVALID_DATA;
}
@@ -281,7 +280,7 @@
return PLDM_ERROR_INVALID_LENGTH;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.instance = instance_id;
header.msg_type = PLDM_REQUEST;
header.pldm_type = PLDM_FRU;
@@ -292,7 +291,7 @@
}
struct pldm_get_fru_record_by_option_req *req =
- (struct pldm_get_fru_record_by_option_req *)msg->payload;
+ (struct pldm_get_fru_record_by_option_req *)msg->payload;
req->data_transfer_handle = htole32(data_transfer_handle);
req->fru_table_handle = htole16(fru_table_handle);
@@ -305,10 +304,10 @@
}
int decode_get_fru_record_by_option_req(
- const struct pldm_msg *msg, size_t payload_length,
- uint32_t *data_transfer_handle, uint16_t *fru_table_handle,
- uint16_t *record_set_identifier, uint8_t *record_type, uint8_t *field_type,
- uint8_t *transfer_op_flag)
+ const struct pldm_msg *msg, size_t payload_length,
+ uint32_t *data_transfer_handle, uint16_t *fru_table_handle,
+ uint16_t *record_set_identifier, uint8_t *record_type,
+ uint8_t *field_type, uint8_t *transfer_op_flag)
{
if (msg == NULL || data_transfer_handle == NULL ||
fru_table_handle == NULL || record_set_identifier == NULL ||
@@ -323,7 +322,7 @@
}
struct pldm_get_fru_record_by_option_req *req =
- (struct pldm_get_fru_record_by_option_req *)msg->payload;
+ (struct pldm_get_fru_record_by_option_req *)msg->payload;
*data_transfer_handle = le32toh(req->data_transfer_handle);
*fru_table_handle = le16toh(req->fru_table_handle);
@@ -351,7 +350,7 @@
return PLDM_ERROR_INVALID_LENGTH;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.instance = instance_id;
header.msg_type = PLDM_RESPONSE;
header.pldm_type = PLDM_FRU;
@@ -362,7 +361,7 @@
}
struct pldm_get_fru_record_by_option_resp *resp =
- (struct pldm_get_fru_record_by_option_resp *)msg->payload;
+ (struct pldm_get_fru_record_by_option_resp *)msg->payload;
resp->completion_code = completion_code;
resp->next_data_transfer_handle = htole32(next_data_transfer_handle);
@@ -376,9 +375,9 @@
}
int decode_get_fru_record_by_option_resp(
- const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
- uint32_t *next_transfer_handle, uint8_t *transfer_flag,
- struct variable_field *fru_structure_data)
+ const struct pldm_msg *msg, size_t payload_length,
+ uint8_t *completion_code, uint32_t *next_transfer_handle,
+ uint8_t *transfer_flag, struct variable_field *fru_structure_data)
{
if (msg == NULL || completion_code == NULL ||
next_transfer_handle == NULL || transfer_flag == NULL ||
@@ -396,13 +395,13 @@
}
struct pldm_get_fru_record_by_option_resp *resp =
- (struct pldm_get_fru_record_by_option_resp *)msg->payload;
+ (struct pldm_get_fru_record_by_option_resp *)msg->payload;
*next_transfer_handle = le32toh(resp->next_data_transfer_handle);
*transfer_flag = resp->transfer_flag;
fru_structure_data->ptr = resp->fru_structure_data;
fru_structure_data->length =
- payload_length - PLDM_GET_FRU_RECORD_BY_OPTION_MIN_RESP_BYTES;
+ payload_length - PLDM_GET_FRU_RECORD_BY_OPTION_MIN_RESP_BYTES;
return PLDM_SUCCESS;
}
@@ -420,7 +419,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_FRU;
@@ -432,7 +431,7 @@
}
struct pldm_get_fru_record_table_req *req =
- (struct pldm_get_fru_record_table_req *)msg->payload;
+ (struct pldm_get_fru_record_table_req *)msg->payload;
req->data_transfer_handle = htole32(data_transfer_handle);
req->transfer_operation_flag = transfer_operation_flag;
@@ -440,10 +439,10 @@
}
int decode_get_fru_record_table_resp_safe(
- const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
- uint32_t *next_data_transfer_handle, uint8_t *transfer_flag,
- uint8_t *fru_record_table_data, size_t *fru_record_table_length,
- size_t max_fru_record_table_length)
+ const struct pldm_msg *msg, size_t payload_length,
+ uint8_t *completion_code, uint32_t *next_data_transfer_handle,
+ uint8_t *transfer_flag, uint8_t *fru_record_table_data,
+ size_t *fru_record_table_length, size_t max_fru_record_table_length)
{
if (msg == NULL || completion_code == NULL ||
next_data_transfer_handle == NULL || transfer_flag == NULL ||
@@ -460,13 +459,13 @@
}
struct pldm_get_fru_record_table_resp *resp =
- (struct pldm_get_fru_record_table_resp *)msg->payload;
+ (struct pldm_get_fru_record_table_resp *)msg->payload;
*next_data_transfer_handle = le32toh(resp->next_data_transfer_handle);
*transfer_flag = resp->transfer_flag;
*fru_record_table_length =
- payload_length - PLDM_GET_FRU_RECORD_TABLE_MIN_RESP_BYTES;
+ payload_length - PLDM_GET_FRU_RECORD_TABLE_MIN_RESP_BYTES;
if (*fru_record_table_length > max_fru_record_table_length) {
return PLDM_ERROR_INVALID_LENGTH;
@@ -478,15 +477,18 @@
return PLDM_SUCCESS;
}
-int decode_get_fru_record_table_resp(
- const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
- uint32_t *next_data_transfer_handle, uint8_t *transfer_flag,
- uint8_t *fru_record_table_data, size_t *fru_record_table_length)
+int decode_get_fru_record_table_resp(const struct pldm_msg *msg,
+ size_t payload_length,
+ uint8_t *completion_code,
+ uint32_t *next_data_transfer_handle,
+ uint8_t *transfer_flag,
+ uint8_t *fru_record_table_data,
+ size_t *fru_record_table_length)
{
return decode_get_fru_record_table_resp_safe(
- msg, payload_length, completion_code, next_data_transfer_handle,
- transfer_flag, fru_record_table_data, fru_record_table_length,
- (size_t)-1);
+ msg, payload_length, completion_code, next_data_transfer_handle,
+ transfer_flag, fru_record_table_data, fru_record_table_length,
+ (size_t)-1);
}
int decode_set_fru_record_table_req(const struct pldm_msg *msg,
@@ -506,12 +508,12 @@
}
struct pldm_set_fru_record_table_req *req =
- (struct pldm_set_fru_record_table_req *)msg->payload;
+ (struct pldm_set_fru_record_table_req *)msg->payload;
*data_transfer_handle = le32toh(req->data_transfer_handle);
*transfer_flag = req->transfer_flag;
fru_table_data->length =
- payload_length - PLDM_SET_FRU_RECORD_TABLE_MIN_REQ_BYTES;
+ payload_length - PLDM_SET_FRU_RECORD_TABLE_MIN_REQ_BYTES;
fru_table_data->ptr = req->fru_record_table_data;
return PLDM_SUCCESS;
@@ -530,7 +532,7 @@
return PLDM_ERROR_INVALID_LENGTH;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.instance = instance_id;
header.msg_type = PLDM_RESPONSE;
header.pldm_type = PLDM_FRU;
@@ -542,10 +544,10 @@
}
struct pldm_set_fru_record_table_resp *response =
- (struct pldm_set_fru_record_table_resp *)msg->payload;
+ (struct pldm_set_fru_record_table_resp *)msg->payload;
response->completion_code = completion_code;
response->next_data_transfer_handle =
- htole32(next_data_transfer_handle);
+ htole32(next_data_transfer_handle);
return PLDM_SUCCESS;
}