Skip to content

Commit 4b19bec

Browse files
committed
docs: deprecated.rst: Add uninitialized_var()
Nothing should be using this macro, and the entire idea of tricking the compiler into silencing such warnings is a mistake. Cc: Jonathan Corbet <[email protected]> Cc: "Gustavo A. R. Silva" <[email protected]> Cc: Joe Perches <[email protected]> Cc: [email protected] Reviewed-by: Nick Desaulniers <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent 9ebcfad commit 4b19bec

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Documentation/process/deprecated.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ to make sure their systems do not continue running in the face of
5151
"unreachable" conditions. (For example, see commits like `this one
5252
<https://git.kernel.org/linus/d4689846881d160a4d12a514e991a740bcb5d65a>`_.)
5353

54+
uninitialized_var()
55+
-------------------
56+
For any compiler warnings about uninitialized variables, just add
57+
an initializer. Using the uninitialized_var() macro (or similar
58+
warning-silencing tricks) is dangerous as it papers over `real bugs
59+
<https://lore.kernel.org/lkml/[email protected]/>`_
60+
(or can in the future), and suppresses unrelated compiler warnings
61+
(e.g. "unused variable"). If the compiler thinks it is uninitialized,
62+
either simply initialize the variable or make compiler changes. Keep in
63+
mind that in most cases, if an initialization is obviously redundant,
64+
the compiler's dead-store elimination pass will make sure there are no
65+
needless variable writes.
66+
67+
As Linus has said, this macro
68+
`must <https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=1TGqCR5vQkCzWJ0QxK6CernOU6eedsudAixw@mail.gmail.com/>`_
69+
`be <https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz9knmPuXhOeg@mail.gmail.com/>`_
70+
`removed <https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/>`_.
71+
5472
open-coded arithmetic in allocator arguments
5573
--------------------------------------------
5674
Dynamic size calculations (especially multiplication) should not be

0 commit comments

Comments
 (0)