diff options
author | Furquan Shaikh <furquan@google.com> | 2019-03-06 14:44:37 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-03-08 21:20:36 -0800 |
commit | c67a566dbcca552b3d7cea57832685c2a83033d6 (patch) | |
tree | dc358e43acf0bc4e9ccf7b1df220f6897caf406f /util | |
parent | 03e1bfd9a375d52236323978e151ed6fdc68a59a (diff) | |
download | chrome-ec-c67a566dbcca552b3d7cea57832685c2a83033d6.tar.gz |
cbi: Add a new API for cbi_set_string
This change introduces cbi_set_string that can be used by callers to
add string data to CBI. Internally, this function ensures that the
data is not NULL and call cbi_set_data for the string with a size of
strlen + 1. It is added so that callers don't have to repeat the same
operations for string data.
BUG=b:124282048
BRANCH=None
TEST=None
Change-Id: Iad9da206c5e87735eac3adee6fce151fd1f0a53a
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1506440
Commit-Ready: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/cbi-util.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/util/cbi-util.c b/util/cbi-util.c index 2ea86b14cf..f8abb4e64a 100644 --- a/util/cbi-util.c +++ b/util/cbi-util.c @@ -340,14 +340,8 @@ static int cmd_create(int argc, char **argv) p = cbi_set_data(p, CBI_TAG_OEM_ID, &bi.oem.val, bi.oem.size); p = cbi_set_data(p, CBI_TAG_SKU_ID, &bi.sku.val, bi.sku.size); p = cbi_set_data(p, CBI_TAG_MODEL_ID, &bi.model.val, bi.model.size); - if (bi.dram_part_num != NULL) { - p = cbi_set_data(p, CBI_TAG_DRAM_PART_NUM, bi.dram_part_num, - strlen(bi.dram_part_num) + 1); - } - if (bi.oem_name != NULL) { - p = cbi_set_data(p, CBI_TAG_OEM_NAME, bi.oem_name, - strlen(bi.oem_name) + 1); - } + p = cbi_set_string(p, CBI_TAG_DRAM_PART_NUM, bi.dram_part_num); + p = cbi_set_string(p, CBI_TAG_OEM_NAME, bi.oem_name); h->total_size = p - cbi; h->crc = cbi_crc8(h); |