Checking Exit Codes (was: Re: Trojan Horses)
Jim Balter
jim at segue.segue.com
Fri Nov 2 13:22:45 AEST 1990
In article <18664 at rpp386.cactus.org> jfh at rpp386.cactus.org (John F. Haugh II) writes:
>In article <4430 at segue.segue.com> jim at segue.segue.com (Jim Balter) writes:
>>You could avoid some embarrassment by testing your claims before making them
>>public. It would appear that you've never actually used assert, or that when
>>you do you don't follow the practice you recommend.
>
>ah, but i do try these things out -
>| signal (SIGIOT, SIG_IGN);
>| assert (argc == 2);
>| printf ("hi dave!\n");
The claim I was referring to was not that assert can be made to return
on some systems, but rather that easy portable programming of asserts
involve a call to exit.
In the normal use of assert, the code following the assert is executed under
normal conditions. The examples you give are simply not real uses of assert.
Assert is not intended to be used to print error messages, as you seem to use
it in your malloc example. A reasonable use is something like
assert(ptr != NULL); /* I (the programmer) believe that the logic of
the program precludes the possibility of ptr
being NULL at this point. If there is a
coding error that does allow ptr to be NULL,
this assert will detect it and prevent
the next line from referencing location 0,
as long as the program is not being compiled
with NDEBUG defined */
foo(*ptr);
Now, just where do you intend to insert the exit in this fragment of code?
>some people ...
Indeed.
More information about the Comp.unix.internals
mailing list