linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] efi/libstub: add strrchr function
@ 2018-03-01 15:27 Rob Herring
  2018-03-01 15:48 ` Ard Biesheuvel
  0 siblings, 1 reply; 2+ messages in thread
From: Rob Herring @ 2018-03-01 15:27 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: linux-kernel

libfdt gained a new dependency on strrchr, so copy the implementation
from lib/string.c.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack. This is a dependency for dtc/libfdt sync with upstream.

 drivers/firmware/efi/libstub/string.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/firmware/efi/libstub/string.c b/drivers/firmware/efi/libstub/string.c
index ed10e3f602c5..c1a7e58a5af7 100644
--- a/drivers/firmware/efi/libstub/string.c
+++ b/drivers/firmware/efi/libstub/string.c
@@ -56,3 +56,20 @@ int strncmp(const char *cs, const char *ct, size_t count)
 	return 0;
 }
 #endif
+
+#ifndef __HAVE_ARCH_STRRCHR
+/**
+ * strrchr - Find the last occurrence of a character in a string
+ * @s: The string to be searched
+ * @c: The character to search for
+ */
+char *strrchr(const char *s, int c)
+{
+	const char *last = NULL;
+	do {
+		if (*s == (char)c)
+			last = s;
+	} while (*s++);
+	return (char *)last;
+}
+#endif
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] efi/libstub: add strrchr function
  2018-03-01 15:27 [PATCH] efi/libstub: add strrchr function Rob Herring
@ 2018-03-01 15:48 ` Ard Biesheuvel
  0 siblings, 0 replies; 2+ messages in thread
From: Ard Biesheuvel @ 2018-03-01 15:48 UTC (permalink / raw)
  To: Rob Herring; +Cc: Linux Kernel Mailing List

On 1 March 2018 at 15:27, Rob Herring <robh@kernel.org> wrote:
> libfdt gained a new dependency on strrchr, so copy the implementation
> from lib/string.c.
>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> Please ack. This is a dependency for dtc/libfdt sync with upstream.
>
>  drivers/firmware/efi/libstub/string.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/drivers/firmware/efi/libstub/string.c b/drivers/firmware/efi/libstub/string.c
> index ed10e3f602c5..c1a7e58a5af7 100644
> --- a/drivers/firmware/efi/libstub/string.c
> +++ b/drivers/firmware/efi/libstub/string.c
> @@ -56,3 +56,20 @@ int strncmp(const char *cs, const char *ct, size_t count)
>         return 0;
>  }
>  #endif
> +
> +#ifndef __HAVE_ARCH_STRRCHR

As discussed over IRC, this #ifndef needs to be dropped.

Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> +/**
> + * strrchr - Find the last occurrence of a character in a string
> + * @s: The string to be searched
> + * @c: The character to search for
> + */
> +char *strrchr(const char *s, int c)
> +{
> +       const char *last = NULL;
> +       do {
> +               if (*s == (char)c)
> +                       last = s;
> +       } while (*s++);
> +       return (char *)last;
> +}
> +#endif
> --
> 2.14.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-01 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-01 15:27 [PATCH] efi/libstub: add strrchr function Rob Herring
2018-03-01 15:48 ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).