mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matt Ullman <staticfox@staticfox.net>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Matt Ullman <staticfox@staticfox.net>
Subject: [PATCH] lib: Make strreplace prototype compatible with C++
Date: Thu, 16 Jun 2016 16:41:19 -0400	[thread overview]
Message-ID: <20160616204119.24008-1-staticfox@staticfox.net> (raw)

Since "new" is a keyword in C++, this breaks compilation when string.h is included in a
C++ file. For example, this affects VirtualBox Guest Additions.

https://www.virtualbox.org/pipermail/vbox-dev/2015-August/013368.html

Signed-off-by: Matt Ullman <staticfox@staticfox.net>
---
 include/linux/string.h |  2 +-
 lib/string.c           | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/string.h b/include/linux/string.h
index 26b6f6a..410696d 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -115,7 +115,7 @@ extern int memcmp(const void *,const void *,__kernel_size_t);
 extern void * memchr(const void *,int,__kernel_size_t);
 #endif
 void *memchr_inv(const void *s, int c, size_t n);
-char *strreplace(char *s, char old, char new);
+char *strreplace(char *s, char oldstr, char newstr);
 
 extern void kfree_const(const void *x);
 
diff --git a/lib/string.c b/lib/string.c
index ed83562..bab5004 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -939,16 +939,16 @@ EXPORT_SYMBOL(memchr_inv);
 /**
  * strreplace - Replace all occurrences of character in string.
  * @s: The string to operate on.
- * @old: The character being replaced.
- * @new: The character @old is replaced with.
+ * @oldstr: The character being replaced.
+ * @newstr: The character @oldstr is replaced with.
  *
  * Returns pointer to the nul byte at the end of @s.
  */
-char *strreplace(char *s, char old, char new)
+char *strreplace(char *s, char oldstr, char newstr)
 {
 	for (; *s; ++s)
-		if (*s == old)
-			*s = new;
+		if (*s == oldstr)
+			*s = newstr;
 	return s;
 }
 EXPORT_SYMBOL(strreplace);
-- 
2.9.0

                 reply	other threads:[~2016-06-16 20:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20160616204119.24008-1-staticfox@staticfox.net \
    --to=staticfox@staticfox.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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

Powered by JetHome