public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Michael D Kinney" <michael.d.kinney@intel.com>
To: Leif Lindholm <leif@nuviainc.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>,
	"mikuback@linux.microsoft.com" <mikuback@linux.microsoft.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: "mhaeuser@posteo.de" <mhaeuser@posteo.de>,
	"rebecca@nuviainc.com" <rebecca@nuviainc.com>,
	Michael Kubacki <Michael.Kubacki@microsoft.com>,
	"Bret Barkelew" <Bret.Barkelew@microsoft.com>
Subject: Re: [edk2-devel] Progress on getting Uncrustify working for EDK2?
Date: Thu, 7 Oct 2021 17:05:23 +0000	[thread overview]
Message-ID: <CO1PR11MB492961E50915FFEF0280B212D2B19@CO1PR11MB4929.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20211007104813.wa4rmfsqgcpvnzwt@leviathan>

Hi Leif,

Thanks for the feedback.  Adjusting the EDK II C Coding Style should absolutely
be part of this discussion.  We need to work towards specific proposals.  Here are
the current open bugs against the EDK II C Coding Style.  Please update or add new 
for the changes you are suggesting.

https://bugzilla.tianocore.org/buglist.cgi?bug_status=UNCONFIRMED&bug_status=CONFIRMED&bug_status=IN_PROGRESS&columnlist=product%2Ccomponent%2Cshort_desc%2Creporter&component=Documentation&f1=cf_documents&list_id=23944&o1=equals&product=EDK2&query_format=advanced&resolution=---&v1=EDK%20II%20C%20Coding%20Standards

  2664  Discrepancies/inconsistencies in coding standards, style and examples 
  1698  Spurious rule about comment style in CCS 6.2.3 
  713   Update EDK II C Coding standard to state a stronger preference for 80 column line widths 
  714   Update EDK II C Coding Standards to allow multiple arguments per line in a function call 
  1766  Remove use of STATIC macros from EDK II C Coding Standard Specification 
  2391  Dangling word at end of Section 5.1.9 In-line assembler shall not be used
  723   5.1.8 Typo provided should be proven 
  884   The cover.jpg file for the EDK II specs has the old style logo 
  839   Minor typographical errors 

Additional comments below.

Thanks,

Mike

> -----Original Message-----
> From: Leif Lindholm <leif@nuviainc.com>
> Sent: Thursday, October 7, 2021 3:48 AM
> To: devel@edk2.groups.io; mikuback@linux.microsoft.com
> Cc: mhaeuser@posteo.de; rebecca@nuviainc.com; Michael Kubacki <Michael.Kubacki@microsoft.com>; Bret Barkelew
> <Bret.Barkelew@microsoft.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: Re: [edk2-devel] Progress on getting Uncrustify working for EDK2?
> 
> Hi Michael,
> 
> Apologies, I've owed you a response (promised off-list) for a while
> now.
> 
> First, let me say I hugely appreciate this effort. Apart from aligning
> the codebase(s), this will reduce manual reviewing effort
> substantially, as well as cutting down on number of rework cycles for
> developers.
> 
> Looking at the changes to (well, the comments in) uncrustify, this
> seems to be constrained to:
> - Newline after '(' for multi-line function calls.
> - Dealing with "(("/"))" for DEBUG macros.
> - Function pointer typedefs:
>   - typedef\nEFIAPI
>   - closing parentheses indentation
> 
> I don't think I've made any secret over the years that I am not a
> massive fan of the EDK2 coding style in general. So I think for any
> of its quirks that are substantial enough that they require not just
> custom configuration but actual new function added to existing code
> conformance tools, this would be an excellent point to sanitise the
> coding style instead.
> 
> Taking these in order:
> 
> Newline after '('
> -----------------
> I think we already reached a level of flexibility around this, where
> we don't actually enforce this (or single argument per
> line). Personally, I'd be happy to update the coding style as
> required instead.


Here is an example of a change that uncrustify did that I think you
are suggesting is not required with support for multiple params
per line.  Correct?

Before Uncristify
=================
  AsmCpuidEx (
    CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_SUB_LEAF,
    &Eax.Uint32, &Ebx, &Ecx.Uint32, &Edx
    );

After Uncristify
=================
  AsmCpuidEx (
    CPUID_EXTENDED_STATE,
    CPUID_EXTENDED_STATE_SUB_LEAF,
    &Eax.Uint32,
    &Ebx,
    &Ecx.Uint32,
    &Edx
    );

Here is the BZ on the topic.

https://bugzilla.tianocore.org/show_bug.cgi?id=714

I think you are suggesting that a 4th style may be allowed
which would be to support arguments in the same line as
the function name and additional arguments on additional
lines.  Do you want to update this BZ with your additional
thoughts?

> 
> DEBUG macro parentheses
> -----------------------
> How does uncrustify treat DEBUG macros without this modification?
> Do we start getting everything turned into multi-level indented
> multi-line statements without this change?

I think this is related to the DEBUG() macro using double (( and double ))
parens.

> 
> Function pointer typedefs:
> --------------------------
> I don't see that function pointer typedefs need to rigidly follow the
> same pattern as the declaration of functions implementing them. Could
> we update the coding style (if needed) instead?

I know one issue with function pointer typedefs is making sure the format
is compatible with Doxygen document generation.  

    https://github.com/tianocore/edk2/tree/master/BaseTools/Scripts/PackageDocumentTools

> 
> Best Regards,
> 
> Leif
> 
> On Mon, Aug 16, 2021 at 16:00:38 -0400, Michael Kubacki wrote:
> > The edk2 branch was created here:
> > https://github.com/makubacki/edk2/tree/uncrustify_poc_2
> >
> > We have a Project Mu fork with custom changes to the Uncrustify tool to help
> > comply with EDK II formatting here:
> > https://dev.azure.com/projectmu/_git/Uncrustify
> >
> > The latest information about the status and how to experiment with the
> > configuration file and the tool are in that fork:
> https://dev.azure.com/projectmu/Uncrustify/_wiki/wikis/Uncrustify.wiki/1/Project-Mu-(EDK-II)-Fork-Readme
> >
> > That said, I have also finished a CI plugin to run Uncrustify that should be
> > ready soon to initially deploy in Project Mu. Before doing so, I am trying
> > to settle on an initial configuration file that less strictly but more
> > reliably formats the code than in the examples in those branches. For
> > example, remove heuristics that when run against the same set of code
> > multiple times can produce different results. An example would be a rule
> > that reformats code because it exceeds a specified column width on one run
> > but on the next run that reformatted code triggers a different rule to
> > further align the code and so on. At least initially, some rules might be
> > tweaked in a more conservative approach that can be tightened in the future.
> > Once this configuration file is ready, we will baseline Project Mu code as
> > an example and turn on the plugin. The CI plugin runs Uncrustify against
> > modified files and if there's any changes, indicating a formatting
> > deviation, the diff chunks are saved in a log so they can be viewed as a
> > build artifact.
> >
> > I am making progress on the updated config file and I should be able to post
> > a "uncrustify_poc_3" branch soon with the results.
> >
> > Regarding indentation, Marvin is right that Uncrustify cannot support edk2
> > indentation style out-of-box. Some changes are made in that fork to handle
> > the formatting. At this point, it can handle the indentation in the cases
> > I've seen. Uncrustify does potentially give us the ability to massively
> > deploy changes across the codebase in case a decision were made to change
> > the style.
> >
> > Thanks,
> > Michael
> >
> > On 8/16/2021 3:39 PM, Marvin Häuser wrote:
> > > Hey Rebecca,
> > >
> > > I think even Uncrustify has issues with the EDK II indentation style.
> > > You might want to check the UEFI Talkbox Discord server, I had a brief
> > > chat with Michael about it there. I don't think realistically any tool
> > > supports EDK II's indentation style however, so I'd propose it is
> > > changed. This could be for new submissions only, or actually the entire
> > > codebase could be reformatted at once with a good tool setup. While this
> > > screws with git blame, the (to my understanding) decided on CRLF -> LF
> > > change does that anyway, so at least two evils could be dealt with in
> > > one go really.
> > >
> > > Best regards,
> > > Marvin
> > >
> > > On 16/08/2021 21:34, Rebecca Cran wrote:
> > > >
> > > > cc devel@ .
> > > >
> > > > On 8/16/21 1:33 PM, Rebecca Cran wrote:
> > > > >
> > > > > I noticed a message on Twitter about an idea of using Uncrustify
> > > > > for EDK2 instead of the ECC tool, and came across https://www.mail-
> archive.com/search?l=devel@edk2.groups.io&q=subject:%22Re%5C%3A+%5C%5Bedk2%5C-
> devel%5C%5D+TianoCore+Community+Meeting+Minutes+%5C-+2%5C%2F4%22&o=newest&f=1
> > > > > .
> > > > >
> > > > > I was wondering if there's been any progress on it that I could
> > > > > check out?
> > > > >
> > > > >
> > > > > Michael Kubacki: in that message, you said:
> > > > >
> > > > > "I'm planning to put up a branch that we can use as a reference
> > > > > for a conversation around uncrustify in the next couple of
> > > > > weeks."
> > > > >
> > > > >
> > > > > Did you end up creating that branch, and if so could you provide
> > > > > a link to it please?
> > > > >
> > > > >
> > > > > --
> > > > > Rebecca Cran
> > > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> > 
> >
> >

  parent reply	other threads:[~2021-10-07 17:06 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <e15cf895-03a4-96cd-2754-d1cfeead6b98@nuviainc.com>
2021-08-16 19:34 ` Progress on getting Uncrustify working for EDK2? Rebecca Cran
2021-08-16 19:39   ` [edk2-devel] " Marvin Häuser
2021-08-16 20:00     ` Michael Kubacki
2021-10-07 10:48       ` Leif Lindholm
2021-10-07 15:30         ` Andrew Fish
     [not found]         ` <16ABC94F0E9D1AC5.21629@groups.io>
2021-10-07 16:03           ` Andrew Fish
2021-10-07 16:34             ` Michael D Kinney
2021-10-07 17:01               ` Michael Kubacki
2021-10-07 17:05         ` Michael D Kinney [this message]
2021-10-07 18:30         ` Marvin Häuser
2021-10-07 17:19           ` Michael D Kinney
2021-10-07 17:36             ` Andrew Fish
2021-10-07 17:43               ` Marvin Häuser
2021-10-07 21:09                 ` Andrew Fish
2021-11-09  0:23                   ` Michael D Kinney
2021-11-09  1:09                     ` Andrew Fish
2021-11-09  1:13                       ` Michael D Kinney
2021-11-09  2:46                         ` Andrew Fish
2021-11-09  3:02                           ` Michael D Kinney
2021-11-09  7:32                             ` Marvin Häuser
2021-11-09 15:43                               ` Michael D Kinney
2021-11-09 16:12                                 ` Marvin Häuser
2021-11-09 16:33                                   ` Michael D Kinney
2021-11-09 20:55                                     ` Leif Lindholm
2021-11-09 21:20                                       ` Michael D Kinney
2021-11-09 23:23                                         ` Leif Lindholm
2021-11-10 10:12                                   ` Gerd Hoffmann
2021-11-09  1:12                     ` 回复: " gaoliming
2021-11-09 15:22                       ` Michael D Kinney
2021-11-09  8:40                     ` Gerd Hoffmann
2021-11-09 11:56                       ` Michael Brown
2021-11-09 12:36                       ` Leif Lindholm
2021-11-09 14:10                         ` Gerd Hoffmann
2021-11-09 15:44                           ` Michael D Kinney
2021-11-10 15:38                             ` Michael Kubacki
2021-11-09 15:08                         ` Michael D Kinney
2021-11-09 18:13                           ` Andrew Fish
2021-11-09 18:26                             ` Michael D Kinney
2021-11-09 18:52                               ` Andrew Fish

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=CO1PR11MB492961E50915FFEF0280B212D2B19@CO1PR11MB4929.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