On Mon, 25 Mar 2013, Aldy Hernandez wrote:

> > I always tend to check for a null pointer before I access the fields in the
> > structure. In this case it is unnecessary. In some cases (e.g. find_rank)
> > there is a good chance a null pointer will be passed into the function and
> > we need to check that and reject those.
> 
> I think what Joseph is suggesting is that if NULL is not valid, then the
> caller should check this.  But if NULL is valid, then it should be documented
> in the function comment at the top.

The caller should only check it if it's valid in the caller but not the 
callee.  If it's invalid in the caller as well, neither should check 
(except maybe in an assertion if felt appropriate in a particular case).

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to