summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2013-08-14 09:28:00 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2013-08-20 11:05:31 +0200
commit42123a1556aab2d001342301008078252e365cac (patch)
tree9c8793d765e336dd51c0cfc694878f90ed20921d /doc
parenta62d26e32a4ca80a32040b9a9a2a9abe3d77dc78 (diff)
downloadneard-42123a1556aab2d001342301008078252e365cac.tar.gz
neard-42123a1556aab2d001342301008078252e365cac.tar.bz2
neard-42123a1556aab2d001342301008078252e365cac.zip
doc: Change coding style for NULL pointer checks
Diffstat (limited to 'doc')
-rw-r--r--doc/coding-style.txt14
1 files changed, 7 insertions, 7 deletions
diff --git a/doc/coding-style.txt b/doc/coding-style.txt
index 47f9c4a..75ba3c4 100644
--- a/doc/coding-style.txt
+++ b/doc/coding-style.txt
@@ -51,7 +51,7 @@ b = 3;
The only exception to this rule applies when a variable is being allocated:
array = g_try_new0(int, 20);
-if (array == NULL) // Correct
+if (array) // Correct
return;
@@ -162,7 +162,7 @@ the expected behavior, and you may want to use g_try_malloc instead.
Example:
additional = g_try_malloc(len - 1); // correct
-if (additional == NULL)
+if (additional)
return FALSE;
@@ -247,22 +247,22 @@ 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.
+When checking if a pointer or a return value is NULL, use the
+check with "!" operator.
Example:
1)
array = g_try_new0(int, 20);
-if (!array) // Wrong
+if (!array) // Correct
return;
2)
-if (!g_at_chat_get_slave(chat)) // Wrong
+if (!g_at_chat_get_slave(chat)) // Correct
return -EINVAL;
3)
array = g_try_new0(int, 20);
-if (array == NULL) // Correct
+if (array == NULL) // Wrong
return;