git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] CodingGuidelines: discourage arbitrary suffixes in function names
@ 2024-10-21 12:41 Karthik Nayak
  2024-10-21 12:59 ` Patrick Steinhardt
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Karthik Nayak @ 2024-10-21 12:41 UTC (permalink / raw)
  To: karthik.188; +Cc: git, ps

We often name functions with arbitrary suffixes like `_1` as an
extension of another existing function. This created confusion and
doesn't provide good clarity into the functions purpose. Let's document
good function naming etiquette in our CodingGuidelines.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---

This is mostly in response to an ongoing thread [1] where I ran into one of
these functions and it really took me a while to wrap my head around what the
function does.

[1]: https://lore.kernel.org/git/CAOLa=ZREg3xuaT6mbM8+Havn3regZDhK45kGy0+Fw8t56c7Mpg@mail.gmail.com/#R

 Documentation/CodingGuidelines | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 30fda4142c..b8e2d30567 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -621,6 +621,11 @@ For C programs:
     - `S_free()` releases a structure's contents and frees the
       structure.
 
+ - Function names should be self-explanatory, clearly reflecting their
+   purpose or behavior. To maintain clarity and avoid confusion,
+   arbitrary suffixes such as _1 are discouraged, as they provide no
+   meaningful insight into the function's role.
+
 For Perl programs:
 
  - Most of the C guidelines above apply.
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-10-24 16:50 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-21 12:41 [PATCH] CodingGuidelines: discourage arbitrary suffixes in function names Karthik Nayak
2024-10-21 12:59 ` Patrick Steinhardt
2024-10-21 20:02   ` Taylor Blau
2024-10-22  8:45     ` karthik nayak
2024-10-22 16:41       ` Taylor Blau
2024-10-23  7:44         ` karthik nayak
2024-10-24  0:50         ` Junio C Hamano
2024-10-24 16:50           ` Taylor Blau
2024-10-22  8:34   ` karthik nayak
2024-10-21 16:51 ` Kristoffer Haugsbakk
2024-10-22  8:47   ` karthik nayak
2024-10-23  7:57 ` [PATCH v2] " Karthik Nayak
2024-10-23 20:34   ` Taylor Blau
2024-10-23 21:03     ` Karthik Nayak
2024-10-23 23:07     ` Justin Tobler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).