clang-format: copy latest and re-format
clang-format-16 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest .clang-format from the docs repository[1] and reformat
the repository.
[1] https://gerrit.openbmc.org/c/openbmc/docs/+/63441
Further, shift the fixup for C's `_Static_assert` into src/msgbuf.h to
prevent a clang-tidy-16 error:
```
/data0/jenkins/workspace/ci-repository/openbmc/libpldm/src/msgbuf.h:315:2: error: '_Static_assert' is a C11 extension [clang-diagnostic-c11-extensions,-warnings-as-errors]
_Static_assert(sizeof(*dst) == sizeof(ldst),
^
```
And fix up the function prototype in the definition of `pldm_open()`:
```
../src/requester/pldm.c:128:16: error: a function declaration without a prototype is deprecated in all versions of C [clang-diagnostic-strict-prototypes,-warnings-as-errors]
void pldm_close()
^
void
```
Change-Id: I57b53f51914e39237e733d024e62ab41b3d306c1
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/src/bios_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;