From: Utkarsh Verma <utkarshverma294@gmail.com>
To: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>,
Joe Perches <joe@perches.com>, Jonathan Corbet <corbet@lwn.net>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Utkarsh Verma <utkarshverma294@gmail.com>
Subject: [PATCH] Documentation: checkpatch: Document some more message types
Date: Sun, 26 Sep 2021 01:47:46 +0530 [thread overview]
Message-ID: <20210925201746.15917-1-utkarshverma294@gmail.com> (raw)
Added and documented 3 new message types:
- UNNECESSARY_INT
- UNSPECIFIED_INT
- UNNECESSARY_ELSE
Signed-off-by: Utkarsh Verma <utkarshverma294@gmail.com>
---
Documentation/dev-tools/checkpatch.rst | 47 ++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/Documentation/dev-tools/checkpatch.rst b/Documentation/dev-tools/checkpatch.rst
index f0956e9ea2d8..2dc74682277f 100644
--- a/Documentation/dev-tools/checkpatch.rst
+++ b/Documentation/dev-tools/checkpatch.rst
@@ -929,6 +929,13 @@ Functions and Variables
return bar;
+ **UNNECESSARY_INT**
+ int used after short, long and long long is unnecessary. So remove it.
+
+ **UNSPECIFIED_INT**
+ Kernel style prefers "unsigned int <foo>" over "unsigned <foo>" and
+ "signed int <foo>" over "signed <foo>".
+
Permissions
-----------
@@ -1166,3 +1173,43 @@ Others
**TYPO_SPELLING**
Some words may have been misspelled. Consider reviewing them.
+
+ **UNNECESSARY_ELSE**
+ Using an else statement just after a return or a break statement is
+ unnecassary. For example::
+
+ for (i = 0; i < 100; i++) {
+ int foo = bar();
+ if (foo < 1)
+ break;
+ else
+ usleep(1);
+ }
+
+ is generally better written as::
+
+ for (i = 0; i < 100; i++) {
+ int foo = bar();
+ if (foo < 1)
+ break;
+ usleep(1);
+ }
+
+ So remove the else statement. But suppose if a if-else statement each
+ with a single return statement, like::
+
+ if (foo)
+ return bar;
+ else
+ return baz;
+
+ then by removing the else statement::
+
+ if (foo)
+ return bar;
+ return baz;
+
+ their is no significant increase in the readability and one can argue
+ that the first form is more readable because of indentation, so for
+ such cases do not convert the existing code from first form to second
+ form or vice-versa.
--
2.25.1
next reply other threads:[~2021-09-25 20:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-25 20:17 Utkarsh Verma [this message]
2021-09-27 17:43 ` [PATCH] Documentation: checkpatch: Document some more message types Jonathan Corbet
2021-09-27 17:47 ` Utkarsh Verma
2021-09-27 17:53 ` Joe Perches
2021-10-01 12:02 ` [PATCH] docs: checkpatch: add UNNECESSARY_ELSE message Utkarsh Verma
2021-10-02 14:45 ` [PATCH v2] " Utkarsh Verma
2021-10-03 4:38 ` Dwaipayan Ray
2021-10-03 5:08 ` Lukas Bulwahn
2021-10-03 5:19 ` Utkarsh Verma
2021-10-03 5:31 ` Lukas Bulwahn
2021-10-03 5:23 ` Lukas Bulwahn
2021-10-01 19:09 ` [PATCH] Documentation: checkpatch: Document some more message types Utkarsh Verma
2021-10-01 19:26 ` [PATCH] checkpatch: add check for continue statement in UNNECESSARY_ELSE Utkarsh Verma
2021-10-01 20:22 ` Joe Perches
2021-10-01 20:47 ` [PATCH v2] " Utkarsh Verma
2021-10-01 21:09 ` Joe Perches
2021-10-02 14:02 ` [PATCH v3] " Utkarsh Verma
2021-10-03 5:12 ` Lukas Bulwahn
2021-09-29 5:28 ` [PATCH] Documentation: checkpatch: Document some more message types Lukas Bulwahn
-- strict thread matches above, loose matches on Subject: below --
2021-09-25 16:38 Utkarsh Verma
2021-09-17 10:15 Utkarsh Verma
2021-09-17 12:39 ` Dwaipayan Ray
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=20210925201746.15917-1-utkarshverma294@gmail.com \
--to=utkarshverma294@gmail.com \
--cc=corbet@lwn.net \
--cc=dwaipayanray1@gmail.com \
--cc=joe@perches.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
/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 NNTP newsgroup(s).