Wireshark-dev: Re: [Wireshark-dev] Passing NULL to %s format specifiers

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Wed, 15 Aug 2012 12:33:02 -0700
On Aug 15, 2012, at 12:10 PM, Guy Harris wrote:

> On Aug 15, 2012, at 8:12 AM, Evan Huus wrote:
> 
>> I'm a fan of a macro like Jakub mentioned as part of the old conversation:
>> 
>> http://www.wireshark.org/lists/wireshark-dev/201105/msg00205.html
> 
> ...but let's have the macro report a dissector bug if it sees a null pointer.  The dissector in question should probably say something other than just "(null)" if whatever routine supplied the pointer failed for some reason.

...or the non-dissector:

	http://anonsvn.wireshark.org/viewvc?revision=44512&view=revision

"unspecified" is better than "(null)" in that context.

Perhaps, instead, the macro should take *two* arguments:

	#define NULL_CHECK(p, substitute)	((p) != NULL ? (p) : (substitute))

and force everybody to decide what the protocol tree item/message/whatever should say if the pointer *is* null.