Re: CVS commit: src/sys/sys
On Mon, Aug 10, 2009 at 12:24:47AM +0200, Martin Husemann wrote: On Sun, Aug 09, 2009 at 09:20:02PM +, Christos Zoulas wrote: The new style casts are very useful because they show programming intent. So do C casts! provided what you are casting is an integer type or a pointer to a struct (rather than a class). Yes, new style casts are fine. Hmm... even writing a bit of C++ I used C casts when passing buffers to send() etc - casts which are needed because C++ doesn't have a working 'void *'. But warning about old style casts in a language that is designed to be C compatible is plain stupid. Besides, there should be no casts in system headers ;-} What happens if these casts are put into inline functions inside the 'exterrn C' block. The compiler really has no excuse to warn then, if it does it is a compler bug. David -- David Laight: da...@l8s.co.uk
Re: CVS commit: src/sys/uvm
On Sun, 09 Aug 2009 22:19:10 +, Matt Thomas wrote: @@ -708,7 +742,7 @@ l = outl2; #ifdef DEBUG if (swapdebug SDB_SWAPOUT) - printf(%s: no duds, try procp %p\n, __func__, l); + printf(__func__ : no duds, try procp %p\n, l); #endif if (l) { mutex_enter(l-l_swaplock); This will not work
Re: CVS commit: src/sys
On Mon, Aug 10, 2009 at 03:44:38PM +, David Holland wrote: On Sun, Aug 09, 2009 at 10:49:01PM +, Adam Hamsik wrote: Log Message: Add enum uio_seg argument to do_sys_mknod and do_sys_mkdir so these functions can be called from kernel, too. This is the wrong approach: in the user case, copyinstr should happen before getting to these functions. (Well, actually there should be two sets of functions; see what I just posted on tech-kern.) -- David A. Holland dholl...@netbsd.org
Re: CVS commit: src/sys/sys
On Sun, Aug 09, 2009 at 09:20:02PM +, Christos Zoulas wrote: In article 20090809210918.gc22...@drowsy.duskware.de, Martin Husemann mar...@duskware.de wrote: On Sun, Aug 09, 2009 at 09:29:50PM +0200, Tonnerre LOMBARD wrote: Unfortunately, these are widely used headers. We don't want to break -Wold-style-casts in general. Why not? It is IMHO a very useless and stupid warning. The new style casts are very useful because they show programming intent. Can't we instead do what Solaris does? #ifdef __cplusplus extern C { #endif [...] #define __byte_swap_u64_constant(x) \ ((uint64_t) \ [...] #ifdef __cplusplus } #endif That should allows us to keep the old-casts and avoid warnings. Kind regards -- Matthias Scheler http://zhadum.org.uk/
Re: CVS commit: src/sys/sys
On Sun, Aug 09, 2009 at 11:23:53PM +0200, Tonnerre LOMBARD wrote: There may be valid reasons not to want to have them. Yes, in C++ sources and header files. System header files are C headers, not C++ headers. Kind regards P.S. The fundamental problem is of course that C++ tries to be backwards compatible without forcing you to use extern C. -- Matthias Scheler http://zhadum.org.uk/
Re: CVS commit: src/sys/sys
On Aug 10, 5:27pm, t...@netbsd.org (Matthias Scheler) wrote: -- Subject: Re: CVS commit: src/sys/sys | On Sun, Aug 09, 2009 at 09:20:02PM +, Christos Zoulas wrote: | In article 20090809210918.gc22...@drowsy.duskware.de, | Martin Husemann mar...@duskware.de wrote: | On Sun, Aug 09, 2009 at 09:29:50PM +0200, Tonnerre LOMBARD wrote: | Unfortunately, these are widely used headers. We don't want to break | -Wold-style-casts in general. | | Why not? | | It is IMHO a very useless and stupid warning. | | The new style casts are very useful because they show programming intent. | | Can't we instead do what Solaris does? | | #ifdef __cplusplus | extern C { | #endif | | [...] | #define __byte_swap_u64_constant(x) \ | ((uint64_t) \ | [...] | | #ifdef __cplusplus | } | #endif | | That should allows us to keep the old-casts and avoid warnings. This cannot possibly work because the syntax parsing happens after the macro is expanded and the macro is expanded in c++ code. christos
Re: CVS commit: src/sys/sys
On Aug 10, 7:03pm, t...@netbsd.org (Matthias Scheler) wrote: -- Subject: Re: CVS commit: src/sys/sys | On Mon, Aug 10, 2009 at 12:59:57PM -0400, Christos Zoulas wrote: | | That should allows us to keep the old-casts and avoid warnings. | | This cannot possibly work because the syntax parsing happens after the macro | is expanded and the macro is expanded in c++ code. | | Why would that matter? G++ should not complain about old style casts | in 'extern C' sections. | extern C { #define bar(a) (int)(a) }; void foo(void) { double d = 2; int a = bar(a); } The c function implemented as a macro should be able to be used in c++ code. christos