[hipl-dev] Re: [Branch ~toxedvirus/hipl/hipfw-modules] Rev 5008: Forward command line initialization to modules in order to allow registering command line options...

  • From: Stefan Götz <stefan.goetz@xxxxxxxxxxxxxxxxx>
  • To: hipl-dev@xxxxxxxxxxxxx
  • Date: Thu, 04 Nov 2010 12:00:47 +0100

>     Diego seems to not like the '!= NULL' in checks so much...
> 
> How else am I supposed to check a function pointer?

Just leave out the '!= NULL' part: if (fptr) {...

>     Why does this function not check the option_list and modules parameters 
> for NULL
>     pointers?
> 
> Shall I check every paramter for a possible NULL value and print an error 
> message?

You shall check every parameter for a possible NULL value and at least return an
error to caller. I guess an error message is unnecessary because it's the
caller's fault to pass in a NULL pointer in the first place so they should
prevent or handle it in the first place.

The argument for such checks is that NULL pointers tend to crop up occasionally
and, if unchecked, simply terminate the whole process via a beautiful
segmentation fault. That makes users grumpy :-)

I know, I know - this function is called by automatically generated code which
should theoretically never pass in NULL pointers. I would recommend to still do
those checks just in case this assumption changes and because it simply should
be done everywhere.

Stefan

Other related posts: