diff options
author | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2010-11-27 17:38:55 -0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-11-29 10:45:54 -0600 |
commit | 43d2435e64e4448cbdce222c68cb1352c5c74276 (patch) | |
tree | 3c96ec0c254b92657f59f54efff681833364a2c5 /doc/coding-style.txt | |
parent | e4413ccded09e8ad614b016e6ea809c5e47c7cd0 (diff) | |
download | ofono-43d2435e64e4448cbdce222c68cb1352c5c74276.tar.bz2 |
coding-style: add rule about checking NULL pointer
Diffstat (limited to 'doc/coding-style.txt')
-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, |