From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/5] lib: string: retire deprecated strtok() in favor of reentrant strsep()
Date: Mon, 14 Sep 2020 15:37:44 +0200 [thread overview]
Message-ID: <20200914133748.5988-1-a.fatoum@pengutronix.de> (raw)
With the recent changes to ARCH=sandbox, there are no remaining
in-tree users for strtok() anymore. Out-of-tree users are better
served by using the reentrant strsep(), which has existed in-tree
for as long.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Should be applied after <20200914100553.24808-1-a.fatoum@pengutronix.de>
---
include/linux/string.h | 2 --
lib/string.c | 35 +++--------------------------------
2 files changed, 3 insertions(+), 34 deletions(-)
diff --git a/include/linux/string.h b/include/linux/string.h
index 763ef500e574..2b699957e824 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -8,9 +8,7 @@
extern "C" {
#endif
-extern char * ___strtok;
extern char * strpbrk(const char *,const char *);
-extern char * strtok(char *,const char *);
extern char * strsep(char **,const char *);
extern char * strsep_unescaped(char **,const char *);
extern __kernel_size_t strspn(const char *,const char *);
diff --git a/lib/string.c b/lib/string.c
index 50f8e2f87c9f..733b56730070 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -13,6 +13,9 @@
* * Fri Jun 25 1999, Ingo Oeser <ioe@informatik.tu-chemnitz.de>
* - Added strsep() which will replace strtok() soon (because strsep() is
* reentrant and should be faster). Use only strsep() in new code, please.
+ * * Mon Sep 14 2020, Ahmad Fatoum <a.fatoum@pengutronix.de>
+ * - Kissed strtok() goodbye
+ *
*/
#include <linux/types.h>
@@ -20,8 +23,6 @@
#include <linux/ctype.h>
#include <malloc.h>
-char * ___strtok;
-
#ifndef __HAVE_ARCH_STRNICMP
/**
* strnicmp - Case insensitive, length-limited string comparison
@@ -396,36 +397,6 @@ char * strpbrk(const char * cs,const char * ct)
#endif
EXPORT_SYMBOL(strpbrk);
-#ifndef __HAVE_ARCH_STRTOK
-/**
- * strtok - Split a string into tokens
- * @s: The string to be searched
- * @ct: The characters to search for
- *
- * WARNING: strtok is deprecated, use strsep instead.
- */
-char * strtok(char * s, const char * ct)
-{
- char *sbegin, *send;
-
- sbegin = s ? s : ___strtok;
- if (!sbegin) {
- return NULL;
- }
- sbegin += strspn(sbegin,ct);
- if (*sbegin == '\0') {
- ___strtok = NULL;
- return( NULL );
- }
- send = strpbrk( sbegin, ct);
- if (send && *send != '\0')
- *send++ = '\0';
- ___strtok = send;
- return (sbegin);
-}
-#endif
-EXPORT_SYMBOL(strtok);
-
#ifndef __HAVE_ARCH_STRSEP
/**
* strsep - Split a string into tokens
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2020-09-14 13:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-14 13:37 Ahmad Fatoum [this message]
2020-09-14 13:37 ` [PATCH 2/5] ls: don't print . and .. on recursive ls Ahmad Fatoum
2020-09-14 13:37 ` [PATCH 3/5] sandbox: implement simple, ^C-interruptible, restart handler Ahmad Fatoum
2020-09-14 13:37 ` [PATCH 4/5] sandbox: implement actual sandbox reset via exec(2) Ahmad Fatoum
2020-09-15 5:21 ` [PATCH] fixup! " Ahmad Fatoum
2020-09-14 13:37 ` [PATCH 5/5] sandbox: hostfile: support registering images as barebox block devices Ahmad Fatoum
2020-09-15 7:26 ` [PATCH 1/5] lib: string: retire deprecated strtok() in favor of reentrant strsep() Sascha Hauer
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=20200914133748.5988-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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