From: Max Kellermann <max.kellermann@ionos.com>
To: linux@roeck-us.net, joe@perches.com, gregkh@linuxfoundation.org,
Jonathan Corbet <corbet@lwn.net>
Cc: Max Kellermann <max.kellermann@ionos.com>,
workflows@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v3] Documentation/process/coding-style.rst: space around const
Date: Tue, 10 Oct 2023 14:58:31 +0200 [thread overview]
Message-ID: <20231010125832.1002941-1-max.kellermann@ionos.com> (raw)
There are currently no rules on the placement of "const", but a recent
code submission revealed that there is clearly a preference for spaces
around it.
checkpatch.pl has no check at all for this; though it does sometimes
complain, but only because it erroneously thinks that the "*" (on
local variables) is an unary dereference operator, not a pointer type.
Current coding style for const pointers-to-pointers:
"*const*": 2 occurrences
"* const*": 3
"*const *": 182
"* const *": 681
Just const pointers:
"*const": 2833 occurrences
"* const": 16615
Link: https://lore.kernel.org/r/264fa39d-aed6-4a54-a085-107997078f8d@roeck-us.net/
Link: https://lore.kernel.org/r/f511170fe61d7e7214a3a062661cf4103980dad6.camel@perches.com/
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
V1 -> V2: removed "volatile" on gregkh's request.
V2 -> V3: moved patch changelog below the "---" line
---
Documentation/process/coding-style.rst | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/Documentation/process/coding-style.rst b/Documentation/process/coding-style.rst
index 6db37a46d305..71d62d81e506 100644
--- a/Documentation/process/coding-style.rst
+++ b/Documentation/process/coding-style.rst
@@ -271,6 +271,17 @@ adjacent to the type name. Examples:
unsigned long long memparse(char *ptr, char **retptr);
char *match_strdup(substring_t *s);
+Use space around the ``const`` keyword (except when adjacent to
+parentheses). Example:
+
+.. code-block:: c
+
+ const void *a;
+ void * const b;
+ void ** const c;
+ void * const * const d;
+ int strcmp(const char *a, const char *b);
+
Use one space around (on each side of) most binary and ternary operators,
such as any of these::
--
2.39.2
next reply other threads:[~2023-10-10 12:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 12:58 Max Kellermann [this message]
2023-10-10 19:24 ` [PATCH v3] Documentation/process/coding-style.rst: space around const Greg KH
2023-10-10 23:46 ` Guenter Roeck
2023-10-11 0:45 ` Joe Perches
2023-10-11 21:44 ` Dan Williams
2023-10-12 11:50 ` Miguel Ojeda
2023-10-12 14:48 ` Joe Perches
2023-10-12 16:53 ` Miguel Ojeda
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=20231010125832.1002941-1-max.kellermann@ionos.com \
--to=max.kellermann@ionos.com \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=workflows@vger.kernel.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).