public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 01/11] lib: charset: add u16_strcmp()
Date: Thu, 25 Apr 2019 09:38:24 +0900	[thread overview]
Message-ID: <20190425003823.GF7158@linaro.org> (raw)
In-Reply-To: <2751c0b5-94b7-9080-c14a-fb4eff9f9c2e@gmx.de>

On Wed, Apr 24, 2019 at 06:24:44PM +0200, Heinrich Schuchardt wrote:
> On 4/24/19 8:30 AM, AKASHI Takahiro wrote:
> >u16 version of strcmp()
> >
> >AUTHER: Patrick Wildt <patrick@blueri.se>
> 
> %s/AUTHER/Author/

Okay

> >Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> >---
> >  include/charset.h |  5 +++++
> >  lib/charset.c     | 10 ++++++++++
> >  2 files changed, 15 insertions(+)
> >
> >diff --git a/include/charset.h b/include/charset.h
> >index 65087f76d1fc..747a9b376c03 100644
> >--- a/include/charset.h
> >+++ b/include/charset.h
> >@@ -166,6 +166,11 @@ s32 utf_to_lower(const s32 code);
> >   */
> >  s32 utf_to_upper(const s32 code);
> >
> >+/*
> >+ * u16_strcmp() - strcmp() for u16 strings
> >+ */
> >+int u16_strcmp(const u16 *s1, const u16 *s2);
> >+
> >  /**
> >   * u16_strlen - count non-zero words
> >   *
> >diff --git a/lib/charset.c b/lib/charset.c
> >index 5e349ed5ee45..4a25ac0bdb9c 100644
> >--- a/lib/charset.c
> >+++ b/lib/charset.c
> >@@ -335,6 +335,16 @@ s32 utf_to_upper(const s32 code)
> >  	return ret;
> >  }
> >
> >+int u16_strcmp(const u16 *s1, const u16 *s2)
> >+{
> >+	while (*s1 == *s2++)
> >+		if (*s1++ == 0)
> >+			return (0);
> >+	--s2;
> 
> for (;*s1 == *s2; ++s1, ++s2)
> 	if (!s1)
> 		return 0;
> 
> does the same job without superfluous increment/decrement.

Indeed :)

> >+
> >+	return (*(uint16_t *)s1 - *(uint16_t *)s2);
> 
> Why would you use both u16 and uint16_t in the same function?
> You can do without any conversion here.

Will fix.

> How about
> 
> #define u16_strcmp(s1, s2) u16_strncmp(s1, s2, SIZE_MAX)
> 
> like we do for the other string functions?

Sure

Thanks,
-Takahiro Akashi

> Best regards
> 
> Heinrich
> 
> >+}
> >+
> >  size_t u16_strlen(const u16 *in)
> >  {
> >  	size_t i;
> >
> 

  reply	other threads:[~2019-04-25  0:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-24  6:30 [U-Boot] [PATCH v2 00/11] efi_loader: non-volatile variables support AKASHI Takahiro
2019-04-24  6:30 ` [U-Boot] [PATCH v2 01/11] lib: charset: add u16_strcmp() AKASHI Takahiro
2019-04-24 16:24   ` Heinrich Schuchardt
2019-04-25  0:38     ` AKASHI Takahiro [this message]
2019-04-24  6:30 ` [U-Boot] [PATCH v2 02/11] lib: charset: add u16_strncmp() AKASHI Takahiro
2019-04-24 17:40   ` Heinrich Schuchardt
2019-04-24 18:36   ` Heinrich Schuchardt
2019-04-25  0:16     ` AKASHI Takahiro
2019-04-24  6:30 ` [U-Boot] [PATCH v2 03/11] cmd: efidebug: rework "boot dump" sub-command using GetNextVariableName() AKASHI Takahiro
2019-04-24 20:13   ` Heinrich Schuchardt
2019-04-25  0:30     ` AKASHI Takahiro
2019-04-24  6:30 ` [U-Boot] [PATCH v2 04/11] efi_loader: set OsIndicationsSupported at init AKASHI Takahiro
2019-04-24  6:30 ` [U-Boot] [PATCH v2 05/11] env: save UEFI non-volatile variables in dedicated storage AKASHI Takahiro
2019-04-25 18:44   ` Heinrich Schuchardt
2019-04-24  6:30 ` [U-Boot] [PATCH v2 06/11] efi_loader: variable: support non-volatile attribute AKASHI Takahiro
2019-04-24  6:30 ` [U-Boot] [PATCH v2 07/11] efi_loader: variable: split UEFI variables from U-Boot environment AKASHI Takahiro
2019-04-24  6:30 ` [U-Boot] [PATCH v2 08/11] efi_loader: load saved non-volatile variables at init AKASHI Takahiro
2019-04-24  6:30 ` [U-Boot] [PATCH v2 09/11] efi_loader: bootmgr: handle BootNext as non-volatile AKASHI Takahiro
2019-04-24  6:30 ` [U-Boot] [PATCH v2 10/11] cmd: env: add -nv option for UEFI non-volatile variable AKASHI Takahiro
2019-04-24  6:30 ` [U-Boot] [PATCH v2 11/11] cmd: efidebug: make some boot variables non-volatile AKASHI Takahiro
2019-04-24 22:12 ` [U-Boot] [PATCH v2 00/11] efi_loader: non-volatile variables support Heinrich Schuchardt
2019-04-25  1:12   ` AKASHI Takahiro

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=20190425003823.GF7158@linaro.org \
    --to=takahiro.akashi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox