[Opendnssec-develop] About assert()...
Matthijs Mekking
matthijs at nlnetlabs.nl
Mon Feb 10 12:13:03 UTC 2014
On 02/10/2014 12:47 PM, Jerry Lundström wrote:
> On 10 Feb 2014, at 11:33 , Matthijs Mekking <matthijs at nlnetlabs.nl> wrote:
>
>> In some cases they also may be useful in releases, because if the
>> assertion did not kill the program, a segfault probably will. If not,
>> something terribly wrong may happen. So sometimes dying is just the
>> lesser of two evils...
>
> ... and even better would be if it reported the error, handled the problem and continued to operate so that states are kept non-corrupt.
>
> You might argue that an assert is really needed since a (for example) function should never be called with NULL.
>
> But what if something did call it with NULL, there might be a situation where the system is temporarily out of memory or that is was called from an untested code path or some other strange situation. Is it then our praxis, our coding standard to have the program just die? I’d really hope not.
>
> I can not really see how asserts are useful in stable releases of a daemon which has multiple states (zones) like we do. For testing?
Exactly. For testing and debugging.
Best regards,
Matthijs
>
> My point for bringing this all up is to hopefully improved the quality of our code base in the future.
>
> --
> Jerry Lundström - OpenDNSSEC Developer
> http://www.opendnssec.org/
>
More information about the Opendnssec-develop
mailing list