coding-style: add rule about checking NULL pointer

This commit is contained in:
Lucas De Marchi 2010-11-27 17:38:55 -02:00 committed by Denis Kenzior
parent e4413ccded
commit 43d2435e64
1 changed files with 21 additions and 0 deletions

View File

@ -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,