[Opendnssec-develop] About assert()...

Matthijs Mekking matthijs at nlnetlabs.nl
Mon Feb 10 09:12:32 UTC 2014


On 02/07/2014 02:45 PM, Jerry Lundström wrote:
> On 07 Feb 2014, at 14:30 , Yuri Schaeffer <yuri at NLnetLabs.nl> wrote:
> 
>> Assertions are meant for things that REALLY never should go wrong. If
>> you hit one you've hit a programming mistake. Crash early and often
>> I'd say. I would go as far as saying good code has LOTS of assertions.
> 
> Instead of dying in the middle of something essentially breaking and corrupting databases and files I’d rather see that the functions return an error and the callers handles that error.

I agree that having a lot of assertions is good practice. However, I
have a hard time of putting them in the right place. Below is an example
of where I was in doubt, and the ods_log_assert calls do not make sense
anymore.

> Looking a bit into the code there is a lot of assert that do not make any sense, like this (trunk):
> 
>     if (!kl || !key || !key->locator) {
>         ods_log_error("[%s] push failed: no list or no key", key_str);
>         return ODS_STATUS_ASSERT_ERR;
>     }
>     ods_log_assert(kl);
>     ods_log_assert(key);

In this specific case, there may be not anything useful to do for a
particular zone anymore, but other zones can continue to be signed.

Best regards,
  Matthijs

> 
> Guess its just leftover code, spring cleaning may be in order.
> 
> --
> Jerry Lundström - OpenDNSSEC Developer
> http://www.opendnssec.org/
> 
> 
> 
> _______________________________________________
> Opendnssec-develop mailing list
> Opendnssec-develop at lists.opendnssec.org
> https://lists.opendnssec.org/mailman/listinfo/opendnssec-develop
> 




More information about the Opendnssec-develop mailing list