d3dx9_36/tests: Fix printing a NULL string

Francois Gouget fgouget at free.fr
Wed Aug 31 09:43:44 CDT 2011

On Tue, 30 Aug 2011, Joerg-Cyril.Hoehle at t-systems.com wrote:

> André Hentschel suggested:
> >Should stop the crash on Solaris and maybe others
> >-    trace("parent_data = (%p) -> %s\n", parent_data, (char *)parent_data);
> >+    trace("parent_data (%p) -> %s\n", parent_data, parent_data ? (char *)parent_data : "(null)");
> This is sooo backwards.  You don't want to try and find all places where (null) may be printed.
> I remember seeing (null) in logs here and there, so you're telling us that turning on
> Wine logs in Solaris can randomly crash Wine because it crashes on printf("%s", NULL)?
> I'm very surprised. I thought Solaris was one of the first machines - decades ago - where I observed "(null)" for NULL.
> (Or is that really glibc only?)

It appears this was quite extensively debated on the OpenSolaris mailing 

That's just to say that no, Solaris (unlike SunOS 4) never allowed a 
NULL pointer argument to '%s' (not that we should reenact the debate 
here). One of the recommendations in that thread is to define something 
like this where needed:

#define SAFESTR(s)  ((s) ? (s) : "(null)")

The Single UNIX Specification does not say what should happen in this 
case. To me that means we should not depend on '%s' accepting NULL 

Francois Gouget <fgouget at free.fr>              http://fgouget.free.fr/
  Any sufficiently advanced Operating System is indistinguishable from Linux

More information about the wine-devel mailing list