[Swan-dev] extra guards

D. Hugh Redelmeier hugh at mimosa.com
Sat Jul 12 23:45:11 EEST 2014


There's a lot of code like this at the start of functions:
        if (st == NULL)
		return;
in places where it should not be needed.

This is the case in release_fragments() as far as I can tell.

If it should not be needed, it should be left out.  That way we'll crash 
when something goes wrong, rather than bumbling forward.

Fail fast!

These extra tests make the code more complicated and sow doubts in the 
reader's mind about what the callers might be up to.

Of course there are plenty of times were tests like that are called for.

There is a minor convention is libreswan that if a function is freeing 
something but only if there is one, the suffix "any" is used.
Example: pfree() vs pfreeany().


More information about the Swan-dev mailing list