All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Documentation/CodingStyle: Add an example for braces
@ 2018-03-15 20:04 ` Gary R Hook
  0 siblings, 0 replies; 12+ messages in thread
From: Gary R Hook @ 2018-03-15 20:04 UTC (permalink / raw)
  To: linux-doc; +Cc: linux-kernel, corbet

Add another example of required braces when using a compound statements.

Signed-off-by: Gary R Hook <gary.hook@amd.com>
---

Changes since v1:
- Move the new example up, and make it more generic

 Documentation/process/coding-style.rst |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/process/coding-style.rst b/Documentation/process/coding-style.rst
index a20b44a40ec4..fcef0b4b59d0 100644
--- a/Documentation/process/coding-style.rst
+++ b/Documentation/process/coding-style.rst
@@ -188,6 +188,15 @@ and
 	else
 		do_that();
 
+Do use braces when a body is more complex than a single simple statement:
+
+.. code-block:: c
+
+	if (condition) {
+		if (another_condition)
+			do_something();
+	}
+
 This does not apply if only one branch of a conditional statement is a single
 statement; in the latter case use braces in both branches:
 

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

* [PATCH v2] Documentation/CodingStyle: Add an example for braces
@ 2018-03-15 20:04 ` Gary R Hook
  0 siblings, 0 replies; 12+ messages in thread
From: Gary R Hook @ 2018-03-15 20:04 UTC (permalink / raw)
  To: linux-doc; +Cc: linux-kernel, corbet

Add another example of required braces when using a compound statements.

Signed-off-by: Gary R Hook <gary.hook@amd.com>
---

Changes since v1:
- Move the new example up, and make it more generic

 Documentation/process/coding-style.rst |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/process/coding-style.rst b/Documentation/process/coding-style.rst
index a20b44a40ec4..fcef0b4b59d0 100644
--- a/Documentation/process/coding-style.rst
+++ b/Documentation/process/coding-style.rst
@@ -188,6 +188,15 @@ and
 	else
 		do_that();
 
+Do use braces when a body is more complex than a single simple statement:
+
+.. code-block:: c
+
+	if (condition) {
+		if (another_condition)
+			do_something();
+	}
+
 This does not apply if only one branch of a conditional statement is a single
 statement; in the latter case use braces in both branches:
 

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2] Documentation/CodingStyle: Add an example for braces
  2018-03-15 20:04 ` Gary R Hook
@ 2018-03-21 15:17   ` Jonathan Corbet
  -1 siblings, 0 replies; 12+ messages in thread
From: Jonathan Corbet @ 2018-03-21 15:17 UTC (permalink / raw)
  To: Gary R Hook; +Cc: linux-doc, linux-kernel, Jani Nikula

On Thu, 15 Mar 2018 15:04:02 -0500
Gary R Hook <gary.hook@amd.com> wrote:

> +Do use braces when a body is more complex than a single simple statement:
> +
> +.. code-block:: c
> +
> +	if (condition) {
> +		if (another_condition)
> +			do_something();
> +	}

Somebody is sure to complain at some point that this should really be:

	if (condition && another_condition)
		do_something();

To head that off, I think I'll apply your first version instead, sorry
Jani.

In general I'm pretty reluctant to apply coding-style patches for the
simple reason that I sure don't want to be the arbitrator of proper kernel
style.  This one seems to fit well within the accepted norms, though.

Thanks,

jon

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

* Re: [PATCH v2] Documentation/CodingStyle: Add an example for braces
@ 2018-03-21 15:17   ` Jonathan Corbet
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Corbet @ 2018-03-21 15:17 UTC (permalink / raw)
  To: Gary R Hook; +Cc: linux-doc, linux-kernel, Jani Nikula

On Thu, 15 Mar 2018 15:04:02 -0500
Gary R Hook <gary.hook@amd.com> wrote:

> +Do use braces when a body is more complex than a single simple statement:
> +
> +.. code-block:: c
> +
> +	if (condition) {
> +		if (another_condition)
> +			do_something();
> +	}

Somebody is sure to complain at some point that this should really be:

	if (condition && another_condition)
		do_something();

To head that off, I think I'll apply your first version instead, sorry
Jani.

In general I'm pretty reluctant to apply coding-style patches for the
simple reason that I sure don't want to be the arbitrator of proper kernel
style.  This one seems to fit well within the accepted norms, though.

Thanks,

jon
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2] Documentation/CodingStyle: Add an example for braces
  2018-03-21 15:17   ` Jonathan Corbet
@ 2018-03-22  9:12     ` Jani Nikula
  -1 siblings, 0 replies; 12+ messages in thread
From: Jani Nikula @ 2018-03-22  9:12 UTC (permalink / raw)
  To: Jonathan Corbet, Gary R Hook; +Cc: linux-doc, linux-kernel

On Wed, 21 Mar 2018, Jonathan Corbet <corbet@lwn.net> wrote:
> To head that off, I think I'll apply your first version instead, sorry
> Jani.

No worries.

BR,
Jani.

-- 
Jani Nikula, Intel Open Source Technology Center

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

* Re: [PATCH v2] Documentation/CodingStyle: Add an example for braces
@ 2018-03-22  9:12     ` Jani Nikula
  0 siblings, 0 replies; 12+ messages in thread
From: Jani Nikula @ 2018-03-22  9:12 UTC (permalink / raw)
  To: Jonathan Corbet, Gary R Hook; +Cc: linux-doc, linux-kernel

On Wed, 21 Mar 2018, Jonathan Corbet <corbet@lwn.net> wrote:
> To head that off, I think I'll apply your first version instead, sorry
> Jani.

No worries.

BR,
Jani.

-- 
Jani Nikula, Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2] Documentation/CodingStyle: Add an example for braces
  2018-03-22  9:12     ` Jani Nikula
@ 2018-03-26 16:28       ` Gary R Hook
  -1 siblings, 0 replies; 12+ messages in thread
From: Gary R Hook @ 2018-03-26 16:28 UTC (permalink / raw)
  To: Jani Nikula, Jonathan Corbet; +Cc: linux-doc, linux-kernel

On 03/22/2018 04:12 AM, Jani Nikula wrote:
> On Wed, 21 Mar 2018, Jonathan Corbet <corbet@lwn.net> wrote:
>> To head that off, I think I'll apply your first version instead, sorry
>> Jani.
> 
> No worries.
> 

Submitting a v3 because the example could better illuminate the options 
by using loop construct inside of an if, addressing Jani's point but 
without opening the door to later criticism.

I also like the verbage in v2/3 better, but I'll let Jonathan make the call.

BTW which tree should these be developed against? I used torvalds, but 
I'm not entirely sure that was the proper one?

Gary

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

* Re: [PATCH v2] Documentation/CodingStyle: Add an example for braces
@ 2018-03-26 16:28       ` Gary R Hook
  0 siblings, 0 replies; 12+ messages in thread
From: Gary R Hook @ 2018-03-26 16:28 UTC (permalink / raw)
  To: Jani Nikula, Jonathan Corbet; +Cc: linux-doc, linux-kernel

On 03/22/2018 04:12 AM, Jani Nikula wrote:
> On Wed, 21 Mar 2018, Jonathan Corbet <corbet@lwn.net> wrote:
>> To head that off, I think I'll apply your first version instead, sorry
>> Jani.
> 
> No worries.
> 

Submitting a v3 because the example could better illuminate the options 
by using loop construct inside of an if, addressing Jani's point but 
without opening the door to later criticism.

I also like the verbage in v2/3 better, but I'll let Jonathan make the call.

BTW which tree should these be developed against? I used torvalds, but 
I'm not entirely sure that was the proper one?

Gary

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2] Documentation/CodingStyle: Add an example for braces
  2018-03-26 16:28       ` Gary R Hook
@ 2018-03-26 16:32         ` Jonathan Corbet
  -1 siblings, 0 replies; 12+ messages in thread
From: Jonathan Corbet @ 2018-03-26 16:32 UTC (permalink / raw)
  To: Gary R Hook; +Cc: Jani Nikula, linux-doc, linux-kernel

On Mon, 26 Mar 2018 11:28:03 -0500
Gary R Hook <gary.hook@amd.com> wrote:

> Submitting a v3 because the example could better illuminate the options 
> by using loop construct inside of an if, addressing Jani's point but 
> without opening the door to later criticism.
> 
> I also like the verbage in v2/3 better, but I'll let Jonathan make the call.

As I told you, I was applying the first version; I did that last week.

> BTW which tree should these be developed against? I used torvalds, but 
> I'm not entirely sure that was the proper one?

The MAINTAINERS file will (almost) always answer that question for
you:	

	T:	git git://git.lwn.net/linux.git docs-next

For a patch like this it doesn't matter, since there's is no other work on
the file to conflict with.

THanks,

jon

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

* Re: [PATCH v2] Documentation/CodingStyle: Add an example for braces
@ 2018-03-26 16:32         ` Jonathan Corbet
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Corbet @ 2018-03-26 16:32 UTC (permalink / raw)
  To: Gary R Hook; +Cc: Jani Nikula, linux-doc, linux-kernel

On Mon, 26 Mar 2018 11:28:03 -0500
Gary R Hook <gary.hook@amd.com> wrote:

> Submitting a v3 because the example could better illuminate the options 
> by using loop construct inside of an if, addressing Jani's point but 
> without opening the door to later criticism.
> 
> I also like the verbage in v2/3 better, but I'll let Jonathan make the call.

As I told you, I was applying the first version; I did that last week.

> BTW which tree should these be developed against? I used torvalds, but 
> I'm not entirely sure that was the proper one?

The MAINTAINERS file will (almost) always answer that question for
you:	

	T:	git git://git.lwn.net/linux.git docs-next

For a patch like this it doesn't matter, since there's is no other work on
the file to conflict with.

THanks,

jon
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2] Documentation/CodingStyle: Add an example for braces
  2018-03-26 16:32         ` Jonathan Corbet
@ 2018-03-26 16:49           ` Gary R Hook
  -1 siblings, 0 replies; 12+ messages in thread
From: Gary R Hook @ 2018-03-26 16:49 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: Jani Nikula, linux-doc, linux-kernel

On 03/26/2018 11:32 AM, Jonathan Corbet wrote:
> On Mon, 26 Mar 2018 11:28:03 -0500
> Gary R Hook <gary.hook@amd.com> wrote:
> 
>> Submitting a v3 because the example could better illuminate the options
>> by using loop construct inside of an if, addressing Jani's point but
>> without opening the door to later criticism.
>>
>> I also like the verbage in v2/3 better, but I'll let Jonathan make the call.
> 
> As I told you, I was applying the first version; I did that last week.

Forgive me; was out of the office. I've seen maintainers comment but not 
necessarily execute immediately, and therefore I try to learn how each 
works, but here I made an assumption. No worries and sorry to bother.

> 
>> BTW which tree should these be developed against? I used torvalds, but
>> I'm not entirely sure that was the proper one?
> 
> The MAINTAINERS file will (almost) always answer that question for
> you:	
> 
> 	T:	git git://git.lwn.net/linux.git docs-next

Good point. I should know better by now.

Again, thank you.

Gary

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

* Re: [PATCH v2] Documentation/CodingStyle: Add an example for braces
@ 2018-03-26 16:49           ` Gary R Hook
  0 siblings, 0 replies; 12+ messages in thread
From: Gary R Hook @ 2018-03-26 16:49 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: Jani Nikula, linux-doc, linux-kernel

On 03/26/2018 11:32 AM, Jonathan Corbet wrote:
> On Mon, 26 Mar 2018 11:28:03 -0500
> Gary R Hook <gary.hook@amd.com> wrote:
> 
>> Submitting a v3 because the example could better illuminate the options
>> by using loop construct inside of an if, addressing Jani's point but
>> without opening the door to later criticism.
>>
>> I also like the verbage in v2/3 better, but I'll let Jonathan make the call.
> 
> As I told you, I was applying the first version; I did that last week.

Forgive me; was out of the office. I've seen maintainers comment but not 
necessarily execute immediately, and therefore I try to learn how each 
works, but here I made an assumption. No worries and sorry to bother.

> 
>> BTW which tree should these be developed against? I used torvalds, but
>> I'm not entirely sure that was the proper one?
> 
> The MAINTAINERS file will (almost) always answer that question for
> you:	
> 
> 	T:	git git://git.lwn.net/linux.git docs-next

Good point. I should know better by now.

Again, thank you.

Gary
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2018-03-26 16:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-15 20:04 [PATCH v2] Documentation/CodingStyle: Add an example for braces Gary R Hook
2018-03-15 20:04 ` Gary R Hook
2018-03-21 15:17 ` Jonathan Corbet
2018-03-21 15:17   ` Jonathan Corbet
2018-03-22  9:12   ` Jani Nikula
2018-03-22  9:12     ` Jani Nikula
2018-03-26 16:28     ` Gary R Hook
2018-03-26 16:28       ` Gary R Hook
2018-03-26 16:32       ` Jonathan Corbet
2018-03-26 16:32         ` Jonathan Corbet
2018-03-26 16:49         ` Gary R Hook
2018-03-26 16:49           ` Gary R Hook

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.