All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: u-boot@lists.denx.de
Subject: [PATCH 1/6] charset: Add support for calculating bytes occupied by a u16 string
Date: Wed,  6 May 2020 22:12:41 +0300	[thread overview]
Message-ID: <20200506191246.237790-2-ilias.apalodimas@linaro.org> (raw)
In-Reply-To: <20200506191246.237790-1-ilias.apalodimas@linaro.org>

From: Sughosh Ganu <sughosh.ganu@linaro.org>

The current code uses 'u16_strlen(x) + 1) * sizeof(u16)' in various
places to calculate the number of bytes occupied by a u16 string.
Let's introduce a wrapper around this. This wrapper is used on following
patches

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
 include/charset.h | 11 +++++++++++
 lib/charset.c     |  5 +++++
 2 files changed, 16 insertions(+)

diff --git a/include/charset.h b/include/charset.h
index fde6bddbc2fb..30faa72285e6 100644
--- a/include/charset.h
+++ b/include/charset.h
@@ -195,6 +195,17 @@ int u16_strncmp(const u16 *s1, const u16 *s2, size_t n);
  */
 size_t u16_strlen(const void *in);
 
+/**
+ * u16_strsize - count size of u16 string in bytes including the null character
+ *
+ * Counts the number of bytes occupied by a u16 string
+ *
+ * @in:			null terminated u16 string
+ * Return:		bytes in a u16 string
+ *
+ */
+size_t u16_strsize(const void *in);
+
 /**
  * u16_strlen - count non-zero words
  *
diff --git a/lib/charset.c b/lib/charset.c
index 1c6a7f693de4..a28034ee1f1e 100644
--- a/lib/charset.c
+++ b/lib/charset.c
@@ -379,6 +379,11 @@ size_t u16_strnlen(const u16 *in, size_t count)
 	return i;
 }
 
+size_t u16_strsize(const void *in)
+{
+	return (u16_strlen(in) + 1) * sizeof(u16);
+}
+
 u16 *u16_strcpy(u16 *dest, const u16 *src)
 {
 	u16 *tmp = dest;
-- 
2.26.2

  reply	other threads:[~2020-05-06 19:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06 19:12 [PATCH 0/6] EFI variable support via OP-TEE Ilias Apalodimas
2020-05-06 19:12 ` Ilias Apalodimas [this message]
2020-05-09  6:44   ` [PATCH 1/6] charset: Add support for calculating bytes occupied by a u16 string Heinrich Schuchardt
2020-05-06 19:12 ` [PATCH 2/6] efi_loader: Add headers for EDK2 StandAloneMM communication Ilias Apalodimas
2020-05-09  8:12   ` Heinrich Schuchardt
2020-05-11 10:25     ` Ilias Apalodimas
2020-05-06 19:12 ` [PATCH 3/6] efi_loader: Implement EFI variable handling via OP-TEE Ilias Apalodimas
2020-05-09  9:14   ` Heinrich Schuchardt
2020-05-11  8:43     ` Ilias Apalodimas
2020-05-11 10:00     ` Ilias Apalodimas
2020-05-06 19:12 ` [PATCH 4/6] cmd: efidebug: Add support for querying UEFI variable storage Ilias Apalodimas
2020-05-09  9:58   ` Heinrich Schuchardt
2020-05-11  8:49     ` Ilias Apalodimas
2020-05-06 19:12 ` [PATCH 5/6] MAINTAINERS: Add maintainer for EFI variables via OP-TEE Ilias Apalodimas
2020-05-09  9:17   ` Heinrich Schuchardt
2020-05-11  8:47     ` Ilias Apalodimas
2020-05-06 19:12 ` [PATCH 6/6] doc: uefi.rst: Add OP-TEE variable storage config options Ilias Apalodimas
2020-05-09  9:51   ` Heinrich Schuchardt
2020-05-11  8:52     ` Ilias Apalodimas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200506191246.237790-2-ilias.apalodimas@linaro.org \
    --to=ilias.apalodimas@linaro.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.