From 42123a1556aab2d001342301008078252e365cac Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Wed, 14 Aug 2013 09:28:00 +0200 Subject: doc: Change coding style for NULL pointer checks --- doc/coding-style.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'doc') 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; -- cgit v1.2.3