[edk2-devel] [edk2-CCodingStandardsSpecification PATCH 1/1] Update Chapter 5 Source Files examples to follow the coding standard

Michael D Kinney michael.d.kinney at intel.com
Fri Dec 11 19:40:43 UTC 2020


Pushed

https://github.com/tianocore-docs/edk2-CCodingStandardsSpecification/commit/3edad55bd06c99abc318e7716cad6ce45ee2636a


> -----Original Message-----
> From: Kinney, Michael D <michael.d.kinney at intel.com>
> Sent: Tuesday, December 8, 2020 1:46 PM
> To: devel at edk2.groups.io; rebecca at nuviainc.com; Kinney, Michael D <michael.d.kinney at intel.com>
> Cc: Leif Lindholm <leif at nuviainc.com>; Laszlo Ersek <lersek at redhat.com>; Andrew Fish <afish at apple.com>
> Subject: RE: [edk2-devel] [edk2-CCodingStandardsSpecification PATCH 1/1] Update Chapter 5 Source Files examples to follow
> the coding standard
> 
> Reviewed-by: Michael D Kinney <michael.d.kinney at intel.com>
> 
> Mike
> 
> > -----Original Message-----
> > From: devel at edk2.groups.io <devel at edk2.groups.io> On Behalf Of Rebecca Cran
> > Sent: Tuesday, December 8, 2020 4:27 AM
> > To: devel at edk2.groups.io
> > Cc: Rebecca Cran <rebecca at nuviainc.com>; Kinney, Michael D <michael.d.kinney at intel.com>; Leif Lindholm
> > <leif at nuviainc.com>; Laszlo Ersek <lersek at redhat.com>; Andrew Fish <afish at 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 at 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
> >
> >
> >
> > 
> >



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#68722): https://edk2.groups.io/g/devel/message/68722
Mute This Topic: https://groups.io/mt/78805254/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list