Skip to content

The Sourcecode: Formatting and Style

Steffen Jaeckel edited this page Sep 7, 2019 · 5 revisions

Formatting

Basic Formatting

The basic formatting—the placing of brackets, how many spaces and where, etc.—are done by a simple make astyle. The program astyle should be available in almost all Linux and BSD distributions and if that is not the case, is available at their home at Sourceforge.

Braces

Also one-liners go into curly brackets.

Exceptions

The error-handling is normally done with a goto to the end. That goto has to be at the same line as the error-check itself and without the curly brackets. The goto shall be aligned. Example:

if ((err = mp_add(&a, &b, &c) != MP_OKAY)        goto LTM_ERR;
if ((err = mp_incr(&c) != MP_OKAY)               goto LTM_ERR;

Style

All static and private functions have to have the prefix s_.

Clone this wiki locally