From: "Michael D Kinney" <michael.d.kinney@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"rebecca@nuviainc.com" <rebecca@nuviainc.com>,
"Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: Leif Lindholm <leif@nuviainc.com>,
Laszlo Ersek <lersek@redhat.com>, Andrew Fish <afish@apple.com>
Subject: Re: [edk2-devel] [edk2-CCodingStandardsSpecification PATCH 1/1] Update Chapter 5 Source Files examples to follow the coding standard
Date: Tue, 8 Dec 2020 21:46:05 +0000 [thread overview]
Message-ID: <BL0PR11MB32362D3A06FB1BA1257BC51FD2CD0@BL0PR11MB3236.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20201208122638.4916-1-rebecca@nuviainc.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Mike
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> Sent: Tuesday, December 8, 2020 4:27 AM
> To: devel@edk2.groups.io
> Cc: Rebecca Cran <rebecca@nuviainc.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Leif Lindholm
> <leif@nuviainc.com>; Laszlo Ersek <lersek@redhat.com>; Andrew Fish <afish@apple.com>
> Subject: [edk2-devel] [edk2-CCodingStandardsSpecification PATCH 1/1] Update Chapter 5 Source Files examples to follow the
> coding standard
>
> There shouldn't be a space after an opening parenthesis, or around
> unary operators.
>
> There should be a space before a opening parenthesis and around binary
> operators.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
> ---
> 5_source_files/52_spacing.md | 8 ++++----
> 5_source_files/54_code_file_structure.md | 8 ++++----
> 5_source_files/55_preprocessor_directives.md | 14 +++++++-------
> 5_source_files/57_c_programming.md | 6 +++---
> 4 files changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/5_source_files/52_spacing.md b/5_source_files/52_spacing.md
> index fca0044a148b..9a97466f1d61 100644
> --- a/5_source_files/52_spacing.md
> +++ b/5_source_files/52_spacing.md
> @@ -103,10 +103,10 @@ by && or || must have each sub-expression on a separate line. The opening brace,
> column of the associated keyword.
>
> ```c
> -while ( ( Code == MEETS_STANDARD)
> - && ( Code == FUNCTIONAL))
> +while ((Code == MEETS_STANDARD)
> + && (Code == FUNCTIONAL))
> {
> - ShipIt();
> + ShipIt ();
> }
> ```
>
> @@ -220,7 +220,7 @@ This is not the case. The bitwise OR operator, '`|`', has lower precedence than
> the equality operator, '`==`'. This results in the expression being evaluated as
> if one had entered:
> ```
> -8 | ( 8 == 8 )
> +8 | (8 == 8)
> ```
>
> This evaluates to the value 9.
> diff --git a/5_source_files/54_code_file_structure.md b/5_source_files/54_code_file_structure.md
> index caaeab94b68e..0c4d6a26820c 100644
> --- a/5_source_files/54_code_file_structure.md
> +++ b/5_source_files/54_code_file_structure.md
> @@ -151,12 +151,12 @@ and hide each other. Never write code that does this.
> 7 {
> 8 UINT32 i;
> 9
> -10 for ( i = 0; i < 5; ++i) {
> +10 for (i = 0; i < 5; ++i) {
> 11 UCHAR8 MyVar = i; // Block scope
> 12 INT16 i = 12;
> 13
> 14 MyVar += 'A';
> -15 process ( MyVar, i);
> +15 process (MyVar, i);
> 16 }
> 17 *MyVar = i;
> 18 }
> @@ -165,8 +165,8 @@ and hide each other. Never write code that does this.
> 21 {
> 22 UINT32 George = 4;
> 23
> -24 MyFunction ( &George);
> -25 process ( MyVar, 0);
> +24 MyFunction (&George);
> +25 process (MyVar, 0);
> 26 }
> 27
> ```
> diff --git a/5_source_files/55_preprocessor_directives.md b/5_source_files/55_preprocessor_directives.md
> index 98839f6677a8..3075285b7e31 100644
> --- a/5_source_files/55_preprocessor_directives.md
> +++ b/5_source_files/55_preprocessor_directives.md
> @@ -77,8 +77,8 @@ An order-of-precedence bug in a macro is very hard to debug. The following are
> examples of macro construction:
>
> ```
> -#define BAD_MACRO(a, b) a*b
> -#define GOOD_MACRO(a, b) ((a)*(b))
> +#define BAD_MACRO(a, b) a * b
> +#define GOOD_MACRO(a, b) ((a) * (b))
> ```
>
> The following examples should explain the difference between `BAD_MACRO ()` and
> @@ -86,9 +86,9 @@ The following examples should explain the difference between `BAD_MACRO ()` and
>
> * `BAD_MACRO (10, 2)` and `GOOD_MACRO (10, 2)` both evaluate to 20.
>
> -* `BAD_MACRO (7+3, 2)` returns 13 = 7 + (3*2).
> +* `BAD_MACRO (7 + 3, 2)` returns 13 = 7 + (3 * 2).
>
> -* `GOOD_MACRO (7+3, 2)` returns 20.
> +* `GOOD_MACRO (7 + 3, 2)` returns 20.
>
> Also, consider the following expression:
>
> @@ -102,7 +102,7 @@ the equality operator, '`==`'. This results in the expression being evaluated as
> if one had entered:
>
> ```
> -8 | ( 8 == 8 )
> +8 | (8 == 8)
> ```
>
> This evaluates to the value 9 The desired result of `TRUE`, (1), can be achieved
> @@ -123,7 +123,7 @@ or a simple substitution macro.
> Failure to do this will cause the build to break.
>
> ```
> -#define GOOD_MACRO(a, b) ((a)*(b))
> +#define GOOD_MACRO(a, b) ((a) * (b))
> ```
>
> This is because the compiler has no way to differentiate between
> @@ -146,7 +146,7 @@ Failure to separate macro names from parameters negatively impacts readability
> and consistency with other coding style rules.
>
> ```
> -GOOD_MACRO (7+3, 2)
> +GOOD_MACRO (7 + 3, 2)
> ```
>
> #### 5.5.2.7 Single-line Functions
> diff --git a/5_source_files/57_c_programming.md b/5_source_files/57_c_programming.md
> index 8b9db584eea7..a167f925536f 100644
> --- a/5_source_files/57_c_programming.md
> +++ b/5_source_files/57_c_programming.md
> @@ -259,7 +259,7 @@ Module parameters of a PERF_END invocation.
>
> ```c
> for (Index = 0; Index < NumberOfEntries; Index++) {
> - if (( LogEntryArray[Index].Handle == (EFI_PHYSICAL_ADDRESS)(UINTN) Handle)
> + if ((LogEntryArray[Index].Handle == (EFI_PHYSICAL_ADDRESS)(UINTN) Handle)
> && AsciiStrnCmp (LogEntryArray[Index].Token, Token, PEI_PERFORMANCE_STRING_LENGTH) == 0
> && AsciiStrnCmp (LogEntryArray[Index].Module, Module, PEI_PERFORMANCE_STRING_LENGTH) == 0
> && LogEntryArray[Index].EndTimeStamp == 0
> @@ -301,7 +301,7 @@ Re-ordering the predicate expression using this information produces:
>
> ```c
> for (Index = 0; Index < NumberOfEntries; Index++) {
> - if ( LogEntryArray[Index].EndTimeStamp == 0
> + if (LogEntryArray[Index].EndTimeStamp == 0
> && LogEntryArray[Index].Handle == (EFI_PHYSICAL_ADDRESS)(UINTN) Handle
> && AsciiStrnCmp (LogEntryArray[Index].Module, Module, PEI_PERFORMANCE_STRING_LENGTH) == 0
> && AsciiStrnCmp (LogEntryArray[Index].Token, Token, PEI_PERFORMANCE_STRING_LENGTH) == 0
> @@ -495,7 +495,7 @@ a `goto`.
>
> ```c
> Status = IAmTheCode ();
> -if (! EFI_ERROR (Status)) {
> +if (!EFI_ERROR (Status)) {
> IDoTheWork ();
> }
> return Status;
> --
> 2.26.2
>
>
>
>
>
next prev parent reply other threads:[~2020-12-08 21:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-08 12:26 [edk2-CCodingStandardsSpecification PATCH 1/1] Update Chapter 5 Source Files examples to follow the coding standard Rebecca Cran
2020-12-08 21:46 ` Michael D Kinney [this message]
2020-12-11 19:40 ` [edk2-devel] " Michael D Kinney
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=BL0PR11MB32362D3A06FB1BA1257BC51FD2CD0@BL0PR11MB3236.namprd11.prod.outlook.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