On Tue, Jul 11, 2006 at 12:14:59AM -0700, Padraig O'Briain wrote: > I have submitted patches to various projects to change references to string > variables which could be NULL from > > s to > > s ? s : "NULL"
Why? Other than debugging, what possible value does "NULL" have to users besides than alerting them to the fact that your software is buggy? > I have looked in the code and found > http://cvs.opensolaris.org/source/xref/on/usr/src/common/util/string.c#172 > > which I think is what Linux is doing. Linux will panic on any NULL pointer dereference. glibc prints "(null)" last I saw, just like SunOS 4, which should come as no surprise since early GNU was usually intended to act like that OS. > Most of the code where I have encountered the4 problem are logging > or debug statements. You will have difficulty persuading people used > to that behavior that it is a bug and not a feature. It's not a bug, it's a feature. A misfeature, to be exact. Like [EMAIL PROTECTED], it's a feature that you can use to hide bugs in your software. Unlike [EMAIL PROTECTED], it's on all the time, which is pure 200-proof insanity. You might have better luck arguing for a separate globally-visible family of functions that offer this behaviour, but that still doesn't address the fact that this is really useful only for debugging, where you probably already have your own debug_printf() anyway. Sure, there are cases when a NULL value corresponds to something meaningful, but what should be displayed is application-specific. Finally, relying on this behaviour is still unportable even if OpenSolaris has it, so you're back to fixing all the broken apps if you care about portability at all. Despite the low cost, I just don't see anything positive about this feature. -- Keith M Wesolowski "Sir, we're surrounded!" Solaris Kernel Team "Excellent; we can attack in any direction!" _______________________________________________ opensolaris-code mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/opensolaris-code
