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/bios.c b/src/bios.c
index aa8cc15..70f4d28 100644
--- a/src/bios.c
+++ b/src/bios.c
@@ -10,7 +10,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_BIOS;
@@ -27,7 +27,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_BIOS;
@@ -39,7 +39,7 @@
}
struct pldm_get_date_time_resp *response =
- (struct pldm_get_date_time_resp *)msg->payload;
+ (struct pldm_get_date_time_resp *)msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
response->completion_code = completion_code;
@@ -74,7 +74,7 @@
}
struct pldm_get_date_time_resp *response =
- (struct pldm_get_date_time_resp *)msg->payload;
+ (struct pldm_get_date_time_resp *)msg->payload;
*seconds = response->seconds;
*minutes = response->minutes;
@@ -102,7 +102,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- 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_BIOS;
@@ -114,7 +114,7 @@
}
struct pldm_set_date_time_req *request =
- (struct pldm_set_date_time_req *)msg->payload;
+ (struct pldm_set_date_time_req *)msg->payload;
request->seconds = dec2bcd8(seconds);
request->minutes = dec2bcd8(minutes);
request->hours = dec2bcd8(hours);
@@ -138,7 +138,7 @@
}
const struct pldm_set_date_time_req *request =
- (struct pldm_set_date_time_req *)msg->payload;
+ (struct pldm_set_date_time_req *)msg->payload;
*seconds = bcd2dec8(request->seconds);
*minutes = bcd2dec8(request->minutes);
@@ -164,7 +164,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_BIOS;
@@ -176,7 +176,7 @@
}
struct pldm_only_cc_resp *response =
- (struct pldm_only_cc_resp *)msg->payload;
+ (struct pldm_only_cc_resp *)msg->payload;
response->completion_code = completion_code;
return PLDM_SUCCESS;
@@ -210,7 +210,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_BIOS;
@@ -222,10 +222,9 @@
}
struct pldm_get_bios_table_resp *response =
- (struct pldm_get_bios_table_resp *)msg->payload;
+ (struct pldm_get_bios_table_resp *)msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
-
response->next_transfer_handle = htole32(next_transfer_handle);
response->transfer_flag = transfer_flag;
if (table_data != NULL &&
@@ -233,8 +232,8 @@
PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES)) {
memcpy(response->table_data, table_data,
payload_length -
- (sizeof(struct pldm_msg_hdr) +
- PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES));
+ (sizeof(struct pldm_msg_hdr) +
+ PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES));
}
}
return PLDM_SUCCESS;
@@ -248,7 +247,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_BIOS;
@@ -260,7 +259,7 @@
}
struct pldm_get_bios_table_req *request =
- (struct pldm_get_bios_table_req *)msg->payload;
+ (struct pldm_get_bios_table_req *)msg->payload;
request->transfer_handle = htole32(transfer_handle);
request->transfer_op_flag = transfer_op_flag;
@@ -282,7 +281,7 @@
}
struct pldm_get_bios_table_req *request =
- (struct pldm_get_bios_table_req *)msg->payload;
+ (struct pldm_get_bios_table_req *)msg->payload;
*transfer_handle = le32toh(request->transfer_handle);
*transfer_op_flag = request->transfer_op_flag;
*table_type = request->table_type;
@@ -306,7 +305,7 @@
}
struct pldm_get_bios_table_resp *response =
- (struct pldm_get_bios_table_resp *)msg->payload;
+ (struct pldm_get_bios_table_resp *)msg->payload;
*completion_code = response->completion_code;
@@ -325,14 +324,14 @@
}
int encode_get_bios_attribute_current_value_by_handle_req(
- uint8_t instance_id, uint32_t transfer_handle, uint8_t transfer_op_flag,
- uint16_t attribute_handle, struct pldm_msg *msg)
+ uint8_t instance_id, uint32_t transfer_handle, uint8_t transfer_op_flag,
+ uint16_t attribute_handle, 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_BIOS;
@@ -344,8 +343,8 @@
}
struct pldm_get_bios_attribute_current_value_by_handle_req *request =
- (struct pldm_get_bios_attribute_current_value_by_handle_req *)
- msg->payload;
+ (struct pldm_get_bios_attribute_current_value_by_handle_req *)
+ msg->payload;
request->transfer_handle = htole32(transfer_handle);
request->transfer_op_flag = transfer_op_flag;
@@ -354,9 +353,9 @@
}
int decode_get_bios_attribute_current_value_by_handle_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 *attribute_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 *attribute_data)
{
if (msg == NULL || transfer_flag == NULL ||
next_transfer_handle == NULL || completion_code == NULL) {
@@ -364,8 +363,8 @@
}
struct pldm_get_bios_attribute_current_value_by_handle_resp *response =
- (struct pldm_get_bios_attribute_current_value_by_handle_resp *)
- msg->payload;
+ (struct pldm_get_bios_attribute_current_value_by_handle_resp *)
+ msg->payload;
*completion_code = response->completion_code;
@@ -388,9 +387,9 @@
}
int decode_get_bios_attribute_current_value_by_handle_req(
- const struct pldm_msg *msg, size_t payload_length,
- uint32_t *transfer_handle, uint8_t *transfer_op_flag,
- uint16_t *attribute_handle)
+ const struct pldm_msg *msg, size_t payload_length,
+ uint32_t *transfer_handle, uint8_t *transfer_op_flag,
+ uint16_t *attribute_handle)
{
if (msg == NULL || transfer_handle == NULL ||
transfer_op_flag == NULL || attribute_handle == NULL) {
@@ -402,8 +401,8 @@
}
struct pldm_get_bios_attribute_current_value_by_handle_req *request =
- (struct pldm_get_bios_attribute_current_value_by_handle_req *)
- msg->payload;
+ (struct pldm_get_bios_attribute_current_value_by_handle_req *)
+ msg->payload;
*transfer_handle = le32toh(request->transfer_handle);
*transfer_op_flag = request->transfer_op_flag;
*attribute_handle = le16toh(request->attribute_handle);
@@ -411,16 +410,19 @@
return PLDM_SUCCESS;
}
-int encode_get_bios_current_value_by_handle_resp(
- uint8_t instance_id, uint8_t completion_code, uint32_t next_transfer_handle,
- uint8_t transfer_flag, const uint8_t *attribute_data,
- size_t attribute_length, struct pldm_msg *msg)
+int encode_get_bios_current_value_by_handle_resp(uint8_t instance_id,
+ uint8_t completion_code,
+ uint32_t next_transfer_handle,
+ uint8_t transfer_flag,
+ const uint8_t *attribute_data,
+ size_t attribute_length,
+ struct pldm_msg *msg)
{
if (msg == NULL || attribute_data == 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_BIOS;
@@ -432,11 +434,10 @@
}
struct pldm_get_bios_attribute_current_value_by_handle_resp *response =
- (struct pldm_get_bios_attribute_current_value_by_handle_resp *)
- msg->payload;
+ (struct pldm_get_bios_attribute_current_value_by_handle_resp *)
+ msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
-
response->next_transfer_handle = htole32(next_transfer_handle);
response->transfer_flag = transfer_flag;
if (attribute_data != NULL) {
@@ -447,9 +448,9 @@
return PLDM_SUCCESS;
}
int encode_set_bios_attribute_current_value_req(
- uint8_t instance_id, uint32_t transfer_handle, uint8_t transfer_flag,
- const uint8_t *attribute_data, size_t attribute_length,
- struct pldm_msg *msg, size_t payload_length)
+ uint8_t instance_id, uint32_t transfer_handle, uint8_t transfer_flag,
+ const uint8_t *attribute_data, size_t attribute_length,
+ struct pldm_msg *msg, size_t payload_length)
{
if (msg == NULL || attribute_data == NULL) {
return PLDM_ERROR_INVALID_DATA;
@@ -458,7 +459,7 @@
payload_length) {
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_BIOS;
@@ -470,7 +471,7 @@
}
struct pldm_set_bios_attribute_current_value_req *request =
- (struct pldm_set_bios_attribute_current_value_req *)msg->payload;
+ (struct pldm_set_bios_attribute_current_value_req *)msg->payload;
request->transfer_handle = htole32(transfer_handle);
request->transfer_flag = transfer_flag;
memcpy(request->attribute_data, attribute_data, attribute_length);
@@ -498,7 +499,8 @@
}
struct pldm_set_bios_attribute_current_value_resp *response =
- (struct pldm_set_bios_attribute_current_value_resp *)msg->payload;
+ (struct pldm_set_bios_attribute_current_value_resp *)
+ msg->payload;
*next_transfer_handle = le32toh(response->next_transfer_handle);
@@ -506,9 +508,9 @@
}
int decode_set_bios_attribute_current_value_req(
- const struct pldm_msg *msg, size_t payload_length,
- uint32_t *transfer_handle, uint8_t *transfer_flag,
- struct variable_field *attribute)
+ const struct pldm_msg *msg, size_t payload_length,
+ uint32_t *transfer_handle, uint8_t *transfer_flag,
+ struct variable_field *attribute)
{
if (msg == NULL || transfer_handle == NULL || transfer_flag == NULL ||
attribute == NULL) {
@@ -519,11 +521,11 @@
}
struct pldm_set_bios_attribute_current_value_req *request =
- (struct pldm_set_bios_attribute_current_value_req *)msg->payload;
+ (struct pldm_set_bios_attribute_current_value_req *)msg->payload;
*transfer_handle = le32toh(request->transfer_handle);
*transfer_flag = request->transfer_flag;
attribute->length =
- payload_length - PLDM_SET_BIOS_ATTR_CURR_VAL_MIN_REQ_BYTES;
+ payload_length - PLDM_SET_BIOS_ATTR_CURR_VAL_MIN_REQ_BYTES;
attribute->ptr = request->attribute_data;
return PLDM_SUCCESS;
}
@@ -536,7 +538,7 @@
if (msg == NULL) {
return PLDM_ERROR_INVALID_DATA;
}
- 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_BIOS;
@@ -548,7 +550,8 @@
}
struct pldm_set_bios_attribute_current_value_resp *response =
- (struct pldm_set_bios_attribute_current_value_resp *)msg->payload;
+ (struct pldm_set_bios_attribute_current_value_resp *)
+ msg->payload;
response->completion_code = completion_code;
response->next_transfer_handle = htole32(next_transfer_handle);
@@ -569,7 +572,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_BIOS;
@@ -581,7 +584,7 @@
}
struct pldm_set_bios_table_req *request =
- (struct pldm_set_bios_table_req *)msg->payload;
+ (struct pldm_set_bios_table_req *)msg->payload;
request->transfer_handle = htole32(transfer_handle);
request->transfer_flag = transfer_flag;
request->table_type = table_type;
@@ -609,7 +612,7 @@
}
struct pldm_set_bios_table_resp *response =
- (struct pldm_set_bios_table_resp *)msg->payload;
+ (struct pldm_set_bios_table_resp *)msg->payload;
*next_transfer_handle = le32toh(response->next_transfer_handle);
@@ -624,7 +627,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- 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_BIOS;
@@ -636,7 +639,7 @@
}
struct pldm_set_bios_table_resp *response =
- (struct pldm_set_bios_table_resp *)msg->payload;
+ (struct pldm_set_bios_table_resp *)msg->payload;
response->completion_code = completion_code;
response->next_transfer_handle = htole32(next_transfer_handle);
@@ -657,7 +660,7 @@
}
struct pldm_set_bios_table_req *request =
- (struct pldm_set_bios_table_req *)msg->payload;
+ (struct pldm_set_bios_table_req *)msg->payload;
*transfer_handle = le32toh(request->transfer_handle);
*transfer_flag = request->transfer_flag;
*table_type = request->table_type;