提交 9343db59 编写于 作者: P Peter Krempa

docs: hacking: Discourage use of the ternary operator and ban it's abuse

Forbid breaking lines inside the two branches of the ternary operator
and nesting them. Using it in these instances does not help readability.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
ACKed-by: NEric Blake <eblake@redhat.com>
上级 27dfb028
...@@ -847,6 +847,17 @@ BAD: ...@@ -847,6 +847,17 @@ BAD:
if (!nfoos) if (!nfoos)
if (nfoos) if (nfoos)
</pre> </pre>
<p>New code should avoid the ternary operator as much as possible.
Specifically it must never span more than one line or nest:
</p>
<pre>
BAD:
char *foo = baz ?
virDoSomethingReallyComplex(driver, vm, something, baz->foo) :
NULL;
char *foo = bar ? bar->baz ? bar->baz->foo : "nobaz" : "nobar";
</pre>
<h2><a id="preprocessor">Preprocessor</a></h2> <h2><a id="preprocessor">Preprocessor</a></h2>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册