pdf-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pdf-devel] time module unit test cases


From: jemarch
Subject: Re: [pdf-devel] time module unit test cases
Date: Fri, 18 Apr 2008 20:55:05 +0200
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/23.0.60 (powerpc-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO)

    > Passing an invalid object to the function (an invalid pointer) will
    > surely cause the application to crash. It is generally not possible in
    > C to determine if a pointer is a "valid" one (if it points to
    > appropiately allocated _and_ appropriately initialized memory). Even
    > if you expect a crash (and test for the presence of a crash in the
    > process) you may be dissapointed: the application may survive if the
    > garbage contained in the pointer points to a valid memory
    > address. So it is not useful to define negative unit tests with
    > invalid pointers.
    > 
    > I hope that helps.
    > 

   NULL pointers indeed are invalid and should always be checked on.

I disagree. Anish is talking about expecting a coherent failure
behaviour from a function in case you pass an invalid pointer as a
parameter. To check for NULL pointers in a function expecting a
pointer parameter is a waste of time. Most pointer variables are
automatic variables and thus they are not initialized to 0. In that
context to check for NULL is like to check for 24.

What makes sense and of course is mandatory is to check for a NULL
pointer after calling a function that _explicitly_ set the return
value as NULL when there is a failure or some other condition.

-- 
Jose E. Marchesi  <address@hidden>
                  <address@hidden>

GNU Spain         http://es.gnu.org
GNU Project       http://www.gnu.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]