From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH 2/2] doc: Remove rule 13 in favor of O3
Date: Thu, 1 Feb 2024 14:44:00 -0600 [thread overview]
Message-ID: <20240201204412.951617-2-denkenz@gmail.com> (raw)
In-Reply-To: <20240201204412.951617-1-denkenz@gmail.com>
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 --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;
--
2.43.0
next prev parent reply other threads:[~2024-02-01 20:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 20:43 [PATCH 1/2] doc: Prefer l_new instead of g_try* Denis Kenzior
2024-02-01 20:44 ` Denis Kenzior [this message]
2024-02-01 21:40 ` patchwork-bot+ofono
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240201204412.951617-2-denkenz@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox