Skip to contentSkip to conversation

lib: Make strreplace prototype compatible with C++

PATCH Superseded Matt Ullman 1 participant 1 message Jun 16, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: Make strreplace prototype compatible with C++

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

---
 include/linux/string.h |  2 +-
 lib/string.c           | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)
include/linux/string.h +1 -1
index 26b6f6a..410696d 100644
@@ -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);
 
lib/string.c +5 -5
index ed83562..bab5004 100644
@@ -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);
Signature · 1 line
2.9.0