diff mbox series

[2/2] doc: Remove rule 13 in favor of O3

Message ID 20240201204412.951617-2-denkenz@gmail.com (mailing list archive)
State Accepted
Commit feb3e44bb6b4df73fb5e56d6cd3fc05957354ad7
Headers show
Series [1/2] doc: Prefer l_new instead of g_try* | expand

Commit Message

Denis Kenzior Feb. 1, 2024, 8:44 p.m. UTC
Since oFono is slowly migrating to ell, remove rule M13 and indicate
that rule O3 style is preferred to match the prevalent coding style in
ell.  Many of the newer code additions have already been silently
following these recommendations.  Make them explicit.
---
 doc/coding-style.txt | 38 ++++++++++++++++----------------------
 1 file changed, 16 insertions(+), 22 deletions(-)
diff mbox series

Patch

diff --git a/doc/coding-style.txt b/doc/coding-style.txt
index 0ec1cd97e8ca..96837f7687eb 100644
--- a/doc/coding-style.txt
+++ b/doc/coding-style.txt
@@ -241,28 +241,6 @@  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;
-
-
 M14: Always use parenthesis with sizeof
 =======================================
 The expression argument to the sizeof operator should always be in
@@ -347,3 +325,19 @@  v = voicecall_create(vc, call);
 v->detect_time = time(NULL);
 DBG("Registering new call: %d", call->id);
 voicecall_dbus_register(v);
+
+O3: Prefer !foo when checking pointers for NULL or boolean values
+=================================================================
+
+When checking if a pointer or a return value is NULL, prefer the negation
+operator form.
+
+Example:
+1)
+array = g_try_new0(int, 2000000);
+if (!array)
+	return -ENOMEM;
+
+2)
+if (!g_at_chat_get_slave(chat))
+	return -EINVAL;