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 /common/cbi.c | |
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 'common/cbi.c')
-rw-r--r-- | common/cbi.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/common/cbi.c b/common/cbi.c index 8517506eec..cf4605288a 100644 --- a/common/cbi.c +++ b/common/cbi.c @@ -49,6 +49,14 @@ uint8_t *cbi_set_data(uint8_t *p, enum cbi_data_tag tag, return p; } +uint8_t *cbi_set_string(uint8_t *p, enum cbi_data_tag tag, const char *str) +{ + if (str == NULL) + return p; + + return cbi_set_data(p, tag, str, strlen(str) + 1); +} + struct cbi_data *cbi_find_tag(const void *cbi, enum cbi_data_tag tag) { struct cbi_data *d; |