[libvirt] [PATCH 07/16] docs: hacking: mention compiler annotations

Ján Tomko jtomko at redhat.com
Fri Oct 18 22:36:41 UTC 2019


Mention all the __atribute__ annotations we use to make the compiler
and/or the static analysis tools understand the code better.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 docs/hacking.html.in | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/docs/hacking.html.in b/docs/hacking.html.in
index b270aa69e3..ad0f595897 100644
--- a/docs/hacking.html.in
+++ b/docs/hacking.html.in
@@ -984,6 +984,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>
-- 
2.21.0




More information about the libvir-list mailing list