[Cryptography] GOTO Considered Harmful

Phillip Hallam-Baker hallam at gmail.com
Fri Feb 28 19:48:09 EST 2014

I don't write code in C. I have my own personal language that is
implemented as C macros

#typedef int PUBLIC_ENTRY;
#define PRIVATE_ENTRY static int

#define BEGIN  << stuff >>
#define END  return 0; _fail:  << stuff >> return -1;

#define CHECK_STATUS(x) if (x != 0) goto _fail;

So all my functions look like

PUBLIC_ENTRY function () {

CHECK_STATUS (some_function);


If I had other people coding I would check their stuff with a preprocessor
that rejects any code that has the string goto in as a code smell.

(thats not the actual code, from memory as i don't take any source with me
when crossing national boundaries but you get the idea).

I don't trust ||= either...

The reason for PUBLIC_ENTRY is because I have a tool that looks for that
string to generate the function declaration headers from it.

Exception handling in C....
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.metzdowd.com/pipermail/cryptography/attachments/20140301/d51ad4a2/attachment.html>

More information about the cryptography mailing list