Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1425346 > unrolled thread

[PATCH v2] lib: Make strreplace prototype compatible with C++

Started byMatt Ullman <staticfox@staticfox.net>
First post2016-06-17 19:30 +0200
Last post2016-06-17 22:30 +0200
Articles 5 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2] lib: Make strreplace prototype compatible with C++ Matt Ullman <staticfox@staticfox.net> - 2016-06-17 19:30 +0200
    Re: [PATCH v2] lib: Make strreplace prototype compatible with C++ Randy Dunlap <rdunlap@infradead.org> - 2016-06-17 20:40 +0200
      Re: [PATCH v2] lib: Make strreplace prototype compatible with C++ Matt Ullman <staticfox@staticfox.net> - 2016-06-17 21:40 +0200
        Re: [PATCH v2] lib: Make strreplace prototype compatible with C++ Joe Perches <joe@perches.com> - 2016-06-17 22:00 +0200
          Re: [PATCH v2] lib: Make strreplace prototype compatible with C++ Matt Ullman <staticfox@staticfox.net> - 2016-06-17 22:30 +0200

#1425346 — [PATCH v2] lib: Make strreplace prototype compatible with C++

FromMatt Ullman <staticfox@staticfox.net>
Date2016-06-17 19:30 +0200
Subject[PATCH v2] lib: Make strreplace prototype compatible with C++
Message-ID<rL5KG-Zn-27@gated-at.bofh.it>
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>
---
Thanks for your feedback and I agree. I've made the requested changes.
 include/linux/string.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/string.h b/include/linux/string.h
index 26b6f6a..1e5183b 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 *, char, char);
 
 extern void kfree_const(const void *x);
 
-- 
2.9.0

[toc] | [next] | [standalone]


#1425380

FromRandy Dunlap <rdunlap@infradead.org>
Date2016-06-17 20:40 +0200
Message-ID<rL6Qq-1D6-13@gated-at.bofh.it>
In reply to#1425346
On 06/17/16 10:24, Matt Ullman wrote:
> 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>
> ---
> Thanks for your feedback and I agree. I've made the requested changes.

I didn't see and could not find any reply to v1.  Who is that comment
addressed to?  Linus?

fwiw, I prefer v1 of the patch.  and so does scripts/kernel-doc.


>  include/linux/string.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/string.h b/include/linux/string.h
> index 26b6f6a..1e5183b 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 *, char, char);
>  
>  extern void kfree_const(const void *x);
>  
> 


-- 
~Randy

[toc] | [prev] | [next] | [standalone]


#1425396

FromMatt Ullman <staticfox@staticfox.net>
Date2016-06-17 21:40 +0200
Message-ID<rL7Mt-2cg-7@gated-at.bofh.it>
In reply to#1425380
On Fri, Jun 17, 2016 at 11:38:13AM -0700, Randy Dunlap wrote:
> I didn't see and could not find any reply to v1.  Who is that comment
> addressed to?  Linus?

Yes, this was addressed to Linus. He CC'd the mailing list, but I could not
find it either. Here is what he wrote:

> Please only change the prototype, not the function. Might as well remove
> the argument names in the prototype.
>
> Let's not make the C code uglier for no reason. The fact that C++ screwed
> up and thought that "new" can't be used as a variable name is no reason not
> to do it in C code.
>
> Similarly, we don't make C code use the insane C++ pointer caring rules.
>
>    Linus

-- Matt Ullman

[toc] | [prev] | [next] | [standalone]


#1425410

FromJoe Perches <joe@perches.com>
Date2016-06-17 22:00 +0200
Message-ID<rL85Q-2kS-27@gated-at.bofh.it>
In reply to#1425396
(Matt, you've got an unusual reply-to header)

On Fri, 2016-06-17 at 15:38 -0400, Matt Ullman wrote:
> On Fri, Jun 17, 2016 at 11:38:13AM -0700, Randy Dunlap wrote:
> > I didn't see and could not find any reply to v1.  Who is that comment
> > addressed to?  Linus?
> Yes, this was addressed to Linus. He CC'd the mailing list, but I could not
> find it either. Here is what he wrote:
> > 
> > Please only change the prototype, not the function. Might as well remove
> > the argument names in the prototype.
> > 
> > Let's not make the C code uglier for no reason. The fact that C++ screwed
> > up and thought that "new" can't be used as a variable name is no reason not
> > to do it in C code.
> > 
> > Similarly, we don't make C code use the insane C++ pointer caring rules.
> > 
> >    Linus
> -- Matt Ullman

I think kernel-doc is useful and maybe from/to or find/replace
could be used instead of old/new

[toc] | [prev] | [next] | [standalone]


#1425452

FromMatt Ullman <staticfox@staticfox.net>
Date2016-06-17 22:30 +0200
Message-ID<rL8yR-2Rk-1@gated-at.bofh.it>
In reply to#1425410
> On Fri, Jun 17, 2016 at 12:54:55PM -0700, Joe Perches wrote:
> (Matt, you've got an unusual reply-to header)

Apologies, I'm using a new mail client and accidently set Reply-To
instead of In-Reply-To.

-- Matt Ullman

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web