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/base.c b/src/base.c
index 5e652cc..90e9c1e 100644
--- a/src/base.c
+++ b/src/base.c
@@ -52,8 +52,8 @@
if (msg->request == PLDM_RESPONSE) {
hdr->msg_type = PLDM_RESPONSE;
} else {
- hdr->msg_type =
- msg->datagram ? PLDM_ASYNC_REQUEST_NOTIFY : PLDM_REQUEST;
+ hdr->msg_type = msg->datagram ? PLDM_ASYNC_REQUEST_NOTIFY :
+ PLDM_REQUEST;
}
hdr->instance = msg->instance_id;
@@ -69,7 +69,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.command = PLDM_GET_PLDM_TYPES;
@@ -84,7 +84,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.command = PLDM_GET_PLDM_COMMANDS;
@@ -95,7 +95,7 @@
}
struct pldm_get_commands_req *request =
- (struct pldm_get_commands_req *)msg->payload;
+ (struct pldm_get_commands_req *)msg->payload;
request->type = type;
request->version = version;
@@ -110,7 +110,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.command = PLDM_GET_PLDM_TYPES;
@@ -121,7 +121,7 @@
}
struct pldm_get_types_resp *response =
- (struct pldm_get_types_resp *)msg->payload;
+ (struct pldm_get_types_resp *)msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
if (types == NULL) {
@@ -145,7 +145,7 @@
}
struct pldm_get_commands_req *request =
- (struct pldm_get_commands_req *)msg->payload;
+ (struct pldm_get_commands_req *)msg->payload;
*type = request->type;
*version = request->version;
return PLDM_SUCCESS;
@@ -158,7 +158,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.command = PLDM_GET_PLDM_COMMANDS;
@@ -168,7 +168,7 @@
}
struct pldm_get_commands_resp *response =
- (struct pldm_get_commands_resp *)msg->payload;
+ (struct pldm_get_commands_resp *)msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
if (commands == NULL) {
@@ -198,7 +198,7 @@
}
struct pldm_get_types_resp *response =
- (struct pldm_get_types_resp *)msg->payload;
+ (struct pldm_get_types_resp *)msg->payload;
memcpy(&(types->byte), response->types, PLDM_MAX_TYPES / 8);
@@ -222,7 +222,7 @@
}
struct pldm_get_commands_resp *response =
- (struct pldm_get_commands_resp *)msg->payload;
+ (struct pldm_get_commands_resp *)msg->payload;
memcpy(&(commands->byte), response->commands,
PLDM_MAX_CMDS_PER_TYPE / 8);
@@ -238,7 +238,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_BASE;
@@ -250,7 +250,7 @@
}
struct pldm_get_version_req *request =
- (struct pldm_get_version_req *)msg->payload;
+ (struct pldm_get_version_req *)msg->payload;
transfer_handle = htole32(transfer_handle);
request->transfer_handle = transfer_handle;
request->transfer_opflag = transfer_opflag;
@@ -268,7 +268,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_BASE;
@@ -280,7 +280,7 @@
}
struct pldm_get_version_resp *response =
- (struct pldm_get_version_resp *)msg->payload;
+ (struct pldm_get_version_resp *)msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
response->next_transfer_handle = htole32(next_transfer_handle);
@@ -295,13 +295,12 @@
uint32_t *transfer_handle, uint8_t *transfer_opflag,
uint8_t *type)
{
-
if (payload_length != PLDM_GET_VERSION_REQ_BYTES) {
return PLDM_ERROR_INVALID_LENGTH;
}
struct pldm_get_version_req *request =
- (struct pldm_get_version_req *)msg->payload;
+ (struct pldm_get_version_req *)msg->payload;
*transfer_handle = le32toh(request->transfer_handle);
*transfer_opflag = request->transfer_opflag;
*type = request->type;
@@ -328,7 +327,7 @@
}
struct pldm_get_version_resp *response =
- (struct pldm_get_version_resp *)msg->payload;
+ (struct pldm_get_version_resp *)msg->payload;
*next_transfer_handle = le32toh(response->next_transfer_handle);
*transfer_flag = response->transfer_flag;
@@ -343,7 +342,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.command = PLDM_GET_TID;
@@ -357,7 +356,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.command = PLDM_GET_TID;
@@ -368,7 +367,7 @@
}
struct pldm_get_tid_resp *response =
- (struct pldm_get_tid_resp *)msg->payload;
+ (struct pldm_get_tid_resp *)msg->payload;
response->completion_code = completion_code;
response->tid = tid;
@@ -392,7 +391,7 @@
}
struct pldm_get_tid_resp *response =
- (struct pldm_get_tid_resp *)msg->payload;
+ (struct pldm_get_tid_resp *)msg->payload;
*tid = response->tid;
@@ -409,7 +408,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.command = PLDM_SET_TID;
@@ -420,16 +419,19 @@
}
struct pldm_set_tid_req *request =
- (struct pldm_set_tid_req *)msg->payload;
+ (struct pldm_set_tid_req *)msg->payload;
request->tid = tid;
return PLDM_SUCCESS;
}
-int decode_multipart_receive_req(
- const struct pldm_msg *msg, size_t payload_length, uint8_t *pldm_type,
- uint8_t *transfer_opflag, uint32_t *transfer_ctx, uint32_t *transfer_handle,
- uint32_t *section_offset, uint32_t *section_length)
+int decode_multipart_receive_req(const struct pldm_msg *msg,
+ size_t payload_length, uint8_t *pldm_type,
+ uint8_t *transfer_opflag,
+ uint32_t *transfer_ctx,
+ uint32_t *transfer_handle,
+ uint32_t *section_offset,
+ uint32_t *section_length)
{
if (msg == NULL || pldm_type == NULL || transfer_opflag == NULL ||
transfer_ctx == NULL || transfer_handle == NULL ||
@@ -442,7 +444,7 @@
}
struct pldm_multipart_receive_req *request =
- (struct pldm_multipart_receive_req *)msg->payload;
+ (struct pldm_multipart_receive_req *)msg->payload;
if (request->pldm_type != PLDM_BASE) {
return PLDM_ERROR_INVALID_PLDM_TYPE;
@@ -483,7 +485,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 = type;
@@ -507,7 +509,7 @@
return PLDM_ERROR_INVALID_DATA;
}
- struct pldm_header_info header = {0};
+ struct pldm_header_info header = { 0 };
header.msg_type = msg_type;
header.instance = instance_id;
header.pldm_type = pldm_type;