From: Laszlo Ersek <lersek@redhat.com>
To: edk2-devel-01 <edk2-devel@lists.01.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Jordan Justen <jordan.l.justen@intel.com>,
Leif Lindholm <leif.lindholm@linaro.org>,
Michael D Kinney <michael.d.kinney@intel.com>
Subject: [edk2-CCodingStandardsSpecification PATCH 2/2] Source Files / Spacing / Multi-line func. calls: allow condensed arguments
Date: Fri, 11 Aug 2017 18:48:51 +0200 [thread overview]
Message-ID: <20170811164851.9466-3-lersek@redhat.com> (raw)
In-Reply-To: <20170811164851.9466-1-lersek@redhat.com>
The "one argument per line" style as the sole possibility takes up too
much vertical space, wastes perfectly good horizontal space, and causes a
constant jump-to-the-left eye movement for the reader.
Now that we have limited the line length to 80 colums, the "condensed
arguments" style cannot be abused; permit it.
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
5_source_files/52_spacing.md | 29 +++++++++++++++++++-
README.md | 1 +
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/5_source_files/52_spacing.md b/5_source_files/52_spacing.md
index ddeabf7753a8..fc8a5e7e58e7 100644
--- a/5_source_files/52_spacing.md
+++ b/5_source_files/52_spacing.md
@@ -133,7 +133,9 @@ If ((--MyInteger) > 0) {
#### 5.2.2.4 Subsequent lines of multi-line function calls should line up two spaces from the beginning of the function name
If a function call or function like macro invocation is broken up into multiple
-lines, then:
+lines, then follow one of the alternatives below.
+
+##### 5.2.2.4.1 The "one argument per line" style
* One argument per line, including the first argument on its own line.
* Indent each argument 2 spaces from the start of the function name. If a
@@ -165,6 +167,31 @@ DEBUG ((
));
```
+Use this line breaking style especially if it saves a format string or complex
+argument from being split, or when commenting on individual arguments.
+
+##### 5.2.2.4.2 The "condensed arguments" style
+
+For most function calls and function-like macro invocations, the "one argument
+per line" style uses up valuable vertical space without utilizing readily
+available horizontal space. Such statements are permitted to condense the
+arguments and the closing parenthesis (or parentheses), up to the allowed line
+length. The indentation requirements are identical to those of the "one
+argument per line" style.
+
+```c
+CopyMem (Destination, Source, SIZE_4KB);
+
+Status = gBS->AllocatePool (EfiBootServicesData, sizeof (DRIVER_NAME_INSTANCE),
+ &PrivateData);
+
+DEBUG ((DEBUG_INFO, "The addresses of the 4 buffers are %p, %p, %p, and %p\n",
+ Buffer1, Buffer2, Buffer3, Buffer4));
+```
+
+This line breaking style prevents overly frequent saccades to the left, without
+resulting in overlong lines.
+
#### 5.2.2.5 Always put space after commas or semicolons that separate items
This punctuation is not necessary if no code or comments follow the comma or
diff --git a/README.md b/README.md
index 8fad5a327b8c..437024e57677 100644
--- a/README.md
+++ b/README.md
@@ -113,3 +113,4 @@ Copyright (c) 2006-2017, Intel Corporation. All rights reserved.
| 2.2 | Convert to Gitbook | June 2017 |
| | [#425](https://bugzilla.tianocore.org/show_bug.cgi?id=425) [CCS] clarify line breaking and indentation requirements for multi-line function calls | |
| | Limit lines to 80 columns | |
+| | Introduce the "condensed arguments" line breaking style | |
--
2.13.1.3.g8be5a757fa67
next prev parent reply other threads:[~2017-08-11 16:46 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-11 16:48 [edk2-CCodingStandardsSpecification PATCH 0/2] improvements related to line wrapping Laszlo Ersek
2017-08-11 16:48 ` [edk2-CCodingStandardsSpecification PATCH 1/2] Source Files / General Rules: limit line lengths to 80 columns Laszlo Ersek
2017-08-11 20:52 ` Jordan Justen
2017-08-11 21:01 ` Kinney, Michael D
2017-08-11 22:52 ` Ard Biesheuvel
2017-08-12 2:39 ` Jordan Justen
2017-08-12 10:03 ` Leif Lindholm
2017-08-15 10:57 ` Laszlo Ersek
2022-11-13 1:25 ` [edk2-devel] " Chang, Abner
2022-11-13 1:59 ` Michael D Kinney
2022-11-13 8:47 ` Chang, Abner
2017-08-11 16:48 ` Laszlo Ersek [this message]
2017-08-11 20:45 ` [edk2-CCodingStandardsSpecification PATCH 2/2] Source Files / Spacing / Multi-line func. calls: allow condensed arguments Jordan Justen
2017-08-11 21:04 ` Kinney, Michael D
2017-08-12 1:31 ` Jordan Justen
2017-08-11 21:05 ` Andrew Fish
2017-08-12 10:13 ` Leif Lindholm
2017-08-15 11:16 ` Laszlo Ersek
2022-11-13 1:35 ` [edk2-devel] " Chang, Abner
2022-11-13 1:57 ` Michael D Kinney
2022-11-13 8:44 ` Chang, Abner
2022-11-13 17:36 ` Michael D Kinney
2022-11-14 1:09 ` Chang, Abner
2022-11-14 17:07 ` Michael D Kinney
2022-11-14 17:37 ` Michael Kubacki
[not found] ` <17278424C4A5D78F.32003@groups.io>
2022-11-14 18:05 ` Michael Kubacki
2022-11-14 18:25 ` Michael D Kinney
2022-11-14 18:49 ` Michael Kubacki
2022-11-14 18:59 ` Michael D Kinney
2022-11-14 19:08 ` Sean
2022-11-15 2:38 ` Chang, Abner
2017-08-11 17:07 ` [edk2-CCodingStandardsSpecification PATCH 0/2] improvements related to line wrapping Kinney, Michael D
2017-08-15 11:01 ` Laszlo Ersek
2017-08-15 15:17 ` Kinney, Michael D
2017-08-15 16:17 ` Laszlo Ersek
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-list 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=20170811164851.9466-3-lersek@redhat.com \
--to=devel@edk2.groups.io \
/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