提交 e30c787a 编写于 作者: J Ján Tomko

docs: hacking: mention compiler annotations

Mention all the __attribute__ annotations we use to make the compiler
and/or the static analysis tools understand the code better.
Signed-off-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
Reviewed-by: NAndrea Bolognani <abologna@redhat.com>
上级 16eed886
......@@ -985,6 +985,25 @@ BAD:
it points to, or it is aliased to another pointer that is.
</p>
<h2><a id="attribute_annotations">Attribute annotations</a></h2>
<p>
Use the following annotations to help the compiler and/or static
analysis tools understand the code better:
</p>
<table class="top_table">
<tr><th>Macro</th><th>Meaning</th></tr>
<tr><td><code>ATTRIBUTE_NONNULL</code></td><td>passing NULL for this parameter is not allowed</td></tr>
<tr><td><code>ATTRIBUTE_PACKED</code></td><td>force a structure to be packed</td></tr>
<tr><td><code>G_GNUC_FALLTHROUGH</code></td><td>allow code reuse by multiple switch cases</td></tr>
<tr><td><code>G_GNUC_NO_INLINE</code></td><td>the function is mocked in the test suite</td></tr>
<tr><td><code>G_GNUC_NORETURN</code></td><td>the function never returns</td></tr>
<tr><td><code>G_GNUC_NULL_TERMINATED</code></td><td>last parameter must be NULL</td></tr>
<tr><td><code>G_GNUC_PRINTF</code></td><td>validate that the formatting string matches parameters</td></tr>
<tr><td><code>G_GNUC_UNUSED</code></td><td>parameter is unused in this implementation of the function</td></tr>
<tr><td><code>G_GNUC_WARN_UNUSED_RESULT</code></td><td>the return value must be checked</td></tr>
</table>
<h2><a id="glib">Adoption of GLib APIs</a></h2>
<p>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册