diff mbox series

backports: add strreplace()

Message ID 1537351259-19914-1-git-send-email-chi-hsien.lin@cypress.com (mailing list archive)
State Superseded
Headers show
Series backports: add strreplace() | expand

Commit Message

Chi-Hsien Lin Sept. 19, 2018, 10:01 a.m. UTC
From: Winnie Chang <Winnie.Chang@cypress.com>

wireless-drivers-next.git commit cb18e2e9ec71 (brcmfmac: fix wrong
strnchr usage) used strreplace(), which is not available in kernel prior
to v4.12. Before this commit proprgates to linux-stable.git, add
strreplace() to avoid gentree failure.

Signed-off-by: Winnie Chang <winnie.chang@cypress.com>
Signed-off-by: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
---
 backport/backport-include/linux/string.h | 4 ++++
 backport/compat/backport-4.2.c           | 9 +++++++++
 2 files changed, 13 insertions(+)

--
2.1.0


This message and any attachments may contain confidential information from Cypress or its subsidiaries. If it has been received in error, please advise the sender and immediately delete this message.
--
To unsubscribe from this list: send the line "unsubscribe backports" in

Comments

Johannes Berg Sept. 19, 2018, 10:03 a.m. UTC | #1
On Wed, 2018-09-19 at 10:01 +0000, Chi-Hsien Lin wrote:
> From: Winnie Chang <Winnie.Chang@cypress.com>
> 
> wireless-drivers-next.git commit cb18e2e9ec71 (brcmfmac: fix wrong
> strnchr usage) used strreplace(), which is not available in kernel prior
> to v4.12.

4.12,

> +#if LINUX_VERSION_IS_LESS(4,2,0)

or 4.2?

johannes

--
To unsubscribe from this list: send the line "unsubscribe backports" in
diff mbox series

Patch

diff --git a/backport/backport-include/linux/string.h b/backport/backport-include/linux/string.h
index b85d9c73dc27..4b35eb9f2baf 100644
--- a/backport/backport-include/linux/string.h
+++ b/backport/backport-include/linux/string.h
@@ -29,4 +29,8 @@  void memzero_explicit(void *s, size_t count);
 ssize_t strscpy(char *dest, const char *src, size_t count);
 #endif

+#if LINUX_VERSION_IS_LESS(4,2,0)
+char *strreplace(char *s, char old, char new);
+#endif
+
 #endif /* __BACKPORT_LINUX_STRING_H */
diff --git a/backport/compat/backport-4.2.c b/backport/compat/backport-4.2.c
index e00aa49c7e4a..b275d349f7eb 100644
--- a/backport/compat/backport-4.2.c
+++ b/backport/compat/backport-4.2.c
@@ -65,3 +65,12 @@  struct aead_request *crypto_backport_convert(struct aead_request *req)
 return &nreq->subreq;
 }
 EXPORT_SYMBOL_GPL(crypto_backport_convert);
+
+char *strreplace(char *s, char old, char new)
+{
+for (; *s; ++s)
+if (*s == old)
+*s = new;
+return s;
+}
+EXPORT_SYMBOL_GPL(strreplace);