From 72cf2e3ae24b17e55b39831c2b02f26a0ca168a2 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 11 Sep 2017 17:14:21 +0200 Subject: README.Coding: Add section about pointers Signed-off-by: Andreas Schneider --- README.CodingStyle | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.CodingStyle b/README.CodingStyle index badd16f3..11acd8dc 100644 --- a/README.CodingStyle +++ b/README.CodingStyle @@ -287,6 +287,27 @@ Good Examples: return rc; } +Initialize pointers +------------------- + +All pointer variables MUST be initialized to NULL. History has +demonstrated that uninitialized pointer variables have lead to various +bugs and security issues. + +Pointers MUST be initialized even if the assignment directly follows +the declaration, like pointer2 in the example below, because the +instructions sequence may change over time. + +Good Example: + + char *pointer1 = NULL; + char *pointer2 = NULL; + + pointer2 = some_func2(); + + ... + + pointer1 = some_func1(); Typedefs --------- -- cgit v1.2.3