[ovs-dev] [PATCH v2] coding-style: Explain when to break lines before or after binary operators.

Tiago Lam tiagolam at gmail.com
Fri Dec 1 23:41:12 UTC 2017


Thanks, Ben!

This clarifies things for me. I've also tried to render the file and 
everything looks fine.

Only one small nit below, but it doesn't affect the rendering, thus, for 
what it's worth:

Acked-by: Tiago Lam <tiagolam at gmail.com>

On 12/01/2017 07:22 PM, Ben Pfaff wrote:
> +Breaking a long line after a binary operator gives its operands a more
> +consistent look, since each operand has the same horizontal position.  This
> +makes the end-of-line position a good choice when the operands naturally
> +resemble each other, as in the previous two examples.  On the other hand,
> +breaking before a binary operator better draws the eye to the operator, which
> +can help clarify code by making it more obvious what's happening, such as in
> +the following example::
> +
> +        if (!ctx.freezing
> +            && xbridge->has_in_band
> +            && in_band_must_output_to_local_port(flow)
> +            && !actions_output_to_local_port(&ctx)) {
> +

Just the indentation on this example above is odd when compared to the 
others on the file (but again, doesn't seem to affect rendering).

> +Thus, decide whether to break before or after a binary operator separately in
> +each situation, based on which of these factors appear to be more important.
>   
>   Try to avoid casts. Don't cast the return value of malloc().
>   
> 


More information about the dev mailing list