mirror of git://git.sysmocom.de/ofono
coding-style: add rule about checking NULL pointer
This commit is contained in:
parent
e4413ccded
commit
43d2435e64
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue