diff options
author | Werner Zeh <werner.zeh@siemens.com> | 2023-01-17 14:54:53 +0100 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2023-01-18 22:06:35 +0000 |
commit | fcff39f0ea47c8c0d82e802058d2ca47c4cc7005 (patch) | |
tree | b89e8889f4aa963a86eb0237f4e5faa76cfd6e8f /src/vendorcode/siemens/hwilib | |
parent | 610be7018b8d09a125cdd907b7898aec321fa795 (diff) |
vc/siemens/hwilib: Rename 'maxlen' to 'dstsize'
The parameter 'maxlen' can be a bit confusing as it actually is
referring to the size of the destination memory block where the
requested parameter is stored to. Rename it to 'dstsize' and change
the type to size_t to be more clear here.
In addition, add a comment line for this parameter in the description
of the function 'hwilib_get_field()'.
This patch has no impact to the generated binary (checked with timeless
build).
Change-Id: I572dc0f3ff3d0c177d608332a88991396b82c2fd
Signed-off-by: Werner Zeh <werner.zeh@siemens.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/72045
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Reviewed-by: Jan Samek <jan.samek@siemens.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Mario Scheithauer <mario.scheithauer@siemens.com>
Diffstat (limited to 'src/vendorcode/siemens/hwilib')
-rw-r--r-- | src/vendorcode/siemens/hwilib/hwilib.c | 26 | ||||
-rw-r--r-- | src/vendorcode/siemens/hwilib/hwilib.h | 2 |
2 files changed, 13 insertions, 15 deletions
diff --git a/src/vendorcode/siemens/hwilib/hwilib.c b/src/vendorcode/siemens/hwilib/hwilib.c index 240774926f..1705a618c5 100644 --- a/src/vendorcode/siemens/hwilib/hwilib.c +++ b/src/vendorcode/siemens/hwilib/hwilib.c @@ -43,7 +43,7 @@ enum { struct param_pos { uint8_t blk_type; /* Valid for a specific block type */ uint32_t offset; /* Offset in given block */ - uint32_t len; /* Length for the field in this block */ + size_t len; /* Length for the field in this block */ }; /* This structure holds all the needed information for a given field type @@ -53,8 +53,7 @@ struct param_info { struct param_pos pos[MAX_BLOCK_NUM]; uint64_t mask; uint8_t mask_offset; - uint32_t (*get_field)(const struct param_info *param, uint8_t *dst, - uint32_t maxlen); + uint32_t (*get_field)(const struct param_info *param, uint8_t *dst, size_t dstsize); }; /* Storage for pointers to the different blocks. The contents will be filled @@ -70,9 +69,7 @@ static uint16_t all_blk_size[MAX_BLOCK_NUM]; /* Storage for the cbfs file name of the currently open hwi file. */ static char current_hwi[HWI_MAX_NAME_LEN]; - -static uint32_t hwilib_read_bytes(const struct param_info *param, uint8_t *dst, - uint32_t maxlen); +static uint32_t hwilib_read_bytes(const struct param_info *param, uint8_t *dst, size_t dstsize); /* Add all supported fields to this variable. It is important to use the * field type of a given field as the array index so that all the information @@ -385,10 +382,10 @@ static const struct param_info params[] = { * block * @param *param Parameter to read from hwinfo * @param *dst Pointer to memory where the data will be stored in - * @return number of copied bytes on success, 0 on error + * @param dstsize Size of the memory passed in via the *dst pointer + * @return Number of copied bytes on success, 0 on error */ -static uint32_t hwilib_read_bytes(const struct param_info *param, uint8_t *dst, - uint32_t maxlen) +static uint32_t hwilib_read_bytes(const struct param_info *param, uint8_t *dst, size_t dstsize) { uint8_t i = 0, *blk = NULL; @@ -405,9 +402,9 @@ static uint32_t hwilib_read_bytes(const struct param_info *param, uint8_t *dst, } while (i < MAX_BLOCK_NUM); /* Ensure there is a valid block available for this parameter and - * the length of the parameter do not exceed maxlen or block len. + * the length of the parameter do not exceed dstsize or block len. */ - if ((!blk) || (param->pos[i].len > maxlen) || + if ((!blk) || (param->pos[i].len > dstsize) || (param->pos[i].len + param->pos[i].offset > all_blk_size[param->pos[i].blk_type])) return 0; @@ -541,13 +538,14 @@ enum cb_err hwilib_find_blocks(const char *hwi_filename) * hwinfo block. * @param field Field type to read from hwinfo * @param *dst Pointer to memory where the data will be stored in - * @return number of copied bytes on success, 0 on error + * @param dstsize Size of the memory passed in via the *dst pointer + * @return Number of copied bytes on success, 0 on error */ -uint32_t hwilib_get_field(hwinfo_field_t field, uint8_t *dst, uint32_t maxlen) +uint32_t hwilib_get_field(hwinfo_field_t field, uint8_t *dst, size_t dstsize) { /* Check the boundaries of params-variable */ if ((uint32_t)field < ARRAY_SIZE(params)) - return params[field].get_field(¶ms[field], dst, maxlen); + return params[field].get_field(¶ms[field], dst, dstsize); else return 0; } diff --git a/src/vendorcode/siemens/hwilib/hwilib.h b/src/vendorcode/siemens/hwilib/hwilib.h index 16df4301ab..e4b11dd528 100644 --- a/src/vendorcode/siemens/hwilib/hwilib.h +++ b/src/vendorcode/siemens/hwilib/hwilib.h @@ -123,6 +123,6 @@ enum cb_err hwilib_find_blocks(const char *hwi_filename); /* Use this function to get fields out of supported info blocks * This function returns the number of copied bytes or 0 on error. */ -uint32_t hwilib_get_field(hwinfo_field_t field, uint8_t *data, uint32_t maxlen); +uint32_t hwilib_get_field(hwinfo_field_t field, uint8_t *dst, size_t dstsize); #endif /* SIEMENS_HWI_LIB_H_ */ |