[openssl-project] Style guide updates

Matt Caswell matt at openssl.org
Fri Jan 26 14:06:27 UTC 2018


Possible things to include:

- Don't use else after return?


- Don't check if a value is non NULL before calling xxx_free()


- Use size_t for sizes of things


- Treat single line if body with a separate line for a comment as multi
line:

e.g.

if (x) {
    /* my comment */
    single_line();
}


- Use ossl_assert() for asserting things


- Initialise in the declaration if appropriate, e.g.

int x = set_a_val();

Not

int x;

x = set_a_val();


- Blank line after variable declarations




On 26/01/18 13:26, Salz, Rich wrote:
> Some things I think we should add to the style guide.  Let’s discuss here.
> 
>  
> 
> No space after sizeof, use parens.  (But see
> ssl/record/rec_layer_{d1,s3}.c )
> 
>  
> 
> Multiline conditionals, such as in an if, should be broken before the
> logical connector and indented an extra tabstop.  For example:
> 
>  
> 
>     while (this_is_true
> 
>               && that_is_not_false) {
> 
>         frobit();
> 
>         more_stuff();
> 
>     }
> 
>  
> 
> When dealing with long lines, try to avoid breaking across a function
> call. Don’t do this:
> 
>     If (some_long_text && foo(a,
> 
>          b, c) && bar()) {
> 
> Instead do this:
> 
>     If (some_long_text
> 
>         && foo(a, b, c,)
> 
>         && bar())
> 
>  
> 
> What else needs to be updated?
> 
>  
> 
> 
> 
> _______________________________________________
> openssl-project mailing list
> openssl-project at openssl.org
> https://mta.openssl.org/mailman/listinfo/openssl-project
> 


More information about the openssl-project mailing list