diff options
-rw-r--r-- | doc/coding-style.txt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/doc/coding-style.txt b/doc/coding-style.txt index eccdacc6..9dfdc09c 100644 --- a/doc/coding-style.txt +++ b/doc/coding-style.txt @@ -209,6 +209,27 @@ However if the enum comes from an external header file outside ofono we cannot make any assumption of how the enum is defined and this rule might not apply. +M13: Check for pointer being NULL +================================= + +When checking if a pointer or a return value is NULL, explicitly compare to +NULL rather than use the shorter check with "!" operator. + +Example: +1) +array = g_try_new0(int, 20); +if (!array) // Wrong + return; + +2) +if (!g_at_chat_get_slave(chat)) // Wrong + return -EINVAL; + +3) +array = g_try_new0(int, 20); +if (array == NULL) // Correct + return; + O1: Shorten the name ==================== Better to use abbreviation, rather than full name, to name a variable, |