Re: [Bug-tar] ignore_value vs (void) [was: bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X]
On 11/27/2013 01:18 PM, Charles Swiger wrote: > Thanks for the reply, and for Paul's as well, but that really is orthogonal > to the original point: using ignore_value() rather than a cast to void is a > GNUism which some folks seem to prefer in lieu of portable ANSI-C code. Huh? ignore_value(expression) is just as portable to ANSI C compilers as (void)expression as long as you have the #define ignore_value(expression) properly declared up front. Furthermore, it has the benefit of being declarative functional syntax rather than a cast, making it obvious that we know why we are using the call (I tend to avoid bare casts in my code because they have the tendency to hide too much information). > > That's readily apparent just from looking at: > > http://github.com/gagern/gnulib/blob/master/lib/ignore-value.h > > # if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) > > ...which is testing for GCC 3.4 or later. It does one thing for newer gcc to shut up gcc, and another thing for other compilers (including older gcc), and the alternative for non-gcc is ((void)(expression)). In other words, the macro devolves to ANSI standard code in all cases except for where we know extension syntax that is guaranteed to shut up compilers that happen to have a particular extension of warning on (void)expression. There's nothing wrong with using extensions in portable code when you've first checked that the extension is available; and the resulting #if/#else/#endif guarantees a fully-portable ignore_value. > > However, since we're on the topic and you appear to be one of the authors > of this code, Eric, would you agree with Paul that either ignore-value.h is > de minimus and not protectable under copyright, Reluctantly, yes. It really is quite small, and took me less than half an hour of reading the GCC manual to come up with the one-liner GCC branch of the #if condition; and the #else condition is the well-known ((void)(expression)). > or would you be willing to > also place it under a permissive license like the 2-clause BSD or MIT/zlib > licenses rather than under GPLv3? You aren't forced to use GPLv3+. The gnulib ignore-value module is already under LGPLv2+ (per the gnulib documentation, we list GPLv3 in the gnulib.git repo for .c and .h files for convenience in symlinking directly into gnulib for a GPLv3 project; but if you use './gnulib-tool --lgpl=2' to copy the code into your project, that action will rewrite the license to the minimum license agreed on by the authors or fail if the looser license is not acceptable). But if it can be argued that the code is copyrightable, then I refuse to relicense my contribution any further than its current LGPLv2+ status (BSD is too weak for my personal preference of FREE software - I generally refuse to release my code in such a manner that it can be abused in a proprietary nature without giving the same freedoms to others as I used in writing my code). -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [Bug-tar] ignore_value vs (void) [was: bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X]
On Nov 27, 2013, at 11:40 AM, Eric Blake wrote: > On 11/27/2013 12:04 PM, Charles Swiger wrote: >> With respect, folks who want to pull in gnulib for ignore_value() simply >> in order to write portable ANSI-C code are far more likely to benefit from >> Joerg's advice and experience in writing portable code-- code which does >> _not_ >> assume GCC & gnulib-- than they are likely to be correct about the relative >> portability of code to non-GNU platforms which don't come with gnulib. > > It sounds like you don't know what gnulib is (and are confusing it with > glibc). Gnulib is a library of SOURCE code, which is designed to > compile on ANY platform with a C89 or better compiler. It is not > required to use gcc to do the compilation, nor to link with glibc. > Gnulib is used in a large number of projects (some GNU, some not), and > has been proven to be useful on systems that don't have any GNU software > installed natively. Thanks for the reply, and for Paul's as well, but that really is orthogonal to the original point: using ignore_value() rather than a cast to void is a GNUism which some folks seem to prefer in lieu of portable ANSI-C code. That's readily apparent just from looking at: http://github.com/gagern/gnulib/blob/master/lib/ignore-value.h # if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) ...which is testing for GCC 3.4 or later. However, since we're on the topic and you appear to be one of the authors of this code, Eric, would you agree with Paul that either ignore-value.h is de minimus and not protectable under copyright, or would you be willing to also place it under a permissive license like the 2-clause BSD or MIT/zlib licenses rather than under GPLv3? Regards, -- -Chuck
Re: [Bug-tar] ignore_value vs (void) [was: bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X]
On 11/27/2013 12:04 PM, Charles Swiger wrote: > With respect, folks who want to pull in gnulib for ignore_value() simply > in order to write portable ANSI-C code are far more likely to benefit from > Joerg's advice and experience in writing portable code-- code which does _not_ > assume GCC & gnulib-- than they are likely to be correct about the relative > portability of code to non-GNU platforms which don't come with gnulib. It sounds like you don't know what gnulib is (and are confusing it with glibc). Gnulib is a library of SOURCE code, which is designed to compile on ANY platform with a C89 or better compiler. It is not required to use gcc to do the compilation, nor to link with glibc. Gnulib is used in a large number of projects (some GNU, some not), and has been proven to be useful on systems that don't have any GNU software installed natively. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [Bug-tar] ignore_value vs (void) [was: bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X]
On 11/27/2013 11:04 AM, Charles Swiger wrote: > folks who want to pull in gnulib for ignore_value() We're talking about six lines of code here; it's so small that it's not really copyrightable and you don't need to use gnulib at all -- just plop the lines into your application and use ignore_value all you want. It's portable in practice. One alternative is to tell builders to ignore those annoying warnings from glibc, but our experience is that it's better to silence them; this saves everybody time. > the relative > portability of code to non-GNU platforms which don't come with gnulib That's not how gnulib works. Platforms don't "come with gnulib"; applications that use gnulib bring the gnulib code along with them.
Re: [Bug-tar] ignore_value vs (void) [was: bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X]
Hi, all-- On Nov 27, 2013, at 10:10 AM, Paul Eggert wrote: > On 11/27/2013 09:05 AM, Joerg Schilling wrote: >> If you however like to write portable code, you cannot expect >> something like ignore_value() to be available. > > ignore_value is free software, is simple, > and is quite portable in practice > -- more portable than casting to 'void' is, > anyway. It's not really a contest. With respect, folks who want to pull in gnulib for ignore_value() simply in order to write portable ANSI-C code are far more likely to benefit from Joerg's advice and experience in writing portable code-- code which does _not_ assume GCC & gnulib-- than they are likely to be correct about the relative portability of code to non-GNU platforms which don't come with gnulib. Failing that, if one doesn't care what K&R says and prefers non-standard GNU extensions to re-implement what was already in ANSI-C, fine, but let's not pretend that casting to void hasn't been documented for literally 25+ years. The C Programming Language, 2nd Edition, Kernighan & Richie, 1988, page 213: "A 6.7 Void [ ... ] An expression may be converted to type void by a cast. For example, a void cast documents the discarding of a function call used as an expression statement." Regards, -- -Chuck
Re: [Bug-tar] ignore_value vs (void) [was: bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X]
On 11/27/2013 09:05 AM, Joerg Schilling wrote: > If you however like to write portable code, you cannot expect > something like ignore_value() to be available. ignore_value is free software, is simple, and is quite portable in practice -- more portable than casting to 'void' is, anyway. It's not really a contest.
Re: [Bug-tar] ignore_value vs (void) [was: bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X]
On 11/27/2013 10:05 AM, Joerg Schilling wrote: > If you like to stay in an environment that is based on GCC only, you may use > ignore_value(). If you however like to write portable code, you cannot expect > something like ignore_value() to be available. False. Gnulib already takes care of that; it #defines ignore_value(e) to ((void)(e)) on all non-gcc compilers. In other words, ignore_value() is portable to ANY standards-compliant compiler, and ALSO has the benefit of shutting up warnings on as many compilers as gnulib knows how to test. > Given the fact that other > compilers honor the (void) cast, GCC honors (void) casting - but that doesn't shut up the warning. Just because the standards require (void)expression to compile (and gcc compiles it just fine) doesn't mean that the compiler can't warn about it being suspicious. > it seems that gcc is trying to be different in > a way that just causes pain but that does not give extra value. Maybe, but that cat is already out of the bag, and cross-posting to these lists is not the effective forum to do anything about it. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [Bug-tar] ignore_value vs (void) [was: bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X]
Eric Blake wrote: > On 11/27/2013 09:53 AM, Joerg Schilling wrote: > >> The C standard does not document that '(void) write(...)' is required to > >> avoid diagnostics, so I don't see the gcc behavior as a bug (yes, it's > >> annoying behavior, but that doesn't make it incorrect behavior). > > > > Well, there is a more than 30 year history of lint that causes > > '(void) write(...)' to be accepted without a warning. > > So? Lint is not gcc, and gcc is not lint. Different compilers have > different capabilities at producing warnings, and you cannot expect that > something that works warning-free on one compiler will remain > warning-free on other compilers (even later versions of the same > compiler). Warnings are an art form, and not an exact science, > precisely because the C standard does not (rather, cannot) specify them. If you like to stay in an environment that is based on GCC only, you may use ignore_value(). If you however like to write portable code, you cannot expect something like ignore_value() to be available. Given the fact that other compilers honor the (void) cast, it seems that gcc is trying to be different in a way that just causes pain but that does not give extra value. Jörg -- EMail:jo...@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin j...@cs.tu-berlin.de(uni) joerg.schill...@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily
Re: [Bug-tar] ignore_value vs (void) [was: bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X]
On 11/27/2013 09:53 AM, Joerg Schilling wrote: >> The C standard does not document that '(void) write(...)' is required to >> avoid diagnostics, so I don't see the gcc behavior as a bug (yes, it's >> annoying behavior, but that doesn't make it incorrect behavior). > > Well, there is a more than 30 year history of lint that causes > '(void) write(...)' to be accepted without a warning. So? Lint is not gcc, and gcc is not lint. Different compilers have different capabilities at producing warnings, and you cannot expect that something that works warning-free on one compiler will remain warning-free on other compilers (even later versions of the same compiler). Warnings are an art form, and not an exact science, precisely because the C standard does not (rather, cannot) specify them. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [Bug-tar] ignore_value vs (void) [was: bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X]
Eric Blake wrote: > On 11/27/2013 09:30 AM, Joerg Schilling wrote: > >>> Are you using "ignore_value" because of the gcc bug that ignores the > >>> official > >>> method to tell that the return code is ignored intentionally: > >>> > >>> (void) write(fd, buf, len); > > The C standard does not document that '(void) write(...)' is required to > avoid diagnostics, so I don't see the gcc behavior as a bug (yes, it's > annoying behavior, but that doesn't make it incorrect behavior). Well, there is a more than 30 year history of lint that causes '(void) write(...)' to be accepted without a warning. Jörg -- EMail:jo...@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin j...@cs.tu-berlin.de(uni) joerg.schill...@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily