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;
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;
diff --git a/src/bios_table.c b/src/bios_table.c
index e9e1f3f..ceb26b1 100644
--- a/src/bios_table.c
+++ b/src/bios_table.c
@@ -78,22 +78,23 @@
}
uint16_t pldm_bios_table_string_entry_decode_handle(
- const struct pldm_bios_string_table_entry *entry)
+ const struct pldm_bios_string_table_entry *entry)
{
return le16toh(entry->string_handle);
}
uint16_t pldm_bios_table_string_entry_decode_string_length(
- const struct pldm_bios_string_table_entry *entry)
+ const struct pldm_bios_string_table_entry *entry)
{
return le16toh(entry->string_length);
}
uint16_t pldm_bios_table_string_entry_decode_string(
- const struct pldm_bios_string_table_entry *entry, char *buffer, size_t size)
+ const struct pldm_bios_string_table_entry *entry, char *buffer,
+ size_t size)
{
uint16_t length =
- pldm_bios_table_string_entry_decode_string_length(entry);
+ pldm_bios_table_string_entry_decode_string_length(entry);
length = length < (size - 1) ? length : (size - 1);
memcpy(buffer, entry->name, length);
buffer[length] = 0;
@@ -101,12 +102,13 @@
}
int pldm_bios_table_string_entry_decode_string_check(
- const struct pldm_bios_string_table_entry *entry, char *buffer, size_t size)
+ const struct pldm_bios_string_table_entry *entry, char *buffer,
+ size_t size)
{
POINTER_CHECK(entry);
POINTER_CHECK(buffer);
size_t length =
- pldm_bios_table_string_entry_decode_string_length(entry);
+ pldm_bios_table_string_entry_decode_string_length(entry);
BUFFER_SIZE_EXPECT(size, length + 1);
pldm_bios_table_string_entry_decode_string(entry, buffer, size);
return PLDM_SUCCESS;
@@ -139,19 +141,19 @@
}
uint16_t pldm_bios_table_attr_entry_decode_attribute_handle(
- const struct pldm_bios_attr_table_entry *entry)
+ const struct pldm_bios_attr_table_entry *entry)
{
return le16toh(entry->attr_handle);
}
uint8_t pldm_bios_table_attr_entry_decode_attribute_type(
- const struct pldm_bios_attr_table_entry *entry)
+ const struct pldm_bios_attr_table_entry *entry)
{
return entry->attr_type;
}
uint16_t pldm_bios_table_attr_entry_decode_string_handle(
- const struct pldm_bios_attr_table_entry *entry)
+ const struct pldm_bios_attr_table_entry *entry)
{
return le16toh(entry->string_handle);
}
@@ -166,39 +168,39 @@
}
void pldm_bios_table_attr_entry_enum_encode(
- void *entry, size_t entry_length,
- const struct pldm_bios_table_attr_entry_enum_info *info)
+ void *entry, size_t entry_length,
+ const struct pldm_bios_table_attr_entry_enum_info *info)
{
size_t length = pldm_bios_table_attr_entry_enum_encode_length(
- info->pv_num, info->def_num);
+ info->pv_num, info->def_num);
assert(length <= entry_length);
- uint8_t attr_type = info->read_only ? PLDM_BIOS_ENUMERATION_READ_ONLY
- : PLDM_BIOS_ENUMERATION;
+ uint8_t attr_type = info->read_only ? PLDM_BIOS_ENUMERATION_READ_ONLY :
+ PLDM_BIOS_ENUMERATION;
attr_table_entry_encode_header(entry, entry_length, attr_type,
info->name_handle);
struct pldm_bios_attr_table_entry *attr_entry = entry;
attr_entry->metadata[0] = info->pv_num;
uint16_t *pv_hdls =
- (uint16_t *)(attr_entry->metadata + 1 /* sizeof(pv num) */);
+ (uint16_t *)(attr_entry->metadata + 1 /* sizeof(pv num) */);
size_t i;
for (i = 0; i < info->pv_num; i++) {
pv_hdls[i] = htole16(info->pv_handle[i]);
}
attr_entry->metadata[1 + info->pv_num * sizeof(uint16_t)] =
- info->def_num;
+ info->def_num;
memcpy(attr_entry->metadata + 1 /* sizeof(pv num) */ +
- info->pv_num * sizeof(uint16_t) + 1 /* sizeof(def num)*/,
+ info->pv_num * sizeof(uint16_t) + 1 /* sizeof(def num)*/,
info->def_index, info->def_num);
}
int pldm_bios_table_attr_entry_enum_encode_check(
- void *entry, size_t entry_length,
- const struct pldm_bios_table_attr_entry_enum_info *info)
+ void *entry, size_t entry_length,
+ const struct pldm_bios_table_attr_entry_enum_info *info)
{
POINTER_CHECK(entry);
POINTER_CHECK(info);
size_t length = pldm_bios_table_attr_entry_enum_encode_length(
- info->pv_num, info->def_num);
+ info->pv_num, info->def_num);
BUFFER_SIZE_EXPECT(entry_length, length);
pldm_bios_table_attr_entry_enum_encode(entry, entry_length, info);
return PLDM_SUCCESS;
@@ -211,13 +213,13 @@
} while (0)
uint8_t pldm_bios_table_attr_entry_enum_decode_pv_num(
- const struct pldm_bios_attr_table_entry *entry)
+ const struct pldm_bios_attr_table_entry *entry)
{
return entry->metadata[0];
}
int pldm_bios_table_attr_entry_enum_decode_pv_num_check(
- const struct pldm_bios_attr_table_entry *entry, uint8_t *pv_num)
+ const struct pldm_bios_attr_table_entry *entry, uint8_t *pv_num)
{
POINTER_CHECK(entry);
POINTER_CHECK(pv_num);
@@ -227,7 +229,7 @@
}
uint8_t pldm_bios_table_attr_entry_enum_decode_def_num(
- const struct pldm_bios_attr_table_entry *entry)
+ const struct pldm_bios_attr_table_entry *entry)
{
uint8_t pv_num = pldm_bios_table_attr_entry_enum_decode_pv_num(entry);
return entry->metadata[sizeof(uint8_t) /* pv_num */ +
@@ -235,7 +237,7 @@
}
int pldm_bios_table_attr_entry_enum_decode_def_num_check(
- const struct pldm_bios_attr_table_entry *entry, uint8_t *def_num)
+ const struct pldm_bios_attr_table_entry *entry, uint8_t *def_num)
{
POINTER_CHECK(entry);
POINTER_CHECK(def_num);
@@ -245,8 +247,8 @@
}
uint8_t pldm_bios_table_attr_entry_enum_decode_pv_hdls(
- const struct pldm_bios_attr_table_entry *entry, uint16_t *pv_hdls,
- uint8_t pv_num)
+ const struct pldm_bios_attr_table_entry *entry, uint16_t *pv_hdls,
+ uint8_t pv_num)
{
uint8_t num = pldm_bios_table_attr_entry_enum_decode_pv_num(entry);
num = num < pv_num ? num : pv_num;
@@ -260,8 +262,8 @@
}
int pldm_bios_table_attr_entry_enum_decode_pv_hdls_check(
- const struct pldm_bios_attr_table_entry *entry, uint16_t *pv_hdls,
- uint8_t pv_num)
+ const struct pldm_bios_attr_table_entry *entry, uint16_t *pv_hdls,
+ uint8_t pv_num)
{
POINTER_CHECK(entry);
POINTER_CHECK(pv_hdls);
@@ -275,8 +277,8 @@
}
uint8_t pldm_bios_table_attr_entry_enum_decode_def_indices(
- const struct pldm_bios_attr_table_entry *entry, uint8_t *def_indices,
- uint8_t def_num)
+ const struct pldm_bios_attr_table_entry *entry, uint8_t *def_indices,
+ uint8_t def_num)
{
uint8_t num = pldm_bios_table_attr_entry_enum_decode_def_num(entry);
num = num < def_num ? num : def_num;
@@ -316,19 +318,19 @@
}
void pldm_bios_table_attr_entry_string_encode(
- void *entry, size_t entry_length,
- const struct pldm_bios_table_attr_entry_string_info *info)
+ void *entry, size_t entry_length,
+ const struct pldm_bios_table_attr_entry_string_info *info)
{
- size_t length =
- pldm_bios_table_attr_entry_string_encode_length(info->def_length);
+ size_t length = pldm_bios_table_attr_entry_string_encode_length(
+ info->def_length);
assert(length <= entry_length);
- uint8_t attr_type =
- info->read_only ? PLDM_BIOS_STRING_READ_ONLY : PLDM_BIOS_STRING;
+ uint8_t attr_type = info->read_only ? PLDM_BIOS_STRING_READ_ONLY :
+ PLDM_BIOS_STRING;
attr_table_entry_encode_header(entry, entry_length, attr_type,
info->name_handle);
struct pldm_bios_attr_table_entry *attr_entry = entry;
struct attr_table_string_entry_fields *attr_fields =
- (struct attr_table_string_entry_fields *)attr_entry->metadata;
+ (struct attr_table_string_entry_fields *)attr_entry->metadata;
attr_fields->string_type = info->string_type;
attr_fields->min_length = htole16(info->min_length);
attr_fields->max_length = htole16(info->max_length);
@@ -339,12 +341,12 @@
}
}
-#define PLDM_STRING_TYPE_MAX 5
+#define PLDM_STRING_TYPE_MAX 5
#define PLDM_STRING_TYPE_VENDOR 0xff
int pldm_bios_table_attr_entry_string_info_check(
- const struct pldm_bios_table_attr_entry_string_info *info,
- const char **errmsg)
+ const struct pldm_bios_table_attr_entry_string_info *info,
+ const char **errmsg)
{
if (info->min_length > info->max_length) {
set_errmsg(errmsg, "MinimumStingLength should not be greater "
@@ -376,13 +378,13 @@
}
int pldm_bios_table_attr_entry_string_encode_check(
- void *entry, size_t entry_length,
- const struct pldm_bios_table_attr_entry_string_info *info)
+ void *entry, size_t entry_length,
+ const struct pldm_bios_table_attr_entry_string_info *info)
{
POINTER_CHECK(entry);
POINTER_CHECK(info);
- size_t length =
- pldm_bios_table_attr_entry_string_encode_length(info->def_length);
+ size_t length = pldm_bios_table_attr_entry_string_encode_length(
+ info->def_length);
BUFFER_SIZE_EXPECT(entry_length, length);
if (pldm_bios_table_attr_entry_string_info_check(info, NULL) !=
PLDM_SUCCESS) {
@@ -393,56 +395,60 @@
}
uint16_t pldm_bios_table_attr_entry_string_decode_def_string_length(
- const struct pldm_bios_attr_table_entry *entry)
+ const struct pldm_bios_attr_table_entry *entry)
{
struct attr_table_string_entry_fields *fields =
- (struct attr_table_string_entry_fields *)entry->metadata;
+ (struct attr_table_string_entry_fields *)entry->metadata;
return le16toh(fields->def_length);
}
int pldm_bios_table_attr_entry_string_decode_def_string_length_check(
- const struct pldm_bios_attr_table_entry *entry, uint16_t *def_string_length)
+ const struct pldm_bios_attr_table_entry *entry,
+ uint16_t *def_string_length)
{
POINTER_CHECK(entry);
POINTER_CHECK(def_string_length);
ATTR_TYPE_EXPECT(entry->attr_type, PLDM_BIOS_STRING);
*def_string_length =
- pldm_bios_table_attr_entry_string_decode_def_string_length(entry);
+ pldm_bios_table_attr_entry_string_decode_def_string_length(
+ entry);
return PLDM_SUCCESS;
}
uint8_t pldm_bios_table_attr_entry_string_decode_string_type(
- const struct pldm_bios_attr_table_entry *entry)
+ const struct pldm_bios_attr_table_entry *entry)
{
struct attr_table_string_entry_fields *fields =
- (struct attr_table_string_entry_fields *)entry->metadata;
+ (struct attr_table_string_entry_fields *)entry->metadata;
return fields->string_type;
}
uint16_t pldm_bios_table_attr_entry_string_decode_max_length(
- const struct pldm_bios_attr_table_entry *entry)
+ const struct pldm_bios_attr_table_entry *entry)
{
struct attr_table_string_entry_fields *fields =
- (struct attr_table_string_entry_fields *)entry->metadata;
+ (struct attr_table_string_entry_fields *)entry->metadata;
return le16toh(fields->max_length);
}
uint16_t pldm_bios_table_attr_entry_string_decode_min_length(
- const struct pldm_bios_attr_table_entry *entry)
+ const struct pldm_bios_attr_table_entry *entry)
{
struct attr_table_string_entry_fields *fields =
- (struct attr_table_string_entry_fields *)entry->metadata;
+ (struct attr_table_string_entry_fields *)entry->metadata;
return le16toh(fields->min_length);
}
uint16_t pldm_bios_table_attr_entry_string_decode_def_string(
- const struct pldm_bios_attr_table_entry *entry, char *buffer, size_t size)
+ const struct pldm_bios_attr_table_entry *entry, char *buffer,
+ size_t size)
{
uint16_t length =
- pldm_bios_table_attr_entry_string_decode_def_string_length(entry);
+ pldm_bios_table_attr_entry_string_decode_def_string_length(
+ entry);
length = length < (size - 1) ? length : (size - 1);
struct attr_table_string_entry_fields *fields =
- (struct attr_table_string_entry_fields *)entry->metadata;
+ (struct attr_table_string_entry_fields *)entry->metadata;
memcpy(buffer, fields->def_string, length);
buffer[length] = 0;
return length;
@@ -453,7 +459,8 @@
static size_t attr_table_entry_length_string(const void *entry)
{
uint16_t def_str_len =
- pldm_bios_table_attr_entry_string_decode_def_string_length(entry);
+ pldm_bios_table_attr_entry_string_decode_def_string_length(
+ entry);
return pldm_bios_table_attr_entry_string_encode_length(def_str_len);
}
@@ -471,18 +478,18 @@
}
void pldm_bios_table_attr_entry_integer_encode(
- void *entry, size_t entry_length,
- const struct pldm_bios_table_attr_entry_integer_info *info)
+ void *entry, size_t entry_length,
+ const struct pldm_bios_table_attr_entry_integer_info *info)
{
size_t length = pldm_bios_table_attr_entry_integer_encode_length();
assert(length <= entry_length);
- uint8_t attr_type =
- info->read_only ? PLDM_BIOS_INTEGER_READ_ONLY : PLDM_BIOS_INTEGER;
+ uint8_t attr_type = info->read_only ? PLDM_BIOS_INTEGER_READ_ONLY :
+ PLDM_BIOS_INTEGER;
attr_table_entry_encode_header(entry, entry_length, attr_type,
info->name_handle);
struct pldm_bios_attr_table_entry *attr_entry = entry;
struct attr_table_integer_entry_fields *attr_fields =
- (struct attr_table_integer_entry_fields *)attr_entry->metadata;
+ (struct attr_table_integer_entry_fields *)attr_entry->metadata;
attr_fields->lower_bound = htole64(info->lower_bound);
attr_fields->upper_bound = htole64(info->upper_bound);
attr_fields->scalar_increment = htole32(info->scalar_increment);
@@ -490,8 +497,8 @@
}
int pldm_bios_table_attr_entry_integer_info_check(
- const struct pldm_bios_table_attr_entry_integer_info *info,
- const char **errmsg)
+ const struct pldm_bios_table_attr_entry_integer_info *info,
+ const char **errmsg)
{
if (info->lower_bound == info->upper_bound) {
if (info->default_value != info->lower_bound) {
@@ -520,7 +527,7 @@
return PLDM_ERROR_INVALID_DATA;
}
if ((info->default_value - info->lower_bound) %
- info->scalar_increment !=
+ info->scalar_increment !=
0) {
set_errmsg(errmsg, "Wrong DefaultValue or ScalarIncrement");
return PLDM_ERROR_INVALID_DATA;
@@ -529,8 +536,8 @@
}
int pldm_bios_table_attr_entry_integer_encode_check(
- void *entry, size_t entry_length,
- const struct pldm_bios_table_attr_entry_integer_info *info)
+ void *entry, size_t entry_length,
+ const struct pldm_bios_table_attr_entry_integer_info *info)
{
POINTER_CHECK(entry);
POINTER_CHECK(info);
@@ -545,11 +552,11 @@
}
void pldm_bios_table_attr_entry_integer_decode(
- const struct pldm_bios_attr_table_entry *entry, uint64_t *lower,
- uint64_t *upper, uint32_t *scalar, uint64_t *def)
+ const struct pldm_bios_attr_table_entry *entry, uint64_t *lower,
+ uint64_t *upper, uint32_t *scalar, uint64_t *def)
{
struct attr_table_integer_entry_fields *fields =
- (struct attr_table_integer_entry_fields *)entry->metadata;
+ (struct attr_table_integer_entry_fields *)entry->metadata;
*lower = le64toh(fields->lower_bound);
*upper = le64toh(fields->upper_bound);
*scalar = le32toh(fields->scalar_increment);
@@ -569,8 +576,10 @@
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
-static const struct table_entry_length *find_table_entry_length_by_type(
- uint8_t attr_type, const struct table_entry_length *handlers, size_t count)
+static const struct table_entry_length *
+find_table_entry_length_by_type(uint8_t attr_type,
+ const struct table_entry_length *handlers,
+ size_t count)
{
size_t i;
for (i = 0; i < count; i++) {
@@ -582,27 +591,27 @@
}
static const struct table_entry_length attr_table_entries[] = {
- {.attr_type = PLDM_BIOS_ENUMERATION,
- .entry_length_handler = attr_table_entry_length_enum},
- {.attr_type = PLDM_BIOS_ENUMERATION_READ_ONLY,
- .entry_length_handler = attr_table_entry_length_enum},
- {.attr_type = PLDM_BIOS_STRING,
- .entry_length_handler = attr_table_entry_length_string},
- {.attr_type = PLDM_BIOS_STRING_READ_ONLY,
- .entry_length_handler = attr_table_entry_length_string},
- {.attr_type = PLDM_BIOS_INTEGER,
- .entry_length_handler = attr_table_entry_length_integer},
- {.attr_type = PLDM_BIOS_INTEGER_READ_ONLY,
- .entry_length_handler = attr_table_entry_length_integer},
+ { .attr_type = PLDM_BIOS_ENUMERATION,
+ .entry_length_handler = attr_table_entry_length_enum },
+ { .attr_type = PLDM_BIOS_ENUMERATION_READ_ONLY,
+ .entry_length_handler = attr_table_entry_length_enum },
+ { .attr_type = PLDM_BIOS_STRING,
+ .entry_length_handler = attr_table_entry_length_string },
+ { .attr_type = PLDM_BIOS_STRING_READ_ONLY,
+ .entry_length_handler = attr_table_entry_length_string },
+ { .attr_type = PLDM_BIOS_INTEGER,
+ .entry_length_handler = attr_table_entry_length_integer },
+ { .attr_type = PLDM_BIOS_INTEGER_READ_ONLY,
+ .entry_length_handler = attr_table_entry_length_integer },
};
static size_t attr_table_entry_length(const void *table_entry)
{
const struct pldm_bios_attr_table_entry *entry = table_entry;
const struct table_entry_length *attr_table_entry =
- find_table_entry_length_by_type(entry->attr_type,
- attr_table_entries,
- ARRAY_SIZE(attr_table_entries));
+ find_table_entry_length_by_type(entry->attr_type,
+ attr_table_entries,
+ ARRAY_SIZE(attr_table_entries));
assert(attr_table_entry != NULL);
assert(attr_table_entry->entry_length_handler != NULL);
@@ -610,13 +619,13 @@
}
uint16_t pldm_bios_table_attr_value_entry_decode_attribute_handle(
- const struct pldm_bios_attr_val_table_entry *entry)
+ const struct pldm_bios_attr_val_table_entry *entry)
{
return le16toh(entry->attr_handle);
}
uint8_t pldm_bios_table_attr_value_entry_decode_attribute_type(
- const struct pldm_bios_attr_val_table_entry *entry)
+ const struct pldm_bios_attr_val_table_entry *entry)
{
return entry->attr_type;
}
@@ -628,11 +637,11 @@
}
void pldm_bios_table_attr_value_entry_encode_enum(
- void *entry, size_t entry_length, uint16_t attr_handle, uint8_t attr_type,
- uint8_t count, const uint8_t *handles)
+ void *entry, size_t entry_length, uint16_t attr_handle,
+ uint8_t attr_type, uint8_t count, const uint8_t *handles)
{
size_t length =
- pldm_bios_table_attr_value_entry_encode_enum_length(count);
+ pldm_bios_table_attr_value_entry_encode_enum_length(count);
assert(length <= entry_length);
struct pldm_bios_attr_val_table_entry *table_entry = entry;
@@ -645,17 +654,17 @@
}
uint8_t pldm_bios_table_attr_value_entry_enum_decode_number(
- const struct pldm_bios_attr_val_table_entry *entry)
+ const struct pldm_bios_attr_val_table_entry *entry)
{
return entry->value[0];
}
uint8_t pldm_bios_table_attr_value_entry_enum_decode_handles(
- const struct pldm_bios_attr_val_table_entry *entry, uint8_t *handles,
- uint8_t number)
+ const struct pldm_bios_attr_val_table_entry *entry, uint8_t *handles,
+ uint8_t number)
{
uint8_t curr_num =
- pldm_bios_table_attr_value_entry_enum_decode_number(entry);
+ pldm_bios_table_attr_value_entry_enum_decode_number(entry);
number = number < curr_num ? number : curr_num;
memcpy(handles, &entry->value[1], number);
@@ -663,8 +672,8 @@
}
int pldm_bios_table_attr_value_entry_encode_enum_check(
- void *entry, size_t entry_length, uint16_t attr_handle, uint8_t attr_type,
- uint8_t count, uint8_t *handles)
+ void *entry, size_t entry_length, uint16_t attr_handle,
+ uint8_t attr_type, uint8_t count, uint8_t *handles)
{
POINTER_CHECK(entry);
if (count != 0 && handles == NULL) {
@@ -672,17 +681,17 @@
}
ATTR_TYPE_EXPECT(attr_type, PLDM_BIOS_ENUMERATION);
size_t length =
- pldm_bios_table_attr_value_entry_encode_enum_length(count);
+ pldm_bios_table_attr_value_entry_encode_enum_length(count);
BUFFER_SIZE_EXPECT(entry_length, length);
pldm_bios_table_attr_value_entry_encode_enum(
- entry, entry_length, attr_handle, attr_type, count, handles);
+ entry, entry_length, attr_handle, attr_type, count, handles);
return PLDM_SUCCESS;
}
static size_t attr_value_table_entry_length_enum(const void *entry)
{
uint8_t number =
- pldm_bios_table_attr_value_entry_enum_decode_number(entry);
+ pldm_bios_table_attr_value_entry_enum_decode_number(entry);
return pldm_bios_table_attr_value_entry_encode_enum_length(number);
}
@@ -694,11 +703,11 @@
}
void pldm_bios_table_attr_value_entry_encode_string(
- void *entry, size_t entry_length, uint16_t attr_handle, uint8_t attr_type,
- uint16_t str_length, const char *str)
+ void *entry, size_t entry_length, uint16_t attr_handle,
+ uint8_t attr_type, uint16_t str_length, const char *str)
{
- size_t length =
- pldm_bios_table_attr_value_entry_encode_string_length(str_length);
+ size_t length = pldm_bios_table_attr_value_entry_encode_string_length(
+ str_length);
assert(length <= entry_length);
struct pldm_bios_attr_val_table_entry *table_entry = entry;
@@ -713,7 +722,7 @@
}
uint16_t pldm_bios_table_attr_value_entry_string_decode_length(
- const struct pldm_bios_attr_val_table_entry *entry)
+ const struct pldm_bios_attr_val_table_entry *entry)
{
uint16_t str_length = 0;
memcpy(&str_length, entry->value, sizeof(str_length));
@@ -721,38 +730,38 @@
}
void pldm_bios_table_attr_value_entry_string_decode_string(
- const struct pldm_bios_attr_val_table_entry *entry,
- struct variable_field *current_string)
+ const struct pldm_bios_attr_val_table_entry *entry,
+ struct variable_field *current_string)
{
current_string->length =
- pldm_bios_table_attr_value_entry_string_decode_length(entry);
+ pldm_bios_table_attr_value_entry_string_decode_length(entry);
current_string->ptr =
- entry->value + sizeof(uint16_t); // sizeof(CurrentStringLength)
+ entry->value + sizeof(uint16_t); // sizeof(CurrentStringLength)
}
int pldm_bios_table_attr_value_entry_encode_string_check(
- void *entry, size_t entry_length, uint16_t attr_handle, uint8_t attr_type,
- uint16_t str_length, const char *str)
+ void *entry, size_t entry_length, uint16_t attr_handle,
+ uint8_t attr_type, uint16_t str_length, const char *str)
{
POINTER_CHECK(entry);
if (str_length != 0 && str == NULL) {
return PLDM_ERROR_INVALID_DATA;
}
ATTR_TYPE_EXPECT(attr_type, PLDM_BIOS_STRING);
- size_t length =
- pldm_bios_table_attr_value_entry_encode_string_length(str_length);
+ size_t length = pldm_bios_table_attr_value_entry_encode_string_length(
+ str_length);
BUFFER_SIZE_EXPECT(entry_length, length);
pldm_bios_table_attr_value_entry_encode_string(
- entry, entry_length, attr_handle, attr_type, str_length, str);
+ entry, entry_length, attr_handle, attr_type, str_length, str);
return PLDM_SUCCESS;
}
static size_t attr_value_table_entry_length_string(const void *entry)
{
uint16_t str_length =
- pldm_bios_table_attr_value_entry_string_decode_length(entry);
+ pldm_bios_table_attr_value_entry_string_decode_length(entry);
return pldm_bios_table_attr_value_entry_encode_string_length(
- str_length);
+ str_length);
}
size_t pldm_bios_table_attr_value_entry_encode_integer_length(void)
@@ -767,7 +776,7 @@
uint64_t cv)
{
size_t length =
- pldm_bios_table_attr_value_entry_encode_integer_length();
+ pldm_bios_table_attr_value_entry_encode_integer_length();
assert(length <= entry_length);
struct pldm_bios_attr_val_table_entry *table_entry = entry;
@@ -785,16 +794,16 @@
{
POINTER_CHECK(entry);
size_t length =
- pldm_bios_table_attr_value_entry_encode_integer_length();
+ pldm_bios_table_attr_value_entry_encode_integer_length();
ATTR_TYPE_EXPECT(attr_type, PLDM_BIOS_INTEGER);
BUFFER_SIZE_EXPECT(entry_length, length);
pldm_bios_table_attr_value_entry_encode_integer(
- entry, entry_length, attr_handle, attr_type, cv);
+ entry, entry_length, attr_handle, attr_type, cv);
return PLDM_SUCCESS;
}
uint64_t pldm_bios_table_attr_value_entry_integer_decode_cv(
- const struct pldm_bios_attr_val_table_entry *entry)
+ const struct pldm_bios_attr_val_table_entry *entry)
{
uint64_t cv = 0;
memcpy(&cv, entry->value, sizeof(cv));
@@ -809,27 +818,27 @@
}
static const struct table_entry_length attr_value_table_entries[] = {
- {.attr_type = PLDM_BIOS_ENUMERATION,
- .entry_length_handler = attr_value_table_entry_length_enum},
- {.attr_type = PLDM_BIOS_ENUMERATION_READ_ONLY,
- .entry_length_handler = attr_value_table_entry_length_enum},
- {.attr_type = PLDM_BIOS_STRING,
- .entry_length_handler = attr_value_table_entry_length_string},
- {.attr_type = PLDM_BIOS_STRING_READ_ONLY,
- .entry_length_handler = attr_value_table_entry_length_string},
- {.attr_type = PLDM_BIOS_INTEGER,
- .entry_length_handler = attr_value_table_entry_length_integer},
- {.attr_type = PLDM_BIOS_INTEGER_READ_ONLY,
- .entry_length_handler = attr_value_table_entry_length_integer},
+ { .attr_type = PLDM_BIOS_ENUMERATION,
+ .entry_length_handler = attr_value_table_entry_length_enum },
+ { .attr_type = PLDM_BIOS_ENUMERATION_READ_ONLY,
+ .entry_length_handler = attr_value_table_entry_length_enum },
+ { .attr_type = PLDM_BIOS_STRING,
+ .entry_length_handler = attr_value_table_entry_length_string },
+ { .attr_type = PLDM_BIOS_STRING_READ_ONLY,
+ .entry_length_handler = attr_value_table_entry_length_string },
+ { .attr_type = PLDM_BIOS_INTEGER,
+ .entry_length_handler = attr_value_table_entry_length_integer },
+ { .attr_type = PLDM_BIOS_INTEGER_READ_ONLY,
+ .entry_length_handler = attr_value_table_entry_length_integer },
};
static size_t attr_value_table_entry_length(const void *table_entry)
{
const struct pldm_bios_attr_val_table_entry *entry = table_entry;
const struct table_entry_length *entry_length =
- find_table_entry_length_by_type(
- entry->attr_type, attr_value_table_entries,
- ARRAY_SIZE(attr_value_table_entries));
+ find_table_entry_length_by_type(
+ entry->attr_type, attr_value_table_entries,
+ ARRAY_SIZE(attr_value_table_entries));
assert(entry_length != NULL);
assert(entry_length->entry_length_handler != NULL);
@@ -837,13 +846,13 @@
}
size_t pldm_bios_table_attr_value_entry_length(
- const struct pldm_bios_attr_val_table_entry *entry)
+ const struct pldm_bios_attr_val_table_entry *entry)
{
return attr_value_table_entry_length(entry);
}
uint16_t pldm_bios_table_attr_value_entry_decode_handle(
- const struct pldm_bios_attr_val_table_entry *entry)
+ const struct pldm_bios_attr_val_table_entry *entry)
{
return le16toh(entry->attr_handle);
}
@@ -880,9 +889,8 @@
size_t pldm_bios_table_append_pad_checksum(void *table, size_t size,
size_t size_without_pad)
{
-
size_t pad_checksum_size =
- pldm_bios_table_pad_checksum_size(size_without_pad);
+ pldm_bios_table_pad_checksum_size(size_without_pad);
size_t total_length = size_without_pad + pad_checksum_size;
assert(size >= total_length);
@@ -979,9 +987,9 @@
equal_handler equal, const void *key)
{
struct pldm_bios_table_iter *iter =
- pldm_bios_table_iter_create(table, length, type);
+ pldm_bios_table_iter_create(table, length, type);
const void *entry =
- pldm_bios_table_entry_find_by_iter(iter, key, equal);
+ pldm_bios_table_entry_find_by_iter(iter, key, equal);
pldm_bios_table_iter_free(iter);
return entry;
}
@@ -1001,9 +1009,10 @@
pldm_bios_table_string_find_by_handle(const void *table, size_t length,
uint16_t handle)
{
- return pldm_bios_table_entry_find_from_table(
- table, length, PLDM_BIOS_STRING_TABLE, string_table_handle_equal,
- &handle);
+ return pldm_bios_table_entry_find_from_table(table, length,
+ PLDM_BIOS_STRING_TABLE,
+ string_table_handle_equal,
+ &handle);
}
struct string_equal_arg {
@@ -1030,10 +1039,11 @@
const char *str)
{
uint16_t str_length = strlen(str);
- struct string_equal_arg arg = {str_length, str};
- return pldm_bios_table_entry_find_from_table(
- table, length, PLDM_BIOS_STRING_TABLE, string_table_string_equal,
- &arg);
+ struct string_equal_arg arg = { str_length, str };
+ return pldm_bios_table_entry_find_from_table(table, length,
+ PLDM_BIOS_STRING_TABLE,
+ string_table_string_equal,
+ &arg);
}
static bool attr_table_handle_equal(const void *entry, const void *key)
@@ -1047,9 +1057,10 @@
pldm_bios_table_attr_find_by_handle(const void *table, size_t length,
uint16_t handle)
{
- return pldm_bios_table_entry_find_from_table(
- table, length, PLDM_BIOS_ATTR_TABLE, attr_table_handle_equal,
- &handle);
+ return pldm_bios_table_entry_find_from_table(table, length,
+ PLDM_BIOS_ATTR_TABLE,
+ attr_table_handle_equal,
+ &handle);
}
static bool attr_table_string_handle_equal(const void *entry, const void *key)
@@ -1063,8 +1074,8 @@
uint16_t handle)
{
return pldm_bios_table_entry_find_from_table(
- table, length, PLDM_BIOS_ATTR_TABLE, attr_table_string_handle_equal,
- &handle);
+ table, length, PLDM_BIOS_ATTR_TABLE,
+ attr_table_string_handle_equal, &handle);
}
static bool attr_value_table_handle_equal(const void *entry, const void *key)
@@ -1078,16 +1089,16 @@
uint16_t handle)
{
return pldm_bios_table_entry_find_from_table(
- table, length, PLDM_BIOS_ATTR_VAL_TABLE,
- attr_value_table_handle_equal, &handle);
+ table, length, PLDM_BIOS_ATTR_VAL_TABLE,
+ attr_value_table_handle_equal, &handle);
}
int pldm_bios_table_attr_value_copy_and_update(
- const void *src_table, size_t src_length, void *dest_table,
- size_t *dest_length, const void *entry, size_t entry_length)
+ const void *src_table, size_t src_length, void *dest_table,
+ size_t *dest_length, const void *entry, size_t entry_length)
{
struct pldm_bios_table_iter *iter = pldm_bios_table_iter_create(
- src_table, src_length, PLDM_BIOS_ATTR_VAL_TABLE);
+ src_table, src_length, PLDM_BIOS_ATTR_VAL_TABLE);
int rc = PLDM_SUCCESS;
const struct pldm_bios_attr_val_table_entry *tmp;
@@ -1120,14 +1131,14 @@
}
size_t pad_checksum_size =
- pldm_bios_table_pad_checksum_size(copied_length);
+ pldm_bios_table_pad_checksum_size(copied_length);
if ((pad_checksum_size + copied_length) > buffer_length) {
rc = PLDM_ERROR_INVALID_LENGTH;
goto out;
}
*dest_length = pldm_bios_table_append_pad_checksum(
- dest_table, buffer_length, copied_length);
+ dest_table, buffer_length, copied_length);
out:
pldm_bios_table_iter_free(iter);
return rc;
diff --git a/src/firmware_update.c b/src/firmware_update.c
index c5a213f..91fbb33 100644
--- a/src/firmware_update.c
+++ b/src/firmware_update.c
@@ -33,7 +33,6 @@
static uint16_t get_descriptor_type_length(uint16_t descriptor_type)
{
switch (descriptor_type) {
-
case PLDM_FWUP_PCI_VENDOR_ID:
return PLDM_FWUP_PCI_VENDOR_ID_LENGTH;
case PLDM_FWUP_IANA_ENTERPRISE_ID:
@@ -112,9 +111,9 @@
default:
if (comp_resp_code >=
- PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MIN &&
+ PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MIN &&
comp_resp_code <=
- PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MAX) {
+ PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MAX) {
return true;
}
return false;
@@ -161,9 +160,9 @@
default:
if (comp_compatibility_resp_code >=
- PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MIN &&
+ PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MIN &&
comp_compatibility_resp_code <=
- PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MAX) {
+ PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MAX) {
return true;
}
return false;
@@ -260,7 +259,6 @@
*/
static bool is_reason_code_valid(uint8_t reason_code)
{
-
switch (reason_code) {
case PLDM_FD_INITIALIZATION:
case PLDM_FD_ACTIVATE_FW:
@@ -286,7 +284,7 @@
* @return true if non functioning component indication is valid, false if not
*/
static bool is_non_functioning_component_indication_valid(
- bool8_t non_functioning_component_indication)
+ bool8_t non_functioning_component_indication)
{
switch (non_functioning_component_indication) {
case PLDM_FWUP_COMPONENTS_FUNCTIONING:
@@ -299,9 +297,9 @@
}
int decode_pldm_package_header_info(
- const uint8_t *data, size_t length,
- struct pldm_package_header_information *package_header_info,
- struct variable_field *package_version_str)
+ const uint8_t *data, size_t length,
+ struct pldm_package_header_information *package_header_info,
+ struct variable_field *package_version_str)
{
if (data == NULL || package_header_info == NULL ||
package_version_str == NULL) {
@@ -313,7 +311,7 @@
}
struct pldm_package_header_information *data_header =
- (struct pldm_package_header_information *)(data);
+ (struct pldm_package_header_information *)(data);
if (!is_string_type_valid(data_header->package_version_string_type) ||
(data_header->package_version_string_length == 0)) {
@@ -321,7 +319,7 @@
}
if (length < sizeof(struct pldm_package_header_information) +
- data_header->package_version_string_length) {
+ data_header->package_version_string_length) {
return PLDM_ERROR_INVALID_LENGTH;
}
@@ -333,33 +331,34 @@
memcpy(package_header_info->uuid, data_header->uuid,
sizeof(data_header->uuid));
package_header_info->package_header_format_version =
- data_header->package_header_format_version;
+ data_header->package_header_format_version;
package_header_info->package_header_size =
- le16toh(data_header->package_header_size);
+ le16toh(data_header->package_header_size);
memcpy(package_header_info->package_release_date_time,
data_header->package_release_date_time,
sizeof(data_header->package_release_date_time));
package_header_info->component_bitmap_bit_length =
- le16toh(data_header->component_bitmap_bit_length);
+ le16toh(data_header->component_bitmap_bit_length);
package_header_info->package_version_string_type =
- data_header->package_version_string_type;
+ data_header->package_version_string_type;
package_header_info->package_version_string_length =
- data_header->package_version_string_length;
+ data_header->package_version_string_length;
package_version_str->ptr =
- data + sizeof(struct pldm_package_header_information);
+ data + sizeof(struct pldm_package_header_information);
package_version_str->length =
- package_header_info->package_version_string_length;
+ package_header_info->package_version_string_length;
return PLDM_SUCCESS;
}
int decode_firmware_device_id_record(
- const uint8_t *data, size_t length, uint16_t component_bitmap_bit_length,
- struct pldm_firmware_device_id_record *fw_device_id_record,
- struct variable_field *applicable_components,
- struct variable_field *comp_image_set_version_str,
- struct variable_field *record_descriptors,
- struct variable_field *fw_device_pkg_data)
+ const uint8_t *data, size_t length,
+ uint16_t component_bitmap_bit_length,
+ struct pldm_firmware_device_id_record *fw_device_id_record,
+ struct variable_field *applicable_components,
+ struct variable_field *comp_image_set_version_str,
+ struct variable_field *record_descriptors,
+ struct variable_field *fw_device_pkg_data)
{
if (data == NULL || fw_device_id_record == NULL ||
applicable_components == NULL ||
@@ -378,66 +377,67 @@
}
struct pldm_firmware_device_id_record *data_record =
- (struct pldm_firmware_device_id_record *)(data);
+ (struct pldm_firmware_device_id_record *)(data);
if (!is_string_type_valid(
- data_record->comp_image_set_version_string_type) ||
+ data_record->comp_image_set_version_string_type) ||
(data_record->comp_image_set_version_string_length == 0)) {
return PLDM_ERROR_INVALID_DATA;
}
fw_device_id_record->record_length =
- le16toh(data_record->record_length);
+ le16toh(data_record->record_length);
fw_device_id_record->descriptor_count = data_record->descriptor_count;
fw_device_id_record->device_update_option_flags.value =
- le32toh(data_record->device_update_option_flags.value);
+ le32toh(data_record->device_update_option_flags.value);
fw_device_id_record->comp_image_set_version_string_type =
- data_record->comp_image_set_version_string_type;
+ data_record->comp_image_set_version_string_type;
fw_device_id_record->comp_image_set_version_string_length =
- data_record->comp_image_set_version_string_length;
+ data_record->comp_image_set_version_string_length;
fw_device_id_record->fw_device_pkg_data_length =
- le16toh(data_record->fw_device_pkg_data_length);
+ le16toh(data_record->fw_device_pkg_data_length);
if (length < fw_device_id_record->record_length) {
return PLDM_ERROR_INVALID_LENGTH;
}
uint16_t applicable_components_length =
- component_bitmap_bit_length / PLDM_FWUP_COMPONENT_BITMAP_MULTIPLE;
+ component_bitmap_bit_length /
+ PLDM_FWUP_COMPONENT_BITMAP_MULTIPLE;
uint16_t calc_min_record_length =
- sizeof(struct pldm_firmware_device_id_record) +
- applicable_components_length +
- data_record->comp_image_set_version_string_length +
- PLDM_FWUP_DEVICE_DESCRIPTOR_MIN_LEN +
- fw_device_id_record->fw_device_pkg_data_length;
+ sizeof(struct pldm_firmware_device_id_record) +
+ applicable_components_length +
+ data_record->comp_image_set_version_string_length +
+ PLDM_FWUP_DEVICE_DESCRIPTOR_MIN_LEN +
+ fw_device_id_record->fw_device_pkg_data_length;
if (fw_device_id_record->record_length < calc_min_record_length) {
return PLDM_ERROR_INVALID_LENGTH;
}
applicable_components->ptr =
- data + sizeof(struct pldm_firmware_device_id_record);
+ data + sizeof(struct pldm_firmware_device_id_record);
applicable_components->length = applicable_components_length;
comp_image_set_version_str->ptr =
- applicable_components->ptr + applicable_components->length;
+ applicable_components->ptr + applicable_components->length;
comp_image_set_version_str->length =
- fw_device_id_record->comp_image_set_version_string_length;
+ fw_device_id_record->comp_image_set_version_string_length;
record_descriptors->ptr = comp_image_set_version_str->ptr +
comp_image_set_version_str->length;
record_descriptors->length =
- fw_device_id_record->record_length -
- sizeof(struct pldm_firmware_device_id_record) -
- applicable_components_length -
- fw_device_id_record->comp_image_set_version_string_length -
- fw_device_id_record->fw_device_pkg_data_length;
+ fw_device_id_record->record_length -
+ sizeof(struct pldm_firmware_device_id_record) -
+ applicable_components_length -
+ fw_device_id_record->comp_image_set_version_string_length -
+ fw_device_id_record->fw_device_pkg_data_length;
if (fw_device_id_record->fw_device_pkg_data_length) {
fw_device_pkg_data->ptr =
- record_descriptors->ptr + record_descriptors->length;
+ record_descriptors->ptr + record_descriptors->length;
fw_device_pkg_data->length =
- fw_device_id_record->fw_device_pkg_data_length;
+ fw_device_id_record->fw_device_pkg_data_length;
}
return PLDM_SUCCESS;
@@ -459,7 +459,7 @@
}
struct pldm_descriptor_tlv *entry =
- (struct pldm_descriptor_tlv *)(data);
+ (struct pldm_descriptor_tlv *)(data);
*descriptor_type = le16toh(entry->descriptor_type);
descriptor_length = le16toh(entry->descriptor_length);
@@ -482,9 +482,9 @@
}
int decode_vendor_defined_descriptor_value(
- const uint8_t *data, size_t length, uint8_t *descriptor_title_str_type,
- struct variable_field *descriptor_title_str,
- struct variable_field *descriptor_data)
+ const uint8_t *data, size_t length, uint8_t *descriptor_title_str_type,
+ struct variable_field *descriptor_title_str,
+ struct variable_field *descriptor_data)
{
if (data == NULL || descriptor_title_str_type == NULL ||
descriptor_title_str == NULL || descriptor_data == NULL) {
@@ -496,9 +496,9 @@
}
struct pldm_vendor_defined_descriptor_title_data *entry =
- (struct pldm_vendor_defined_descriptor_title_data *)(data);
+ (struct pldm_vendor_defined_descriptor_title_data *)(data);
if (!is_string_type_valid(
- entry->vendor_defined_descriptor_title_str_type) ||
+ entry->vendor_defined_descriptor_title_str_type) ||
(entry->vendor_defined_descriptor_title_str_len == 0)) {
return PLDM_ERROR_INVALID_DATA;
}
@@ -510,25 +510,26 @@
}
*descriptor_title_str_type =
- entry->vendor_defined_descriptor_title_str_type;
+ entry->vendor_defined_descriptor_title_str_type;
descriptor_title_str->ptr = entry->vendor_defined_descriptor_title_str;
descriptor_title_str->length =
- entry->vendor_defined_descriptor_title_str_len;
+ entry->vendor_defined_descriptor_title_str_len;
descriptor_data->ptr =
- descriptor_title_str->ptr + descriptor_title_str->length;
+ descriptor_title_str->ptr + descriptor_title_str->length;
descriptor_data->length =
- length - sizeof(entry->vendor_defined_descriptor_title_str_type) -
- sizeof(entry->vendor_defined_descriptor_title_str_len) -
- descriptor_title_str->length;
+ length -
+ sizeof(entry->vendor_defined_descriptor_title_str_type) -
+ sizeof(entry->vendor_defined_descriptor_title_str_len) -
+ descriptor_title_str->length;
return PLDM_SUCCESS;
}
int decode_pldm_comp_image_info(
- const uint8_t *data, size_t length,
- struct pldm_component_image_information *pldm_comp_image_info,
- struct variable_field *comp_version_str)
+ const uint8_t *data, size_t length,
+ struct pldm_component_image_information *pldm_comp_image_info,
+ struct variable_field *comp_version_str)
{
if (data == NULL || pldm_comp_image_info == NULL ||
comp_version_str == NULL) {
@@ -540,7 +541,7 @@
}
struct pldm_component_image_information *data_header =
- (struct pldm_component_image_information *)(data);
+ (struct pldm_component_image_information *)(data);
if (!is_string_type_valid(data_header->comp_version_string_type) ||
(data_header->comp_version_string_length == 0)) {
@@ -548,31 +549,31 @@
}
if (length < sizeof(struct pldm_component_image_information) +
- data_header->comp_version_string_length) {
+ data_header->comp_version_string_length) {
return PLDM_ERROR_INVALID_LENGTH;
}
pldm_comp_image_info->comp_classification =
- le16toh(data_header->comp_classification);
+ le16toh(data_header->comp_classification);
pldm_comp_image_info->comp_identifier =
- le16toh(data_header->comp_identifier);
+ le16toh(data_header->comp_identifier);
pldm_comp_image_info->comp_comparison_stamp =
- le32toh(data_header->comp_comparison_stamp);
+ le32toh(data_header->comp_comparison_stamp);
pldm_comp_image_info->comp_options.value =
- le16toh(data_header->comp_options.value);
+ le16toh(data_header->comp_options.value);
pldm_comp_image_info->requested_comp_activation_method.value =
- le16toh(data_header->requested_comp_activation_method.value);
+ le16toh(data_header->requested_comp_activation_method.value);
pldm_comp_image_info->comp_location_offset =
- le32toh(data_header->comp_location_offset);
+ le32toh(data_header->comp_location_offset);
pldm_comp_image_info->comp_size = le32toh(data_header->comp_size);
pldm_comp_image_info->comp_version_string_type =
- data_header->comp_version_string_type;
+ data_header->comp_version_string_type;
pldm_comp_image_info->comp_version_string_length =
- data_header->comp_version_string_length;
+ data_header->comp_version_string_length;
if ((pldm_comp_image_info->comp_options.bits.bit1 == false &&
pldm_comp_image_info->comp_comparison_stamp !=
- PLDM_FWUP_INVALID_COMPONENT_COMPARISON_TIMESTAMP)) {
+ PLDM_FWUP_INVALID_COMPONENT_COMPARISON_TIMESTAMP)) {
return PLDM_ERROR_INVALID_DATA;
}
@@ -582,9 +583,9 @@
}
comp_version_str->ptr =
- data + sizeof(struct pldm_component_image_information);
+ data + sizeof(struct pldm_component_image_information);
comp_version_str->length =
- pldm_comp_image_info->comp_version_string_length;
+ pldm_comp_image_info->comp_version_string_length;
return PLDM_SUCCESS;
}
@@ -629,7 +630,7 @@
}
struct pldm_query_device_identifiers_resp *response =
- (struct pldm_query_device_identifiers_resp *)msg->payload;
+ (struct pldm_query_device_identifiers_resp *)msg->payload;
*device_identifiers_len = le32toh(response->device_identifiers_len);
if (*device_identifiers_len < PLDM_FWUP_DEVICE_DESCRIPTOR_MIN_LEN) {
@@ -638,7 +639,7 @@
if (payload_length !=
sizeof(struct pldm_query_device_identifiers_resp) +
- *device_identifiers_len) {
+ *device_identifiers_len) {
return PLDM_ERROR_INVALID_LENGTH;
}
*descriptor_count = response->descriptor_count;
@@ -647,8 +648,8 @@
return PLDM_ERROR_INVALID_DATA;
}
*descriptor_data =
- (uint8_t *)(msg->payload +
- sizeof(struct pldm_query_device_identifiers_resp));
+ (uint8_t *)(msg->payload +
+ sizeof(struct pldm_query_device_identifiers_resp));
return PLDM_SUCCESS;
}
@@ -669,11 +670,11 @@
}
int decode_get_firmware_parameters_resp(
- const struct pldm_msg *msg, size_t payload_length,
- struct pldm_get_firmware_parameters_resp *resp_data,
- struct variable_field *active_comp_image_set_ver_str,
- struct variable_field *pending_comp_image_set_ver_str,
- struct variable_field *comp_parameter_table)
+ const struct pldm_msg *msg, size_t payload_length,
+ struct pldm_get_firmware_parameters_resp *resp_data,
+ struct variable_field *active_comp_image_set_ver_str,
+ struct variable_field *pending_comp_image_set_ver_str,
+ struct variable_field *comp_parameter_table)
{
if (msg == NULL || resp_data == NULL ||
active_comp_image_set_ver_str == NULL ||
@@ -692,10 +693,10 @@
}
struct pldm_get_firmware_parameters_resp *response =
- (struct pldm_get_firmware_parameters_resp *)msg->payload;
+ (struct pldm_get_firmware_parameters_resp *)msg->payload;
if (!is_string_type_valid(
- response->active_comp_image_set_ver_str_type) ||
+ response->active_comp_image_set_ver_str_type) ||
(response->active_comp_image_set_ver_str_len == 0)) {
return PLDM_ERROR_INVALID_DATA;
}
@@ -707,44 +708,44 @@
}
} else {
if (!is_string_type_valid(
- response->pending_comp_image_set_ver_str_type)) {
+ response->pending_comp_image_set_ver_str_type)) {
return PLDM_ERROR_INVALID_DATA;
}
}
size_t partial_response_length =
- sizeof(struct pldm_get_firmware_parameters_resp) +
- response->active_comp_image_set_ver_str_len +
- response->pending_comp_image_set_ver_str_len;
+ sizeof(struct pldm_get_firmware_parameters_resp) +
+ response->active_comp_image_set_ver_str_len +
+ response->pending_comp_image_set_ver_str_len;
if (payload_length < partial_response_length) {
return PLDM_ERROR_INVALID_LENGTH;
}
resp_data->capabilities_during_update.value =
- le32toh(response->capabilities_during_update.value);
+ le32toh(response->capabilities_during_update.value);
resp_data->comp_count = le16toh(response->comp_count);
resp_data->active_comp_image_set_ver_str_type =
- response->active_comp_image_set_ver_str_type;
+ response->active_comp_image_set_ver_str_type;
resp_data->active_comp_image_set_ver_str_len =
- response->active_comp_image_set_ver_str_len;
+ response->active_comp_image_set_ver_str_len;
resp_data->pending_comp_image_set_ver_str_type =
- response->pending_comp_image_set_ver_str_type;
+ response->pending_comp_image_set_ver_str_type;
resp_data->pending_comp_image_set_ver_str_len =
- response->pending_comp_image_set_ver_str_len;
+ response->pending_comp_image_set_ver_str_len;
active_comp_image_set_ver_str->ptr =
- msg->payload + sizeof(struct pldm_get_firmware_parameters_resp);
+ msg->payload + sizeof(struct pldm_get_firmware_parameters_resp);
active_comp_image_set_ver_str->length =
- resp_data->active_comp_image_set_ver_str_len;
+ resp_data->active_comp_image_set_ver_str_len;
if (resp_data->pending_comp_image_set_ver_str_len != 0) {
pending_comp_image_set_ver_str->ptr =
- msg->payload +
- sizeof(struct pldm_get_firmware_parameters_resp) +
- resp_data->active_comp_image_set_ver_str_len;
+ msg->payload +
+ sizeof(struct pldm_get_firmware_parameters_resp) +
+ resp_data->active_comp_image_set_ver_str_len;
pending_comp_image_set_ver_str->length =
- resp_data->pending_comp_image_set_ver_str_len;
+ resp_data->pending_comp_image_set_ver_str_len;
} else {
pending_comp_image_set_ver_str->ptr = NULL;
pending_comp_image_set_ver_str->length = 0;
@@ -752,12 +753,12 @@
if (payload_length > partial_response_length && resp_data->comp_count) {
comp_parameter_table->ptr =
- msg->payload +
- sizeof(struct pldm_get_firmware_parameters_resp) +
- resp_data->active_comp_image_set_ver_str_len +
- resp_data->pending_comp_image_set_ver_str_len;
+ msg->payload +
+ sizeof(struct pldm_get_firmware_parameters_resp) +
+ resp_data->active_comp_image_set_ver_str_len +
+ resp_data->pending_comp_image_set_ver_str_len;
comp_parameter_table->length =
- payload_length - partial_response_length;
+ payload_length - partial_response_length;
} else {
comp_parameter_table->ptr = NULL;
comp_parameter_table->length = 0;
@@ -767,10 +768,10 @@
}
int decode_get_firmware_parameters_resp_comp_entry(
- const uint8_t *data, size_t length,
- struct pldm_component_parameter_entry *component_data,
- struct variable_field *active_comp_ver_str,
- struct variable_field *pending_comp_ver_str)
+ const uint8_t *data, size_t length,
+ struct pldm_component_parameter_entry *component_data,
+ struct variable_field *active_comp_ver_str,
+ struct variable_field *pending_comp_ver_str)
{
if (data == NULL || component_data == NULL ||
active_comp_ver_str == NULL || pending_comp_ver_str == NULL) {
@@ -782,7 +783,7 @@
}
struct pldm_component_parameter_entry *entry =
- (struct pldm_component_parameter_entry *)(data);
+ (struct pldm_component_parameter_entry *)(data);
size_t entry_length = sizeof(struct pldm_component_parameter_entry) +
entry->active_comp_ver_str_len +
@@ -793,36 +794,36 @@
}
component_data->comp_classification =
- le16toh(entry->comp_classification);
+ le16toh(entry->comp_classification);
component_data->comp_identifier = le16toh(entry->comp_identifier);
component_data->comp_classification_index =
- entry->comp_classification_index;
+ entry->comp_classification_index;
component_data->active_comp_comparison_stamp =
- le32toh(entry->active_comp_comparison_stamp);
+ le32toh(entry->active_comp_comparison_stamp);
component_data->active_comp_ver_str_type =
- entry->active_comp_ver_str_type;
+ entry->active_comp_ver_str_type;
component_data->active_comp_ver_str_len =
- entry->active_comp_ver_str_len;
+ entry->active_comp_ver_str_len;
memcpy(component_data->active_comp_release_date,
entry->active_comp_release_date,
sizeof(entry->active_comp_release_date));
component_data->pending_comp_comparison_stamp =
- le32toh(entry->pending_comp_comparison_stamp);
+ le32toh(entry->pending_comp_comparison_stamp);
component_data->pending_comp_ver_str_type =
- entry->pending_comp_ver_str_type;
+ entry->pending_comp_ver_str_type;
component_data->pending_comp_ver_str_len =
- entry->pending_comp_ver_str_len;
+ entry->pending_comp_ver_str_len;
memcpy(component_data->pending_comp_release_date,
entry->pending_comp_release_date,
sizeof(entry->pending_comp_release_date));
component_data->comp_activation_methods.value =
- le16toh(entry->comp_activation_methods.value);
+ le16toh(entry->comp_activation_methods.value);
component_data->capabilities_during_update.value =
- le32toh(entry->capabilities_during_update.value);
+ le32toh(entry->capabilities_during_update.value);
if (entry->active_comp_ver_str_len != 0) {
active_comp_ver_str->ptr =
- data + sizeof(struct pldm_component_parameter_entry);
+ data + sizeof(struct pldm_component_parameter_entry);
active_comp_ver_str->length = entry->active_comp_ver_str_len;
} else {
active_comp_ver_str->ptr = NULL;
@@ -830,10 +831,9 @@
}
if (entry->pending_comp_ver_str_len != 0) {
-
pending_comp_ver_str->ptr =
- data + sizeof(struct pldm_component_parameter_entry) +
- entry->active_comp_ver_str_len;
+ data + sizeof(struct pldm_component_parameter_entry) +
+ entry->active_comp_ver_str_len;
pending_comp_ver_str->length = entry->pending_comp_ver_str_len;
} else {
pending_comp_ver_str->ptr = NULL;
@@ -857,7 +857,7 @@
}
if (payload_length != sizeof(struct pldm_request_update_req) +
- comp_img_set_ver_str->length) {
+ comp_img_set_ver_str->length) {
return PLDM_ERROR_INVALID_LENGTH;
}
@@ -875,7 +875,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_FWUP;
@@ -886,7 +886,7 @@
}
struct pldm_request_update_req *request =
- (struct pldm_request_update_req *)msg->payload;
+ (struct pldm_request_update_req *)msg->payload;
request->max_transfer_size = htole32(max_transfer_size);
request->num_of_comp = htole16(num_of_comp);
@@ -922,7 +922,7 @@
}
struct pldm_request_update_resp *response =
- (struct pldm_request_update_resp *)msg->payload;
+ (struct pldm_request_update_resp *)msg->payload;
*fd_meta_data_len = le16toh(response->fd_meta_data_len);
*fd_will_send_pkg_data = response->fd_will_send_pkg_data;
@@ -930,19 +930,22 @@
return PLDM_SUCCESS;
}
-int encode_pass_component_table_req(
- uint8_t instance_id, uint8_t transfer_flag, uint16_t comp_classification,
- uint16_t comp_identifier, uint8_t comp_classification_index,
- uint32_t comp_comparison_stamp, uint8_t comp_ver_str_type,
- uint8_t comp_ver_str_len, const struct variable_field *comp_ver_str,
- struct pldm_msg *msg, size_t payload_length)
+int encode_pass_component_table_req(uint8_t instance_id, uint8_t transfer_flag,
+ uint16_t comp_classification,
+ uint16_t comp_identifier,
+ uint8_t comp_classification_index,
+ uint32_t comp_comparison_stamp,
+ uint8_t comp_ver_str_type,
+ uint8_t comp_ver_str_len,
+ const struct variable_field *comp_ver_str,
+ struct pldm_msg *msg, size_t payload_length)
{
if (comp_ver_str == NULL || comp_ver_str->ptr == NULL || msg == NULL) {
return PLDM_ERROR_INVALID_DATA;
}
if (payload_length != sizeof(struct pldm_pass_component_table_req) +
- comp_ver_str->length) {
+ comp_ver_str->length) {
return PLDM_ERROR_INVALID_LENGTH;
}
@@ -959,7 +962,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_FWUP;
@@ -970,7 +973,7 @@
}
struct pldm_pass_component_table_req *request =
- (struct pldm_pass_component_table_req *)msg->payload;
+ (struct pldm_pass_component_table_req *)msg->payload;
request->transfer_flag = transfer_flag;
request->comp_classification = htole16(comp_classification);
@@ -1007,7 +1010,7 @@
}
struct pldm_pass_component_table_resp *response =
- (struct pldm_pass_component_table_resp *)msg->payload;
+ (struct pldm_pass_component_table_resp *)msg->payload;
if (!is_comp_resp_valid(response->comp_resp)) {
return PLDM_ERROR_INVALID_DATA;
@@ -1024,12 +1027,12 @@
}
int encode_update_component_req(
- uint8_t instance_id, uint16_t comp_classification, uint16_t comp_identifier,
- uint8_t comp_classification_index, uint32_t comp_comparison_stamp,
- uint32_t comp_image_size, bitfield32_t update_option_flags,
- uint8_t comp_ver_str_type, uint8_t comp_ver_str_len,
- const struct variable_field *comp_ver_str, struct pldm_msg *msg,
- size_t payload_length)
+ uint8_t instance_id, uint16_t comp_classification,
+ uint16_t comp_identifier, uint8_t comp_classification_index,
+ uint32_t comp_comparison_stamp, uint32_t comp_image_size,
+ bitfield32_t update_option_flags, uint8_t comp_ver_str_type,
+ uint8_t comp_ver_str_len, const struct variable_field *comp_ver_str,
+ struct pldm_msg *msg, size_t payload_length)
{
if (comp_ver_str == NULL || comp_ver_str->ptr == NULL || msg == NULL) {
return PLDM_ERROR_INVALID_DATA;
@@ -1053,7 +1056,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_FWUP;
@@ -1064,7 +1067,7 @@
}
struct pldm_update_component_req *request =
- (struct pldm_update_component_req *)msg->payload;
+ (struct pldm_update_component_req *)msg->payload;
request->comp_classification = htole16(comp_classification);
request->comp_identifier = htole16(comp_identifier);
@@ -1107,22 +1110,22 @@
}
struct pldm_update_component_resp *response =
- (struct pldm_update_component_resp *)msg->payload;
+ (struct pldm_update_component_resp *)msg->payload;
if (!is_comp_compatibility_resp_valid(
- response->comp_compatibility_resp)) {
+ response->comp_compatibility_resp)) {
return PLDM_ERROR_INVALID_DATA;
}
if (!is_comp_compatibility_resp_code_valid(
- response->comp_compatibility_resp_code)) {
+ response->comp_compatibility_resp_code)) {
return PLDM_ERROR_INVALID_DATA;
}
*comp_compatibility_resp = response->comp_compatibility_resp;
*comp_compatibility_resp_code = response->comp_compatibility_resp_code;
update_option_flags_enabled->value =
- le32toh(response->update_option_flags_enabled.value);
+ le32toh(response->update_option_flags_enabled.value);
*time_before_req_fw_data = le16toh(response->time_before_req_fw_data);
return PLDM_SUCCESS;
@@ -1139,7 +1142,7 @@
return PLDM_ERROR_INVALID_LENGTH;
}
struct pldm_request_firmware_data_req *request =
- (struct pldm_request_firmware_data_req *)msg->payload;
+ (struct pldm_request_firmware_data_req *)msg->payload;
*offset = le32toh(request->offset);
*length = le32toh(request->length);
@@ -1159,7 +1162,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_FWUP;
@@ -1201,7 +1204,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_FWUP;
@@ -1242,7 +1245,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_FWUP;
@@ -1257,9 +1260,9 @@
return PLDM_SUCCESS;
}
-int decode_apply_complete_req(
- const struct pldm_msg *msg, size_t payload_length, uint8_t *apply_result,
- bitfield16_t *comp_activation_methods_modification)
+int decode_apply_complete_req(const struct pldm_msg *msg, size_t payload_length,
+ uint8_t *apply_result,
+ bitfield16_t *comp_activation_methods_modification)
{
if (msg == NULL || apply_result == NULL ||
comp_activation_methods_modification == NULL) {
@@ -1271,11 +1274,11 @@
}
struct pldm_apply_complete_req *request =
- (struct pldm_apply_complete_req *)msg->payload;
+ (struct pldm_apply_complete_req *)msg->payload;
*apply_result = request->apply_result;
comp_activation_methods_modification->value =
- le16toh(request->comp_activation_methods_modification.value);
+ le16toh(request->comp_activation_methods_modification.value);
if ((*apply_result != PLDM_FWUP_APPLY_SUCCESS_WITH_ACTIVATION_METHOD) &&
comp_activation_methods_modification->value) {
@@ -1296,7 +1299,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_FWUP;
@@ -1324,11 +1327,11 @@
}
if (!is_self_contained_activation_req_valid(
- self_contained_activation_req)) {
+ self_contained_activation_req)) {
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_FWUP;
@@ -1339,7 +1342,7 @@
}
struct pldm_activate_firmware_req *request =
- (struct pldm_activate_firmware_req *)msg->payload;
+ (struct pldm_activate_firmware_req *)msg->payload;
request->self_contained_activation_req = self_contained_activation_req;
@@ -1366,10 +1369,10 @@
}
struct pldm_activate_firmware_resp *response =
- (struct pldm_activate_firmware_resp *)msg->payload;
+ (struct pldm_activate_firmware_resp *)msg->payload;
*estimated_time_activation =
- le16toh(response->estimated_time_activation);
+ le16toh(response->estimated_time_activation);
return PLDM_SUCCESS;
}
@@ -1385,7 +1388,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_FWUP;
@@ -1422,7 +1425,7 @@
return PLDM_ERROR_INVALID_LENGTH;
}
struct pldm_get_status_resp *response =
- (struct pldm_get_status_resp *)msg->payload;
+ (struct pldm_get_status_resp *)msg->payload;
if (!is_state_valid(response->current_state)) {
return PLDM_ERROR_INVALID_DATA;
@@ -1459,7 +1462,7 @@
*progress_percent = response->progress_percent;
*reason_code = response->reason_code;
update_option_flags_enabled->value =
- le32toh(response->update_option_flags_enabled.value);
+ le32toh(response->update_option_flags_enabled.value);
return PLDM_SUCCESS;
}
@@ -1476,7 +1479,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_FWUP;
@@ -1516,7 +1519,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_FWUP;
@@ -1549,19 +1552,19 @@
return PLDM_ERROR_INVALID_LENGTH;
}
struct pldm_cancel_update_resp *response =
- (struct pldm_cancel_update_resp *)msg->payload;
+ (struct pldm_cancel_update_resp *)msg->payload;
if (!is_non_functioning_component_indication_valid(
- response->non_functioning_component_indication)) {
+ response->non_functioning_component_indication)) {
return PLDM_ERROR_INVALID_DATA;
}
*non_functioning_component_indication =
- response->non_functioning_component_indication;
+ response->non_functioning_component_indication;
if (*non_functioning_component_indication) {
non_functioning_component_bitmap->value =
- le64toh(response->non_functioning_component_bitmap);
+ le64toh(response->non_functioning_component_bitmap);
}
return PLDM_SUCCESS;
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;
}
diff --git a/src/mctp-defines.h b/src/mctp-defines.h
index 6c3d086..912d47c 100644
--- a/src/mctp-defines.h
+++ b/src/mctp-defines.h
@@ -6,7 +6,7 @@
#endif
#define MCTP_MSG_TYPE_PLDM 1
-#define MCTP_MAX_NUM_EID 256
+#define MCTP_MAX_NUM_EID 256
#ifdef __cplusplus
}
diff --git a/src/msgbuf.h b/src/msgbuf.h
index f5d4a54..62992a0 100644
--- a/src/msgbuf.h
+++ b/src/msgbuf.h
@@ -2,6 +2,13 @@
#define PLDM_MSGBUF_H
#ifdef __cplusplus
+/*
+ * Fix up C11's _Static_assert() vs C++'s static_assert().
+ *
+ * Can we please have nice things for once.
+ */
+// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
+#define _Static_assert(...) static_assert(__VA_ARGS__)
extern "C" {
#endif
@@ -333,14 +340,14 @@
}
#define pldm_msgbuf_extract(ctx, dst) \
- _Generic((*(dst)), uint8_t \
- : pldm_msgbuf_extract_uint8, int8_t \
- : pldm_msgbuf_extract_int8, uint16_t \
- : pldm_msgbuf_extract_uint16, int16_t \
- : pldm_msgbuf_extract_int16, uint32_t \
- : pldm_msgbuf_extract_uint32, int32_t \
- : pldm_msgbuf_extract_int32, real32_t \
- : pldm_msgbuf_extract_real32)(ctx, dst)
+ _Generic((*(dst)), \
+ uint8_t: pldm_msgbuf_extract_uint8, \
+ int8_t: pldm_msgbuf_extract_int8, \
+ uint16_t: pldm_msgbuf_extract_uint16, \
+ int16_t: pldm_msgbuf_extract_int16, \
+ uint32_t: pldm_msgbuf_extract_uint32, \
+ int32_t: pldm_msgbuf_extract_int32, \
+ real32_t: pldm_msgbuf_extract_real32)(ctx, dst)
static inline int pldm_msgbuf_extract_array_uint8(struct pldm_msgbuf *ctx,
uint8_t *dst, size_t count)
@@ -373,8 +380,8 @@
}
#define pldm_msgbuf_extract_array(ctx, dst, count) \
- _Generic((*(dst)), uint8_t \
- : pldm_msgbuf_extract_array_uint8)(ctx, dst, count)
+ _Generic((*(dst)), uint8_t: pldm_msgbuf_extract_array_uint8)(ctx, dst, \
+ count)
static inline int pldm_msgbuf_insert_uint32(struct pldm_msgbuf *ctx,
const uint32_t src)
@@ -499,13 +506,13 @@
}
#define pldm_msgbuf_insert(dst, src) \
- _Generic((src), uint8_t \
- : pldm_msgbuf_insert_uint8, int8_t \
- : pldm_msgbuf_insert_int8, uint16_t \
- : pldm_msgbuf_insert_uint16, int16_t \
- : pldm_msgbuf_insert_int16, uint32_t \
- : pldm_msgbuf_insert_uint32, int32_t \
- : pldm_msgbuf_insert_int32)(dst, src)
+ _Generic((src), \
+ uint8_t: pldm_msgbuf_insert_uint8, \
+ int8_t: pldm_msgbuf_insert_int8, \
+ uint16_t: pldm_msgbuf_insert_uint16, \
+ int16_t: pldm_msgbuf_insert_int16, \
+ uint32_t: pldm_msgbuf_insert_uint32, \
+ int32_t: pldm_msgbuf_insert_int32)(dst, src)
static inline int pldm_msgbuf_insert_array_uint8(struct pldm_msgbuf *ctx,
const uint8_t *src,
@@ -538,8 +545,8 @@
}
#define pldm_msgbuf_insert_array(dst, src, count) \
- _Generic((*(src)), uint8_t \
- : pldm_msgbuf_insert_array_uint8)(dst, src, count)
+ _Generic((*(src)), uint8_t: pldm_msgbuf_insert_array_uint8)(dst, src, \
+ count)
static inline int pldm_msgbuf_span_required(struct pldm_msgbuf *ctx,
size_t required, void **cursor)
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;
diff --git a/src/oem/ibm/host.c b/src/oem/ibm/host.c
index 5cdcf74..6534e5b 100644
--- a/src/oem/ibm/host.c
+++ b/src/oem/ibm/host.c
@@ -16,7 +16,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;
@@ -51,7 +51,7 @@
}
struct pldm_get_alert_status_resp *response =
- (struct pldm_get_alert_status_resp *)msg->payload;
+ (struct pldm_get_alert_status_resp *)msg->payload;
*rack_entry = le32toh(response->rack_entry);
*pri_cec_node = le32toh(response->pri_cec_node);
@@ -87,7 +87,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;
@@ -98,7 +98,7 @@
}
struct pldm_get_alert_status_resp *response =
- (struct pldm_get_alert_status_resp *)msg->payload;
+ (struct pldm_get_alert_status_resp *)msg->payload;
response->completion_code = completion_code;
response->rack_entry = htole32(rack_entry);
diff --git a/src/oem/ibm/platform.c b/src/oem/ibm/platform.c
index 15e9463..9f68bce 100644
--- a/src/oem/ibm/platform.c
+++ b/src/oem/ibm/platform.c
@@ -27,7 +27,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_PLATFORM;
@@ -38,7 +38,7 @@
}
struct pldm_bios_attribute_update_event_req *request =
- (struct pldm_bios_attribute_update_event_req *)msg->payload;
+ (struct pldm_bios_attribute_update_event_req *)msg->payload;
request->format_version = format_version;
request->tid = tid;
request->event_class = PLDM_EVENT_TYPE_OEM_EVENT_BIOS_ATTRIBUTE_UPDATE;
diff --git a/src/pdr.c b/src/pdr.c
index 2fe9e7b..232dd89 100644
--- a/src/pdr.c
+++ b/src/pdr.c
@@ -54,7 +54,7 @@
{
assert(repo != NULL);
uint32_t last_used_hdl =
- repo->last != NULL ? repo->last->record_handle : 0;
+ repo->last != NULL ? repo->last->record_handle : 0;
assert(last_used_hdl != UINT32_MAX);
return last_used_hdl + 1;
@@ -70,8 +70,9 @@
pldm_pdr_record *record = malloc(sizeof(pldm_pdr_record));
assert(record != NULL);
- record->record_handle =
- record_handle == 0 ? get_new_record_handle(repo) : record_handle;
+ record->record_handle = record_handle == 0 ?
+ get_new_record_handle(repo) :
+ record_handle;
record->size = size;
record->is_remote = is_remote;
record->terminus_handle = terminus_handle;
@@ -87,7 +88,7 @@
*/
if (!record_handle) {
struct pldm_pdr_hdr *hdr =
- (struct pldm_pdr_hdr *)(record->data);
+ (struct pldm_pdr_hdr *)(record->data);
hdr->record_handle = htole32(record->record_handle);
}
}
@@ -104,7 +105,7 @@
assert(data != NULL);
pldm_pdr_record *record = make_new_record(
- repo, data, size, record_handle, is_remote, terminus_handle);
+ repo, data, size, record_handle, is_remote, terminus_handle);
add_record(repo, record);
return record->record_handle;
@@ -158,7 +159,7 @@
*size = record->size;
*data = record->data;
*next_record_handle =
- get_next_record_handle(repo, record);
+ get_next_record_handle(repo, record);
return record;
}
record = record->next;
@@ -269,8 +270,8 @@
hdr->record_change_num = 0;
hdr->length = htole16(sizeof(struct pldm_pdr_fru_record_set));
struct pldm_pdr_fru_record_set *fru =
- (struct pldm_pdr_fru_record_set *)((uint8_t *)hdr +
- sizeof(struct pldm_pdr_hdr));
+ (struct pldm_pdr_fru_record_set *)((uint8_t *)hdr +
+ sizeof(struct pldm_pdr_hdr));
fru->terminus_handle = htole16(terminus_handle);
fru->fru_rsi = htole16(fru_rsi);
fru->entity_type = htole16(entity_type);
@@ -282,9 +283,9 @@
}
const pldm_pdr_record *pldm_pdr_fru_record_set_find_by_rsi(
- const pldm_pdr *repo, uint16_t fru_rsi, uint16_t *terminus_handle,
- uint16_t *entity_type, uint16_t *entity_instance_num,
- uint16_t *container_id)
+ const pldm_pdr *repo, uint16_t fru_rsi, uint16_t *terminus_handle,
+ uint16_t *entity_type, uint16_t *entity_instance_num,
+ uint16_t *container_id)
{
assert(terminus_handle != NULL);
assert(entity_type != NULL);
@@ -294,22 +295,23 @@
uint8_t *data = NULL;
uint32_t size = 0;
const pldm_pdr_record *curr_record = pldm_pdr_find_record_by_type(
- repo, PLDM_PDR_FRU_RECORD_SET, NULL, &data, &size);
+ repo, PLDM_PDR_FRU_RECORD_SET, NULL, &data, &size);
while (curr_record != NULL) {
struct pldm_pdr_fru_record_set *fru =
- (struct pldm_pdr_fru_record_set
- *)(data + sizeof(struct pldm_pdr_hdr));
+ (struct pldm_pdr_fru_record_set
+ *)(data + sizeof(struct pldm_pdr_hdr));
if (fru->fru_rsi == htole16(fru_rsi)) {
*terminus_handle = le16toh(fru->terminus_handle);
*entity_type = le16toh(fru->entity_type);
*entity_instance_num =
- le16toh(fru->entity_instance_num);
+ le16toh(fru->entity_instance_num);
*container_id = le16toh(fru->container_id);
return curr_record;
}
data = NULL;
curr_record = pldm_pdr_find_record_by_type(
- repo, PLDM_PDR_FRU_RECORD_SET, curr_record, &data, &size);
+ repo, PLDM_PDR_FRU_RECORD_SET, curr_record, &data,
+ &size);
}
*terminus_handle = 0;
@@ -333,18 +335,19 @@
do {
if (record != NULL) {
struct pldm_terminus_locator_pdr *pdr =
- (struct pldm_terminus_locator_pdr *)out_data;
+ (struct pldm_terminus_locator_pdr *)out_data;
struct pldm_terminus_locator_type_mctp_eid *value =
- (struct pldm_terminus_locator_type_mctp_eid *)
- pdr->terminus_locator_value;
+ (struct pldm_terminus_locator_type_mctp_eid *)
+ pdr->terminus_locator_value;
if (pdr->terminus_handle == terminus_handle &&
pdr->tid == tid && value->eid == tl_eid) {
pdr->validity = valid_bit;
break;
}
}
- record = pldm_pdr_find_record_by_type(
- repo, PLDM_TERMINUS_LOCATOR_PDR, record, &out_data, &size);
+ record = pldm_pdr_find_record_by_type(repo,
+ PLDM_TERMINUS_LOCATOR_PDR,
+ record, &out_data, &size);
} while (record);
}
@@ -379,7 +382,7 @@
pldm_entity_association_tree *pldm_entity_association_tree_init(void)
{
pldm_entity_association_tree *tree =
- malloc(sizeof(pldm_entity_association_tree));
+ malloc(sizeof(pldm_entity_association_tree));
assert(tree != NULL);
tree->root = NULL;
tree->last_used_container_id = 0;
@@ -409,9 +412,9 @@
}
pldm_entity_node *pldm_entity_association_tree_add(
- pldm_entity_association_tree *tree, pldm_entity *entity,
- uint16_t entity_instance_number, pldm_entity_node *parent,
- uint8_t association_type)
+ pldm_entity_association_tree *tree, pldm_entity *entity,
+ uint16_t entity_instance_number, pldm_entity_node *parent,
+ uint8_t association_type)
{
assert(tree != NULL);
assert(entity != NULL);
@@ -436,7 +439,7 @@
node->parent.entity_container_id = 0;
node->entity.entity_type = entity->entity_type;
node->entity.entity_instance_num =
- entity_instance_number != 0xFFFF ? entity_instance_number : 1;
+ entity_instance_number != 0xFFFF ? entity_instance_number : 1;
node->association_type = association_type;
if (tree->root == NULL) {
@@ -449,24 +452,24 @@
node->parent = parent->entity;
node->entity.entity_container_id = next_container_id(tree);
} else {
- pldm_entity_node *start =
- parent == NULL ? tree->root : parent->first_child;
+ pldm_entity_node *start = parent == NULL ? tree->root :
+ parent->first_child;
pldm_entity_node *prev =
- find_insertion_at(start, entity->entity_type);
+ find_insertion_at(start, entity->entity_type);
assert(prev != NULL);
pldm_entity_node *next = prev->next_sibling;
if (prev->entity.entity_type == entity->entity_type) {
assert(prev->entity.entity_instance_num != UINT16_MAX);
node->entity.entity_instance_num =
- entity_instance_number != 0xFFFF
- ? entity_instance_number
- : prev->entity.entity_instance_num + 1;
+ entity_instance_number != 0xFFFF ?
+ entity_instance_number :
+ prev->entity.entity_instance_num + 1;
}
prev->next_sibling = node;
node->parent = prev->parent;
node->next_sibling = next;
node->entity.entity_container_id =
- prev->entity.entity_container_id;
+ prev->entity.entity_container_id;
}
entity->entity_instance_num = node->entity.entity_instance_num;
entity->entity_container_id = node->entity.entity_container_id;
@@ -593,8 +596,7 @@
while (curr != NULL) {
if (node->entity_type == curr->entity.entity_type &&
node->entity_instance_num ==
- curr->entity.entity_instance_num) {
-
+ curr->entity.entity_instance_num) {
return true;
}
curr = curr->next_sibling;
@@ -642,9 +644,9 @@
pldm_entity *entity = (pldm_entity *)start;
entity->entity_type = htole16(node->entity.entity_type);
entity->entity_instance_num =
- htole16(node->entity.entity_instance_num);
+ htole16(node->entity.entity_instance_num);
entity->entity_container_id =
- htole16(node->entity.entity_container_id);
+ htole16(node->entity.entity_container_id);
start += sizeof(pldm_entity);
}
node = node->next_sibling;
@@ -657,30 +659,33 @@
pldm_pdr *repo, bool is_remote,
uint16_t terminus_handle)
{
- uint8_t num_logical_children =
- pldm_entity_get_num_children(curr, PLDM_ENTITY_ASSOCIAION_LOGICAL);
- uint8_t num_physical_children =
- pldm_entity_get_num_children(curr, PLDM_ENTITY_ASSOCIAION_PHYSICAL);
+ uint8_t num_logical_children = pldm_entity_get_num_children(
+ curr, PLDM_ENTITY_ASSOCIAION_LOGICAL);
+ uint8_t num_physical_children = pldm_entity_get_num_children(
+ curr, PLDM_ENTITY_ASSOCIAION_PHYSICAL);
if (num_logical_children) {
uint16_t logical_pdr_size =
- sizeof(struct pldm_pdr_hdr) + sizeof(uint16_t) +
- sizeof(uint8_t) + sizeof(pldm_entity) + sizeof(uint8_t) +
- (num_logical_children * sizeof(pldm_entity));
+ sizeof(struct pldm_pdr_hdr) + sizeof(uint16_t) +
+ sizeof(uint8_t) + sizeof(pldm_entity) +
+ sizeof(uint8_t) +
+ (num_logical_children * sizeof(pldm_entity));
entity_association_pdr_add_children(
- curr, repo, logical_pdr_size, num_logical_children,
- PLDM_ENTITY_ASSOCIAION_LOGICAL, is_remote, terminus_handle);
+ curr, repo, logical_pdr_size, num_logical_children,
+ PLDM_ENTITY_ASSOCIAION_LOGICAL, is_remote,
+ terminus_handle);
}
if (num_physical_children) {
uint16_t physical_pdr_size =
- sizeof(struct pldm_pdr_hdr) + sizeof(uint16_t) +
- sizeof(uint8_t) + sizeof(pldm_entity) + sizeof(uint8_t) +
- (num_physical_children * sizeof(pldm_entity));
+ sizeof(struct pldm_pdr_hdr) + sizeof(uint16_t) +
+ sizeof(uint8_t) + sizeof(pldm_entity) +
+ sizeof(uint8_t) +
+ (num_physical_children * sizeof(pldm_entity));
entity_association_pdr_add_children(
- curr, repo, physical_pdr_size, num_physical_children,
- PLDM_ENTITY_ASSOCIAION_PHYSICAL, is_remote,
- terminus_handle);
+ curr, repo, physical_pdr_size, num_physical_children,
+ PLDM_ENTITY_ASSOCIAION_PHYSICAL, is_remote,
+ terminus_handle);
}
}
@@ -731,8 +736,8 @@
}
void pldm_entity_association_pdr_add_from_node(
- pldm_entity_node *node, pldm_pdr *repo, pldm_entity **entities,
- size_t num_entities, bool is_remote, uint16_t terminus_handle)
+ pldm_entity_node *node, pldm_pdr *repo, pldm_entity **entities,
+ size_t num_entities, bool is_remote, uint16_t terminus_handle)
{
assert(repo != NULL);
@@ -749,7 +754,7 @@
if (tree_node->entity.entity_type == entity.entity_type &&
tree_node->entity.entity_instance_num ==
- entity.entity_instance_num) {
+ entity.entity_instance_num) {
*node = tree_node;
return;
}
@@ -804,9 +809,9 @@
record->record_handle = ++record_handle;
if (record->data != NULL) {
struct pldm_pdr_hdr *hdr =
- (struct pldm_pdr_hdr *)(record->data);
+ (struct pldm_pdr_hdr *)(record->data);
hdr->record_handle =
- htole32(record->record_handle);
+ htole32(record->record_handle);
}
record = record->next;
}
@@ -850,9 +855,9 @@
record->record_handle = ++record_handle;
if (record->data != NULL) {
struct pldm_pdr_hdr *hdr =
- (struct pldm_pdr_hdr *)(record->data);
+ (struct pldm_pdr_hdr *)(record->data);
hdr->record_handle =
- htole32(record->record_handle);
+ htole32(record->record_handle);
}
record = record->next;
}
@@ -907,15 +912,15 @@
}
void pldm_entity_association_tree_copy_root(
- pldm_entity_association_tree *org_tree,
- pldm_entity_association_tree *new_tree)
+ pldm_entity_association_tree *org_tree,
+ pldm_entity_association_tree *new_tree)
{
new_tree->last_used_container_id = org_tree->last_used_container_id;
entity_association_tree_copy(org_tree->root, &(new_tree->root));
}
void pldm_entity_association_tree_destroy_root(
- pldm_entity_association_tree *tree)
+ pldm_entity_association_tree *tree)
{
assert(tree != NULL);
entity_association_tree_destroy(tree->root);
@@ -934,39 +939,39 @@
{
assert(pdr != NULL);
assert(pdr_len >= sizeof(struct pldm_pdr_hdr) +
- sizeof(struct pldm_pdr_entity_association));
+ sizeof(struct pldm_pdr_entity_association));
struct pldm_pdr_hdr *hdr = (struct pldm_pdr_hdr *)pdr;
assert(hdr->type == PLDM_PDR_ENTITY_ASSOCIATION);
const uint8_t *start = (uint8_t *)pdr;
const uint8_t *end =
- start + sizeof(struct pldm_pdr_hdr) + le16toh(hdr->length);
+ start + sizeof(struct pldm_pdr_hdr) + le16toh(hdr->length);
start += sizeof(struct pldm_pdr_hdr);
struct pldm_pdr_entity_association *entity_association_pdr =
- (struct pldm_pdr_entity_association *)start;
+ (struct pldm_pdr_entity_association *)start;
*num_entities = entity_association_pdr->num_children + 1;
assert(*num_entities >= 2);
*entities = malloc(sizeof(pldm_entity) * *num_entities);
assert(*entities != NULL);
assert(start + sizeof(struct pldm_pdr_entity_association) +
- sizeof(pldm_entity) * (*num_entities - 2) ==
+ sizeof(pldm_entity) * (*num_entities - 2) ==
end);
(*entities)->entity_type =
- le16toh(entity_association_pdr->container.entity_type);
+ le16toh(entity_association_pdr->container.entity_type);
(*entities)->entity_instance_num =
- le16toh(entity_association_pdr->container.entity_instance_num);
+ le16toh(entity_association_pdr->container.entity_instance_num);
(*entities)->entity_container_id =
- le16toh(entity_association_pdr->container.entity_container_id);
+ le16toh(entity_association_pdr->container.entity_container_id);
pldm_entity *curr_entity = entity_association_pdr->children;
size_t i = 1;
while (i < *num_entities) {
(*entities + i)->entity_type =
- le16toh(curr_entity->entity_type);
+ le16toh(curr_entity->entity_type);
(*entities + i)->entity_instance_num =
- le16toh(curr_entity->entity_instance_num);
+ le16toh(curr_entity->entity_instance_num);
(*entities + i)->entity_container_id =
- le16toh(curr_entity->entity_container_id);
+ le16toh(curr_entity->entity_container_id);
++curr_entity;
++i;
}
diff --git a/src/platform.c b/src/platform.c
index 7292847..5da538c 100644
--- a/src/platform.c
+++ b/src/platform.c
@@ -23,10 +23,10 @@
}
int encode_state_effecter_pdr(
- struct pldm_state_effecter_pdr *const effecter,
- const size_t allocation_size,
- const struct state_effecter_possible_states *const possible_states,
- const size_t possible_states_size, size_t *const actual_size)
+ struct pldm_state_effecter_pdr *const effecter,
+ const size_t allocation_size,
+ const struct state_effecter_possible_states *const possible_states,
+ const size_t possible_states_size, size_t *const actual_size)
{
// Encode possible states
@@ -38,13 +38,14 @@
for (int i = 0; i < effecter->composite_effecter_count; ++i) {
struct state_effecter_possible_states *states =
- (struct state_effecter_possible_states *)states_ptr;
+ (struct state_effecter_possible_states *)
+ states_ptr;
HTOLE16(states->state_set_id);
states_ptr +=
- (sizeof(*states) - sizeof(states->states) +
- states->possible_states_size);
+ (sizeof(*states) - sizeof(states->states) +
+ states->possible_states_size);
}
calculated_possible_states_size = states_ptr - begin_states_ptr;
@@ -58,8 +59,8 @@
}
*actual_size =
- (sizeof(struct pldm_state_effecter_pdr) + possible_states_size -
- sizeof(effecter->possible_states));
+ (sizeof(struct pldm_state_effecter_pdr) + possible_states_size -
+ sizeof(effecter->possible_states));
if (allocation_size < *actual_size) {
*actual_size = 0;
@@ -92,9 +93,10 @@
}
int encode_state_sensor_pdr(
- struct pldm_state_sensor_pdr *const sensor, const size_t allocation_size,
- const struct state_sensor_possible_states *const possible_states,
- const size_t possible_states_size, size_t *const actual_size)
+ struct pldm_state_sensor_pdr *const sensor,
+ const size_t allocation_size,
+ const struct state_sensor_possible_states *const possible_states,
+ const size_t possible_states_size, size_t *const actual_size)
{
// Encode possible states
@@ -106,13 +108,14 @@
for (int i = 0; i < sensor->composite_sensor_count; ++i) {
struct state_sensor_possible_states *states =
- (struct state_sensor_possible_states *)states_ptr;
+ (struct state_sensor_possible_states *)
+ states_ptr;
HTOLE16(states->state_set_id);
states_ptr +=
- (sizeof(*states) - sizeof(states->states) +
- states->possible_states_size);
+ (sizeof(*states) - sizeof(states->states) +
+ states->possible_states_size);
}
calculated_possible_states_size = states_ptr - begin_states_ptr;
@@ -164,7 +167,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_PLATFORM;
@@ -195,7 +198,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_PLATFORM;
@@ -207,7 +210,7 @@
}
struct pldm_set_state_effecter_states_req *request =
- (struct pldm_set_state_effecter_states_req *)msg->payload;
+ (struct pldm_set_state_effecter_states_req *)msg->payload;
effecter_id = htole16(effecter_id);
request->effecter_id = effecter_id;
request->comp_effecter_count = comp_effecter_count;
@@ -323,7 +326,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_PLATFORM;
@@ -335,13 +338,13 @@
}
struct pldm_get_pdr_resp *response =
- (struct pldm_get_pdr_resp *)msg->payload;
+ (struct pldm_get_pdr_resp *)msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
response->next_record_handle = htole32(next_record_hndl);
response->next_data_transfer_handle =
- htole32(next_data_transfer_hndl);
+ htole32(next_data_transfer_hndl);
response->transfer_flag = transfer_flag;
response->response_count = htole16(resp_cnt);
if (record_data != NULL && resp_cnt > 0) {
@@ -349,8 +352,8 @@
}
if (transfer_flag == PLDM_END) {
uint8_t *dst = msg->payload;
- dst +=
- (sizeof(struct pldm_get_pdr_resp) - 1) + resp_cnt;
+ dst += (sizeof(struct pldm_get_pdr_resp) - 1) +
+ resp_cnt;
*dst = transfer_crc;
}
}
@@ -359,17 +362,17 @@
}
int encode_get_pdr_repository_info_resp(
- uint8_t instance_id, uint8_t completion_code, uint8_t repository_state,
- const uint8_t *update_time, const uint8_t *oem_update_time,
- uint32_t record_count, uint32_t repository_size,
- uint32_t largest_record_size, uint8_t data_transfer_handle_timeout,
- struct pldm_msg *msg)
+ uint8_t instance_id, uint8_t completion_code, uint8_t repository_state,
+ const uint8_t *update_time, const uint8_t *oem_update_time,
+ uint32_t record_count, uint32_t repository_size,
+ uint32_t largest_record_size, uint8_t data_transfer_handle_timeout,
+ 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_PLATFORM;
@@ -381,7 +384,7 @@
}
struct pldm_pdr_repository_info_resp *response =
- (struct pldm_pdr_repository_info_resp *)msg->payload;
+ (struct pldm_pdr_repository_info_resp *)msg->payload;
response->completion_code = completion_code;
if (response->completion_code == PLDM_SUCCESS) {
@@ -398,17 +401,18 @@
response->repository_size = htole32(repository_size);
response->largest_record_size = htole32(largest_record_size);
response->data_transfer_handle_timeout =
- data_transfer_handle_timeout;
+ data_transfer_handle_timeout;
}
return PLDM_SUCCESS;
}
int decode_get_pdr_repository_info_resp(
- const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
- uint8_t *repository_state, uint8_t *update_time, uint8_t *oem_update_time,
- uint32_t *record_count, uint32_t *repository_size,
- uint32_t *largest_record_size, uint8_t *data_transfer_handle_timeout)
+ const struct pldm_msg *msg, size_t payload_length,
+ uint8_t *completion_code, uint8_t *repository_state,
+ uint8_t *update_time, uint8_t *oem_update_time, uint32_t *record_count,
+ uint32_t *repository_size, uint32_t *largest_record_size,
+ uint8_t *data_transfer_handle_timeout)
{
struct pldm_msgbuf _buf;
struct pldm_msgbuf *buf = &_buf;
@@ -461,7 +465,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_PLATFORM;
@@ -473,7 +477,7 @@
}
struct pldm_get_pdr_req *request =
- (struct pldm_get_pdr_req *)msg->payload;
+ (struct pldm_get_pdr_req *)msg->payload;
request->record_handle = htole32(record_hndl);
request->data_transfer_handle = htole32(data_transfer_hndl);
request->transfer_op_flag = transfer_op_flag;
@@ -548,9 +552,9 @@
return PLDM_ERROR_INVALID_DATA;
}
- rc =
- pldm_msgbuf_init(buf, PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES,
- msg->payload, payload_length);
+ rc = pldm_msgbuf_init(buf,
+ PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES,
+ msg->payload, payload_length);
if (rc) {
return rc;
}
@@ -584,7 +588,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_PLATFORM;
@@ -600,9 +604,12 @@
return rc;
}
-int encode_set_numeric_effecter_value_req(
- uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
- const uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length)
+int encode_set_numeric_effecter_value_req(uint8_t instance_id,
+ uint16_t effecter_id,
+ uint8_t effecter_data_size,
+ const uint8_t *effecter_value,
+ struct pldm_msg *msg,
+ size_t payload_length)
{
if (msg == NULL || effecter_value == NULL) {
return PLDM_ERROR_INVALID_DATA;
@@ -612,7 +619,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_PLATFORM;
@@ -624,7 +631,7 @@
}
struct pldm_set_numeric_effecter_value_req *request =
- (struct pldm_set_numeric_effecter_value_req *)msg->payload;
+ (struct pldm_set_numeric_effecter_value_req *)msg->payload;
if (effecter_data_size == PLDM_EFFECTER_DATA_SIZE_UINT8 ||
effecter_data_size == PLDM_EFFECTER_DATA_SIZE_SINT8) {
if (payload_length !=
@@ -692,7 +699,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_PLATFORM;
@@ -704,7 +711,7 @@
}
struct pldm_get_state_sensor_readings_resp *response =
- (struct pldm_get_state_sensor_readings_resp *)msg->payload;
+ (struct pldm_get_state_sensor_readings_resp *)msg->payload;
response->completion_code = completion_code;
response->comp_sensor_count = comp_sensor_count;
@@ -723,7 +730,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_PLATFORM;
@@ -735,7 +742,7 @@
}
struct pldm_get_state_sensor_readings_req *request =
- (struct pldm_get_state_sensor_readings_req *)msg->payload;
+ (struct pldm_get_state_sensor_readings_req *)msg->payload;
request->sensor_id = htole16(sensor_id);
request->reserved = reserved;
@@ -760,9 +767,9 @@
return PLDM_ERROR_INVALID_DATA;
}
- rc =
- pldm_msgbuf_init(buf, PLDM_GET_STATE_SENSOR_READINGS_MIN_RESP_BYTES,
- msg->payload, payload_length);
+ rc = pldm_msgbuf_init(buf,
+ PLDM_GET_STATE_SENSOR_READINGS_MIN_RESP_BYTES,
+ msg->payload, payload_length);
if (rc) {
return rc;
}
@@ -823,15 +830,16 @@
}
int encode_sensor_event_data(
- struct pldm_sensor_event_data *const event_data,
- const size_t event_data_size, const uint16_t sensor_id,
- const enum sensor_event_class_states sensor_event_class,
- const uint8_t sensor_offset, const uint8_t event_state,
- const uint8_t previous_event_state, size_t *const actual_event_data_size)
+ struct pldm_sensor_event_data *const event_data,
+ const size_t event_data_size, const uint16_t sensor_id,
+ const enum sensor_event_class_states sensor_event_class,
+ const uint8_t sensor_offset, const uint8_t event_state,
+ const uint8_t previous_event_state,
+ size_t *const actual_event_data_size)
{
*actual_event_data_size =
- (sizeof(*event_data) - sizeof(event_data->event_class) +
- sizeof(struct pldm_sensor_event_state_sensor_state));
+ (sizeof(*event_data) - sizeof(event_data->event_class) +
+ sizeof(struct pldm_sensor_event_state_sensor_state));
if (!event_data) {
return PLDM_SUCCESS;
@@ -846,8 +854,8 @@
event_data->sensor_event_class_type = sensor_event_class;
struct pldm_sensor_event_state_sensor_state *const state_data =
- (struct pldm_sensor_event_state_sensor_state *)
- event_data->event_class;
+ (struct pldm_sensor_event_state_sensor_state *)
+ event_data->event_class;
state_data->sensor_offset = sensor_offset;
state_data->event_state = event_state;
@@ -881,15 +889,15 @@
pldm_msgbuf_extract(buf, tid);
pldm_msgbuf_extract(buf, event_class);
*event_data_offset =
- sizeof(*format_version) + sizeof(*tid) + sizeof(*event_class);
+ sizeof(*format_version) + sizeof(*tid) + sizeof(*event_class);
return pldm_msgbuf_destroy(buf);
}
int decode_poll_for_platform_event_message_req(
- const struct pldm_msg *msg, size_t payload_length, uint8_t *format_version,
- uint8_t *transfer_operation_flag, uint32_t *data_transfer_handle,
- uint16_t *event_id_to_acknowledge)
+ const struct pldm_msg *msg, size_t payload_length,
+ uint8_t *format_version, uint8_t *transfer_operation_flag,
+ uint32_t *data_transfer_handle, uint16_t *event_id_to_acknowledge)
{
struct pldm_msgbuf _buf;
struct pldm_msgbuf *buf = &_buf;
@@ -945,7 +953,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_PLATFORM;
@@ -957,7 +965,7 @@
}
struct pldm_platform_event_message_resp *response =
- (struct pldm_platform_event_message_resp *)msg->payload;
+ (struct pldm_platform_event_message_resp *)msg->payload;
response->completion_code = completion_code;
response->platform_event_status = platform_event_status;
@@ -965,11 +973,11 @@
}
int encode_poll_for_platform_event_message_resp(
- uint8_t instance_id, uint8_t completion_code, uint8_t tid,
- uint16_t event_id, uint32_t next_data_transfer_handle,
- uint8_t transfer_flag, uint8_t event_class, uint32_t event_data_size,
- uint8_t *event_data, uint32_t checksum, struct pldm_msg *msg,
- size_t payload_length)
+ uint8_t instance_id, uint8_t completion_code, uint8_t tid,
+ uint16_t event_id, uint32_t next_data_transfer_handle,
+ uint8_t transfer_flag, uint8_t event_class, uint32_t event_data_size,
+ uint8_t *event_data, uint32_t checksum, struct pldm_msg *msg,
+ size_t payload_length)
{
struct pldm_msgbuf _buf;
struct pldm_msgbuf *buf = &_buf;
@@ -979,7 +987,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_PLATFORM;
@@ -991,8 +999,8 @@
}
rc = pldm_msgbuf_init(
- buf, PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_MIN_RESP_BYTES,
- msg->payload, payload_length);
+ buf, PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_MIN_RESP_BYTES,
+ msg->payload, payload_length);
if (rc) {
return rc;
}
@@ -1030,9 +1038,9 @@
}
int encode_platform_event_message_req(
- uint8_t instance_id, uint8_t format_version, uint8_t tid,
- uint8_t event_class, const uint8_t *event_data, size_t event_data_length,
- struct pldm_msg *msg, size_t payload_length)
+ uint8_t instance_id, uint8_t format_version, uint8_t tid,
+ uint8_t event_class, const uint8_t *event_data,
+ size_t event_data_length, struct pldm_msg *msg, size_t payload_length)
{
if (format_version != 1) {
@@ -1057,7 +1065,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_PLATFORM;
@@ -1069,7 +1077,7 @@
}
struct pldm_platform_event_message_req *request =
- (struct pldm_platform_event_message_req *)msg->payload;
+ (struct pldm_platform_event_message_req *)msg->payload;
request->format_version = format_version;
request->tid = tid;
request->event_class = event_class;
@@ -1119,11 +1127,11 @@
return pldm_msgbuf_destroy(buf);
}
-int encode_event_message_buffer_size_req(
- uint8_t instance_id, uint16_t event_receiver_max_buffer_size,
- struct pldm_msg *msg)
+int encode_event_message_buffer_size_req(uint8_t instance_id,
+ uint16_t event_receiver_max_buffer_size,
+ struct pldm_msg *msg)
{
- 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_PLATFORM;
@@ -1135,9 +1143,9 @@
}
struct pldm_event_message_buffer_size_req *request =
- (struct pldm_event_message_buffer_size_req *)msg->payload;
+ (struct pldm_event_message_buffer_size_req *)msg->payload;
request->event_receiver_max_buffer_size =
- event_receiver_max_buffer_size;
+ event_receiver_max_buffer_size;
return PLDM_SUCCESS;
}
@@ -1188,7 +1196,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_PLATFORM;
@@ -1200,17 +1208,20 @@
}
struct pldm_event_message_supported_req *request =
- (struct pldm_event_message_supported_req *)msg->payload;
+ (struct pldm_event_message_supported_req *)msg->payload;
request->format_version = format_version;
return PLDM_SUCCESS;
}
-int decode_event_message_supported_resp(
- const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
- uint8_t *synchrony_config, bitfield8_t *synchrony_config_support,
- uint8_t *number_event_class_returned, uint8_t *event_class,
- uint8_t event_class_count)
+int decode_event_message_supported_resp(const struct pldm_msg *msg,
+ size_t payload_length,
+ uint8_t *completion_code,
+ uint8_t *synchrony_config,
+ bitfield8_t *synchrony_config_support,
+ uint8_t *number_event_class_returned,
+ uint8_t *event_class,
+ uint8_t event_class_count)
{
struct pldm_msgbuf _buf;
struct pldm_msgbuf *buf = &_buf;
@@ -1285,7 +1296,7 @@
}
size_t event_class_data_length =
- event_data_length - PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES;
+ event_data_length - PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES;
pldm_msgbuf_extract(buf, sensor_id);
rc = pldm_msgbuf_extract(buf, sensor_event_class_type);
@@ -1305,9 +1316,9 @@
}
} else if (*sensor_event_class_type == PLDM_NUMERIC_SENSOR_STATE) {
if (event_class_data_length <
- PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH ||
+ PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH ||
event_class_data_length >
- PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MAX_DATA_LENGTH) {
+ PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MAX_DATA_LENGTH) {
return PLDM_ERROR_INVALID_LENGTH;
}
} else {
@@ -1315,7 +1326,7 @@
}
*event_class_data_offset =
- sizeof(*sensor_id) + sizeof(*sensor_event_class_type);
+ sizeof(*sensor_id) + sizeof(*sensor_event_class_type);
return pldm_msgbuf_destroy(buf);
}
@@ -1331,9 +1342,9 @@
return PLDM_ERROR_INVALID_DATA;
}
- rc =
- pldm_msgbuf_init(buf, PLDM_SENSOR_EVENT_SENSOR_OP_STATE_DATA_LENGTH,
- sensor_data, sensor_data_length);
+ rc = pldm_msgbuf_init(buf,
+ PLDM_SENSOR_EVENT_SENSOR_OP_STATE_DATA_LENGTH,
+ sensor_data, sensor_data_length);
if (rc) {
return rc;
}
@@ -1393,8 +1404,8 @@
}
rc = pldm_msgbuf_init(
- buf, PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH,
- sensor_data, sensor_data_length);
+ buf, PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH,
+ sensor_data, sensor_data_length);
if (rc) {
return rc;
}
@@ -1463,8 +1474,8 @@
#define PLDM_NUMERIC_SENSOR_VALUE_PDR_MIN_SIZE 69
int decode_numeric_sensor_pdr_data(
- const void *pdr_data, size_t pdr_data_length,
- struct pldm_numeric_sensor_value_pdr *pdr_value)
+ const void *pdr_data, size_t pdr_data_length,
+ struct pldm_numeric_sensor_value_pdr *pdr_value)
{
struct pldm_msgbuf _buf;
struct pldm_msgbuf *buf = &_buf;
@@ -1482,8 +1493,8 @@
}
rc = pldm_platform_pdr_hdr_validate(
- &pdr_value->hdr, PLDM_NUMERIC_SENSOR_VALUE_PDR_MIN_SIZE,
- pdr_data_length);
+ &pdr_value->hdr, PLDM_NUMERIC_SENSOR_VALUE_PDR_MIN_SIZE,
+ pdr_data_length);
if (rc) {
return rc;
}
@@ -1523,7 +1534,7 @@
&pdr_value->hysteresis);
pldm_msgbuf_extract(buf, &pdr_value->supported_thresholds.byte);
pldm_msgbuf_extract(
- buf, &pdr_value->threshold_and_hysteresis_volatility.byte);
+ buf, &pdr_value->threshold_and_hysteresis_volatility.byte);
pldm_msgbuf_extract(buf, &pdr_value->state_transition_interval);
pldm_msgbuf_extract(buf, &pdr_value->update_interval);
pldm_msgbuf_extract_sensor_data(buf, pdr_value->sensor_data_size,
@@ -1541,23 +1552,23 @@
pldm_msgbuf_extract(buf, &pdr_value->range_field_support.byte);
pldm_msgbuf_extract_range_field_format(
- buf, pdr_value->range_field_format, &pdr_value->nominal_value);
+ buf, pdr_value->range_field_format, &pdr_value->nominal_value);
pldm_msgbuf_extract_range_field_format(
- buf, pdr_value->range_field_format, &pdr_value->normal_max);
+ buf, pdr_value->range_field_format, &pdr_value->normal_max);
pldm_msgbuf_extract_range_field_format(
- buf, pdr_value->range_field_format, &pdr_value->normal_min);
+ buf, pdr_value->range_field_format, &pdr_value->normal_min);
pldm_msgbuf_extract_range_field_format(
- buf, pdr_value->range_field_format, &pdr_value->warning_high);
+ buf, pdr_value->range_field_format, &pdr_value->warning_high);
pldm_msgbuf_extract_range_field_format(
- buf, pdr_value->range_field_format, &pdr_value->warning_low);
+ buf, pdr_value->range_field_format, &pdr_value->warning_low);
pldm_msgbuf_extract_range_field_format(
- buf, pdr_value->range_field_format, &pdr_value->critical_high);
+ buf, pdr_value->range_field_format, &pdr_value->critical_high);
pldm_msgbuf_extract_range_field_format(
- buf, pdr_value->range_field_format, &pdr_value->critical_low);
+ buf, pdr_value->range_field_format, &pdr_value->critical_low);
pldm_msgbuf_extract_range_field_format(
- buf, pdr_value->range_field_format, &pdr_value->fatal_high);
+ buf, pdr_value->range_field_format, &pdr_value->fatal_high);
pldm_msgbuf_extract_range_field_format(
- buf, pdr_value->range_field_format, &pdr_value->fatal_low);
+ buf, pdr_value->range_field_format, &pdr_value->fatal_low);
return pldm_msgbuf_destroy(buf);
}
@@ -1570,7 +1581,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_PLATFORM;
@@ -1582,16 +1593,17 @@
}
struct pldm_get_numeric_effecter_value_req *request =
- (struct pldm_get_numeric_effecter_value_req *)msg->payload;
+ (struct pldm_get_numeric_effecter_value_req *)msg->payload;
request->effecter_id = htole16(effecter_id);
return PLDM_SUCCESS;
}
int encode_get_numeric_effecter_value_resp(
- uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
- uint8_t effecter_oper_state, const uint8_t *pending_value,
- const uint8_t *present_value, struct pldm_msg *msg, size_t payload_length)
+ uint8_t instance_id, uint8_t completion_code,
+ uint8_t effecter_data_size, uint8_t effecter_oper_state,
+ const uint8_t *pending_value, const uint8_t *present_value,
+ struct pldm_msg *msg, size_t payload_length)
{
if (msg == NULL || pending_value == NULL || present_value == NULL) {
return PLDM_ERROR_INVALID_DATA;
@@ -1605,7 +1617,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_PLATFORM;
@@ -1617,7 +1629,7 @@
}
struct pldm_get_numeric_effecter_value_resp *response =
- (struct pldm_get_numeric_effecter_value_resp *)msg->payload;
+ (struct pldm_get_numeric_effecter_value_resp *)msg->payload;
response->completion_code = completion_code;
response->effecter_data_size = effecter_data_size;
@@ -1644,9 +1656,9 @@
sizeof(uint16_t));
uint16_t val_present = *(uint16_t *)present_value;
val_present = htole16(val_present);
- memcpy(
- (response->pending_and_present_values + sizeof(uint16_t)),
- &val_present, sizeof(uint16_t));
+ memcpy((response->pending_and_present_values +
+ sizeof(uint16_t)),
+ &val_present, sizeof(uint16_t));
} else if (effecter_data_size == PLDM_EFFECTER_DATA_SIZE_UINT32 ||
effecter_data_size == PLDM_EFFECTER_DATA_SIZE_SINT32) {
@@ -1660,9 +1672,9 @@
sizeof(uint32_t));
uint32_t val_present = *(uint32_t *)present_value;
val_present = htole32(val_present);
- memcpy(
- (response->pending_and_present_values + sizeof(uint32_t)),
- &val_present, sizeof(uint32_t));
+ memcpy((response->pending_and_present_values +
+ sizeof(uint32_t)),
+ &val_present, sizeof(uint32_t));
}
return PLDM_SUCCESS;
}
@@ -1690,10 +1702,13 @@
return pldm_msgbuf_destroy_consumed(buf);
}
-int decode_get_numeric_effecter_value_resp(
- const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
- uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
- uint8_t *pending_value, uint8_t *present_value)
+int decode_get_numeric_effecter_value_resp(const struct pldm_msg *msg,
+ size_t payload_length,
+ uint8_t *completion_code,
+ uint8_t *effecter_data_size,
+ uint8_t *effecter_oper_state,
+ uint8_t *pending_value,
+ uint8_t *present_value)
{
struct pldm_msgbuf _buf;
struct pldm_msgbuf *buf = &_buf;
@@ -1748,12 +1763,12 @@
}
int encode_pldm_pdr_repository_chg_event_data(
- uint8_t event_data_format, uint8_t number_of_change_records,
- const uint8_t *event_data_operations,
- const uint8_t *numbers_of_change_entries,
- const uint32_t *const *change_entries,
- struct pldm_pdr_repository_chg_event_data *event_data,
- size_t *actual_change_records_size, size_t max_change_records_size)
+ uint8_t event_data_format, uint8_t number_of_change_records,
+ const uint8_t *event_data_operations,
+ const uint8_t *numbers_of_change_entries,
+ const uint32_t *const *change_entries,
+ struct pldm_pdr_repository_chg_event_data *event_data,
+ size_t *actual_change_records_size, size_t max_change_records_size)
{
if (event_data_operations == NULL ||
numbers_of_change_entries == NULL || change_entries == NULL) {
@@ -1761,16 +1776,16 @@
}
size_t expected_size =
- sizeof(event_data_format) + sizeof(number_of_change_records);
+ sizeof(event_data_format) + sizeof(number_of_change_records);
expected_size +=
- sizeof(*event_data_operations) * number_of_change_records;
+ sizeof(*event_data_operations) * number_of_change_records;
expected_size +=
- sizeof(*numbers_of_change_entries) * number_of_change_records;
+ sizeof(*numbers_of_change_entries) * number_of_change_records;
for (uint8_t i = 0; i < number_of_change_records; ++i) {
- expected_size +=
- sizeof(*change_entries[0]) * numbers_of_change_entries[i];
+ expected_size += sizeof(*change_entries[0]) *
+ numbers_of_change_entries[i];
}
*actual_change_records_size = expected_size;
@@ -1787,23 +1802,24 @@
event_data->number_of_change_records = number_of_change_records;
struct pldm_pdr_repository_change_record_data *record_data =
- (struct pldm_pdr_repository_change_record_data *)
- event_data->change_records;
+ (struct pldm_pdr_repository_change_record_data *)
+ event_data->change_records;
for (uint8_t i = 0; i < number_of_change_records; ++i) {
record_data->event_data_operation = event_data_operations[i];
record_data->number_of_change_entries =
- numbers_of_change_entries[i];
+ numbers_of_change_entries[i];
for (uint8_t j = 0; j < record_data->number_of_change_entries;
++j) {
record_data->change_entry[j] =
- htole32(change_entries[i][j]);
+ htole32(change_entries[i][j]);
}
- record_data = (struct pldm_pdr_repository_change_record_data
- *)(record_data->change_entry +
- record_data->number_of_change_entries);
+ record_data =
+ (struct pldm_pdr_repository_change_record_data
+ *)(record_data->change_entry +
+ record_data->number_of_change_entries);
}
return PLDM_SUCCESS;
@@ -1834,15 +1850,15 @@
pldm_msgbuf_extract(buf, number_of_change_records);
*change_record_data_offset =
- sizeof(*event_data_format) + sizeof(*number_of_change_records);
+ sizeof(*event_data_format) + sizeof(*number_of_change_records);
return pldm_msgbuf_destroy(buf);
}
int decode_pldm_pdr_repository_change_record_data(
- const uint8_t *change_record_data, size_t change_record_data_size,
- uint8_t *event_data_operation, uint8_t *number_of_change_entries,
- size_t *change_entry_data_offset)
+ const uint8_t *change_record_data, size_t change_record_data_size,
+ uint8_t *event_data_operation, uint8_t *number_of_change_entries,
+ size_t *change_entry_data_offset)
{
struct pldm_msgbuf _buf;
struct pldm_msgbuf *buf = &_buf;
@@ -1862,8 +1878,8 @@
pldm_msgbuf_extract(buf, event_data_operation);
pldm_msgbuf_extract(buf, number_of_change_entries);
- *change_entry_data_offset =
- sizeof(*event_data_operation) + sizeof(*number_of_change_entries);
+ *change_entry_data_offset = sizeof(*event_data_operation) +
+ sizeof(*number_of_change_entries);
return pldm_msgbuf_destroy(buf);
}
@@ -1876,7 +1892,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_PLATFORM;
@@ -1888,7 +1904,7 @@
}
struct pldm_get_sensor_reading_req *request =
- (struct pldm_get_sensor_reading_req *)msg->payload;
+ (struct pldm_get_sensor_reading_req *)msg->payload;
request->sensor_id = htole16(sensor_id);
request->rearm_event_state = rearm_event_state;
@@ -1897,10 +1913,11 @@
}
int decode_get_sensor_reading_resp(
- const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
- uint8_t *sensor_data_size, uint8_t *sensor_operational_state,
- uint8_t *sensor_event_message_enable, uint8_t *present_state,
- uint8_t *previous_state, uint8_t *event_state, uint8_t *present_reading)
+ const struct pldm_msg *msg, size_t payload_length,
+ uint8_t *completion_code, uint8_t *sensor_data_size,
+ uint8_t *sensor_operational_state, uint8_t *sensor_event_message_enable,
+ uint8_t *present_state, uint8_t *previous_state, uint8_t *event_state,
+ uint8_t *present_reading)
{
struct pldm_msgbuf _buf;
struct pldm_msgbuf *buf = &_buf;
@@ -1950,11 +1967,14 @@
return pldm_msgbuf_destroy_consumed(buf);
}
-int encode_get_sensor_reading_resp(
- uint8_t instance_id, uint8_t completion_code, uint8_t sensor_data_size,
- uint8_t sensor_operational_state, uint8_t sensor_event_message_enable,
- uint8_t present_state, uint8_t previous_state, uint8_t event_state,
- const uint8_t *present_reading, struct pldm_msg *msg, size_t payload_length)
+int encode_get_sensor_reading_resp(uint8_t instance_id, uint8_t completion_code,
+ uint8_t sensor_data_size,
+ uint8_t sensor_operational_state,
+ uint8_t sensor_event_message_enable,
+ uint8_t present_state,
+ uint8_t previous_state, uint8_t event_state,
+ const uint8_t *present_reading,
+ struct pldm_msg *msg, size_t payload_length)
{
if (msg == NULL || present_reading == NULL) {
return PLDM_ERROR_INVALID_DATA;
@@ -1964,7 +1984,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_PLATFORM;
@@ -1976,7 +1996,7 @@
}
struct pldm_get_sensor_reading_resp *response =
- (struct pldm_get_sensor_reading_resp *)msg->payload;
+ (struct pldm_get_sensor_reading_resp *)msg->payload;
response->completion_code = completion_code;
response->sensor_data_size = sensor_data_size;
@@ -2056,7 +2076,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_PLATFORM;
@@ -2068,7 +2088,7 @@
}
struct pldm_set_event_receiver_req *request =
- (struct pldm_set_event_receiver_req *)msg->payload;
+ (struct pldm_set_event_receiver_req *)msg->payload;
request->event_message_global_enable = event_message_global_enable;
request->transport_protocol_type = transport_protocol_type;
@@ -2159,7 +2179,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_PLATFORM;
@@ -2191,7 +2211,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_PLATFORM;
@@ -2203,8 +2223,8 @@
}
rc = pldm_msgbuf_init(
- buf, PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_MIN_RESP_BYTES,
- msg->payload, payload_length);
+ buf, PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_MIN_RESP_BYTES,
+ msg->payload, payload_length);
if (rc) {
return rc;
}
@@ -2218,10 +2238,11 @@
}
int decode_poll_for_platform_event_message_resp(
- const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
- uint8_t *tid, uint16_t *event_id, uint32_t *next_data_transfer_handle,
- uint8_t *transfer_flag, uint8_t *event_class, uint32_t *event_data_size,
- void **event_data, uint32_t *event_data_integrity_checksum)
+ const struct pldm_msg *msg, size_t payload_length,
+ uint8_t *completion_code, uint8_t *tid, uint16_t *event_id,
+ uint32_t *next_data_transfer_handle, uint8_t *transfer_flag,
+ uint8_t *event_class, uint32_t *event_data_size, void **event_data,
+ uint32_t *event_data_integrity_checksum)
{
struct pldm_msgbuf _buf;
struct pldm_msgbuf *buf = &_buf;
@@ -2236,8 +2257,8 @@
}
rc = pldm_msgbuf_init(
- buf, PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_MIN_RESP_BYTES,
- msg->payload, payload_length);
+ buf, PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_MIN_RESP_BYTES,
+ msg->payload, payload_length);
if (rc) {
return rc;
}
diff --git a/src/requester/instance-id.c b/src/requester/instance-id.c
index 7fe7c86..82e3ed1 100644
--- a/src/requester/instance-id.c
+++ b/src/requester/instance-id.c
@@ -10,7 +10,7 @@
#define BIT(i) (1UL << (i))
-#define PLDM_TID_MAX 256
+#define PLDM_TID_MAX 256
#define PLDM_INST_ID_MAX 32
/* We need to track our allocations explicitly due to OFD lock merging/splitting
@@ -98,14 +98,14 @@
pldm_instance_id_t *iid)
{
static const struct flock cfls = {
- .l_type = F_RDLCK,
- .l_whence = SEEK_SET,
- .l_len = 1,
+ .l_type = F_RDLCK,
+ .l_whence = SEEK_SET,
+ .l_len = 1,
};
static const struct flock cflx = {
- .l_type = F_WRLCK,
- .l_whence = SEEK_SET,
- .l_len = 1,
+ .l_type = F_WRLCK,
+ .l_whence = SEEK_SET,
+ .l_len = 1,
};
uint8_t l_iid;
@@ -186,9 +186,9 @@
pldm_instance_id_t iid)
{
static const struct flock cflu = {
- .l_type = F_UNLCK,
- .l_whence = SEEK_SET,
- .l_len = 1,
+ .l_type = F_UNLCK,
+ .l_whence = SEEK_SET,
+ .l_len = 1,
};
struct flock flop;
int rc;
diff --git a/src/requester/pldm.c b/src/requester/pldm.c
index c78512f..973f194 100644
--- a/src/requester/pldm.c
+++ b/src/requester/pldm.c
@@ -50,39 +50,39 @@
/* This macro does the setup and teardown required for the old API to use the
* new API. Since the setup/teardown logic is the same for all four send/recv
* functions, it makes sense to only define it once. */
-#define PLDM_REQ_FN(eid, fd, fn, ...) \
- do { \
- struct pldm_transport_mctp_demux *demux; \
- bool using_open_transport = false; \
- pldm_requester_rc_t rc; \
- pldm_tid_t tid = 1; \
- struct pldm_transport *ctx; \
+#define PLDM_REQ_FN(eid, fd, fn, ...) \
+ do { \
+ struct pldm_transport_mctp_demux *demux; \
+ bool using_open_transport = false; \
+ pldm_requester_rc_t rc; \
+ pldm_tid_t tid = 1; \
+ struct pldm_transport *ctx; \
/* The fd can be for a socket we opened or one the consumer \
- * opened. */ \
- if (open_transport && \
- mctp_fd == pldm_transport_mctp_demux_get_socket_fd( \
- open_transport)) { \
- using_open_transport = true; \
- demux = open_transport; \
- } else { \
- demux = pldm_transport_mctp_demux_init_with_fd(fd); \
- if (!demux) { \
- rc = PLDM_REQUESTER_OPEN_FAIL; \
- goto transport_out; \
- } \
- } \
- ctx = pldm_transport_mctp_demux_core(demux); \
- rc = pldm_transport_mctp_demux_map_tid(demux, tid, eid); \
- if (rc) { \
- rc = PLDM_REQUESTER_OPEN_FAIL; \
- goto transport_out; \
- } \
- rc = fn(ctx, tid, __VA_ARGS__); \
- transport_out: \
- if (!using_open_transport) { \
- pldm_transport_mctp_demux_destroy(demux); \
- } \
- return rc; \
+ * opened. */ \
+ if (open_transport && \
+ mctp_fd == pldm_transport_mctp_demux_get_socket_fd( \
+ open_transport)) { \
+ using_open_transport = true; \
+ demux = open_transport; \
+ } else { \
+ demux = pldm_transport_mctp_demux_init_with_fd(fd); \
+ if (!demux) { \
+ rc = PLDM_REQUESTER_OPEN_FAIL; \
+ goto transport_out; \
+ } \
+ } \
+ ctx = pldm_transport_mctp_demux_core(demux); \
+ rc = pldm_transport_mctp_demux_map_tid(demux, tid, eid); \
+ if (rc) { \
+ rc = PLDM_REQUESTER_OPEN_FAIL; \
+ goto transport_out; \
+ } \
+ rc = fn(ctx, tid, __VA_ARGS__); \
+ transport_out: \
+ if (!using_open_transport) { \
+ pldm_transport_mctp_demux_destroy(demux); \
+ } \
+ return rc; \
} while (0)
pldm_requester_rc_t pldm_recv_any(mctp_eid_t eid, int mctp_fd,
@@ -97,7 +97,7 @@
uint8_t **pldm_resp_msg, size_t *resp_msg_len)
{
pldm_requester_rc_t rc =
- pldm_recv_any(eid, mctp_fd, pldm_resp_msg, resp_msg_len);
+ pldm_recv_any(eid, mctp_fd, pldm_resp_msg, resp_msg_len);
struct pldm_msg_hdr *hdr = (struct pldm_msg_hdr *)(*pldm_resp_msg);
if (hdr->instance_id != instance_id) {
free(*pldm_resp_msg);
@@ -125,7 +125,7 @@
/* Adding this here for completeness in the case we can't smoothly
* transition apps over to the new api */
-void pldm_close()
+void pldm_close(void)
{
if (open_transport) {
pldm_transport_mctp_demux_destroy(open_transport);
diff --git a/src/transport/af-mctp.c b/src/transport/af-mctp.c
index 21d2c72..f499a72 100644
--- a/src/transport/af-mctp.c
+++ b/src/transport/af-mctp.c
@@ -108,7 +108,7 @@
return PLDM_REQUESTER_SEND_FAIL;
}
- struct sockaddr_mctp addr = {0};
+ struct sockaddr_mctp addr = { 0 };
addr.smctp_family = AF_MCTP;
addr.smctp_addr.s_addr = eid;
addr.smctp_type = MCTP_MSG_TYPE_PLDM;
@@ -129,7 +129,7 @@
}
struct pldm_transport_af_mctp *af_mctp =
- calloc(1, sizeof(struct pldm_transport_af_mctp));
+ calloc(1, sizeof(struct pldm_transport_af_mctp));
if (!af_mctp) {
return -ENOMEM;
}
diff --git a/src/transport/mctp-demux.c b/src/transport/mctp-demux.c
index 4b56f2f..4769827 100644
--- a/src/transport/mctp-demux.c
+++ b/src/transport/mctp-demux.c
@@ -113,8 +113,8 @@
return PLDM_REQUESTER_RECV_FAIL;
}
- ssize_t min_len =
- sizeof(eid) + sizeof(mctp_msg_type) + sizeof(struct pldm_msg_hdr);
+ ssize_t min_len = sizeof(eid) + sizeof(mctp_msg_type) +
+ sizeof(struct pldm_msg_hdr);
ssize_t length = recv(demux->socket, NULL, 0, MSG_PEEK | MSG_TRUNC);
if (length <= 0) {
return PLDM_REQUESTER_RECV_FAIL;
@@ -141,7 +141,7 @@
}
iov[1].iov_len = pldm_len;
iov[1].iov_base = *pldm_resp_msg;
- struct msghdr msg = {0};
+ struct msghdr msg = { 0 };
msg.msg_iov = iov;
msg.msg_iovlen = sizeof(iov) / sizeof(iov[0]);
ssize_t bytes = recvmsg(demux->socket, &msg, 0);
@@ -169,7 +169,7 @@
return PLDM_REQUESTER_SEND_FAIL;
}
- uint8_t hdr[2] = {eid, mctp_msg_type};
+ uint8_t hdr[2] = { eid, mctp_msg_type };
struct iovec iov[2];
iov[0].iov_base = hdr;
@@ -177,7 +177,7 @@
iov[1].iov_base = (uint8_t *)pldm_req_msg;
iov[1].iov_len = req_msg_len;
- struct msghdr msg = {0};
+ struct msghdr msg = { 0 };
msg.msg_iov = iov;
msg.msg_iovlen = sizeof(iov) / sizeof(iov[0]);
@@ -195,7 +195,7 @@
}
struct pldm_transport_mctp_demux *demux =
- calloc(1, sizeof(struct pldm_transport_mctp_demux));
+ calloc(1, sizeof(struct pldm_transport_mctp_demux));
if (!demux) {
return -ENOMEM;
}
@@ -228,7 +228,7 @@
pldm_transport_mctp_demux_init_with_fd(int mctp_fd)
{
struct pldm_transport_mctp_demux *demux =
- calloc(1, sizeof(struct pldm_transport_mctp_demux));
+ calloc(1, sizeof(struct pldm_transport_mctp_demux));
if (!demux) {
return NULL;
}
@@ -250,7 +250,7 @@
}
int pldm_transport_mctp_demux_get_socket_fd(
- struct pldm_transport_mctp_demux *ctx)
+ struct pldm_transport_mctp_demux *ctx)
{
if (ctx && ctx->socket) {
return ctx->socket;
diff --git a/src/transport/transport.c b/src/transport/transport.c
index 0681e23..c8be844 100644
--- a/src/transport/transport.c
+++ b/src/transport/transport.c
@@ -76,7 +76,7 @@
}
pldm_requester_rc_t rc =
- transport->recv(transport, tid, pldm_resp_msg, resp_msg_len);
+ transport->recv(transport, tid, pldm_resp_msg, resp_msg_len);
if (rc != PLDM_REQUESTER_SUCCESS) {
return rc;
}
@@ -108,8 +108,8 @@
return PLDM_REQUESTER_INVALID_SETUP;
}
- pldm_requester_rc_t rc =
- pldm_transport_send_msg(transport, tid, pldm_req_msg, req_msg_len);
+ pldm_requester_rc_t rc = pldm_transport_send_msg(
+ transport, tid, pldm_req_msg, req_msg_len);
if (rc != PLDM_REQUESTER_SUCCESS) {
return rc;
}
diff --git a/src/utils.c b/src/utils.c
index fb3553d..6fe93d1 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -11,75 +11,77 @@
*
*/
static uint32_t crc32_tab[] = {
- 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
- 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
- 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
- 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
- 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
- 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
- 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
- 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
- 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
- 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
- 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
- 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
- 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
- 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
- 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
- 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
- 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
- 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
- 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
- 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
- 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
- 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
- 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
- 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
- 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
- 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
- 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
- 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
- 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
- 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
- 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
- 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
- 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
- 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
- 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
- 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
- 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
- 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
- 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
- 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
- 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
- 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
- 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d};
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
+ 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+ 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
+ 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
+ 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+ 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
+ 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
+ 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
+ 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
+ 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+ 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
+ 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
+ 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+ 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
+ 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
+ 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+ 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
+ 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
+ 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+ 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
+ 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
+ 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
+ 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
+ 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+ 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
+ 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
+ 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+ 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
+ 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
+ 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
+};
/* 0x07(polynomial: x8+x2+x1+1)
*/
static const uint8_t crc8_table[] = {
- 0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31,
- 0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65,
- 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, 0xe0, 0xe7, 0xee, 0xe9,
- 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd,
- 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1,
- 0xb4, 0xb3, 0xba, 0xbd, 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2,
- 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, 0xb7, 0xb0, 0xb9, 0xbe,
- 0xab, 0xac, 0xa5, 0xa2, 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a,
- 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, 0x1f, 0x18, 0x11, 0x16,
- 0x03, 0x04, 0x0d, 0x0a, 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42,
- 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, 0x89, 0x8e, 0x87, 0x80,
- 0x95, 0x92, 0x9b, 0x9c, 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4,
- 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, 0xc1, 0xc6, 0xcf, 0xc8,
- 0xdd, 0xda, 0xd3, 0xd4, 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c,
- 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, 0x19, 0x1e, 0x17, 0x10,
- 0x05, 0x02, 0x0b, 0x0c, 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34,
- 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, 0x76, 0x71, 0x78, 0x7f,
- 0x6a, 0x6d, 0x64, 0x63, 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b,
- 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, 0xae, 0xa9, 0xa0, 0xa7,
- 0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83,
- 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef,
- 0xfa, 0xfd, 0xf4, 0xf3};
+ 0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31,
+ 0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65,
+ 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, 0xe0, 0xe7, 0xee, 0xe9,
+ 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd,
+ 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1,
+ 0xb4, 0xb3, 0xba, 0xbd, 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2,
+ 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, 0xb7, 0xb0, 0xb9, 0xbe,
+ 0xab, 0xac, 0xa5, 0xa2, 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a,
+ 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, 0x1f, 0x18, 0x11, 0x16,
+ 0x03, 0x04, 0x0d, 0x0a, 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42,
+ 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, 0x89, 0x8e, 0x87, 0x80,
+ 0x95, 0x92, 0x9b, 0x9c, 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4,
+ 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, 0xc1, 0xc6, 0xcf, 0xc8,
+ 0xdd, 0xda, 0xd3, 0xd4, 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c,
+ 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, 0x19, 0x1e, 0x17, 0x10,
+ 0x05, 0x02, 0x0b, 0x0c, 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34,
+ 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, 0x76, 0x71, 0x78, 0x7f,
+ 0x6a, 0x6d, 0x64, 0x63, 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b,
+ 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, 0xae, 0xa9, 0xa0, 0xa7,
+ 0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83,
+ 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef,
+ 0xfa, 0xfd, 0xf4, 0xf3
+};
uint32_t crc32(const void *data, size_t size)
{
@@ -101,8 +103,8 @@
return crc;
}
-#define BCD_H(v) (((v) >> 4) & 0xf)
-#define BCD_L(v) ((v)&0xf)
+#define BCD_H(v) (((v) >> 4) & 0xf)
+#define BCD_L(v) ((v)&0xf)
#define AS_CHAR(digit) ((digit) + '0')
#define INSERT_CHAR(c, b, n) \
{ \
@@ -193,8 +195,8 @@
if (month < 1 || month > 12) {
return false;
}
- static const int days[13] = {0, 31, 28, 31, 30, 31, 30,
- 31, 31, 30, 31, 30, 31};
+ static const int days[13] = { 0, 31, 28, 31, 30, 31, 30,
+ 31, 31, 30, 31, 30, 31 };
int rday = days[month];
if (month == 2 &&
((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))) {