From: "Michael D Kinney" <michael.d.kinney@intel.com>
To: Oliver Smith-Denny <osde@linux.microsoft.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>,
"pedro.falcato@gmail.com" <pedro.falcato@gmail.com>
Cc: "rebecca@bsdio.com" <rebecca@bsdio.com>,
"Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [edk2-CCodingStandardsSpecification PATCH 1/1] Prefer use of `static` C keyword over EDK2 type `STATIC`
Date: Mon, 21 Oct 2024 20:35:28 +0000 [thread overview]
Message-ID: <CO1PR11MB4929E48A471FEB464E5AD75DD2432@CO1PR11MB4929.namprd11.prod.outlook.com> (raw)
In-Reply-To: <5a0d2a4f-a423-4ef3-a07b-18e69e7d1241@linux.microsoft.com>
Would it help if code was modified to completely remove the use of
static in local variables and enforce that going forward and limit
use of static to functions and global variables?
Mike
> -----Original Message-----
> From: Oliver Smith-Denny <osde@linux.microsoft.com>
> Sent: Monday, October 21, 2024 1:26 PM
> To: devel@edk2.groups.io; pedro.falcato@gmail.com
> Cc: rebecca@bsdio.com; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: Re: [edk2-devel] [edk2-CCodingStandardsSpecification PATCH 1/1]
> Prefer use of `static` C keyword over EDK2 type `STATIC`
>
> On 10/21/2024 1:21 PM, Pedro Falcato wrote:
> > On Mon, Oct 21, 2024 at 9:05 PM Oliver Smith-Denny
> > <osde@linux.microsoft.com> wrote:
> >>
> >> On 10/21/2024 12:42 PM, Pedro Falcato wrote:
> >>> On Mon, Oct 21, 2024 at 3:49 PM Rebecca Cran via groups.io
> >>> <rebecca=bsdio.com@groups.io> wrote:
> >>>>
> >>>> Thanks, I'll fix it.
> >>>>
> >>>> Could you confirm whether the change from STATIC to static is
> something
> >>>> we want to go ahead with, or do we want to keep STATIC to allow
> >>>> GoogleTest to work?
> >>>
> >>> You don't need STATIC, doing stuff like -Dstatic= (or just #define
> >>> static in C code) Just Works. For GCC at least.
> >>>
> >>> proof of horribleness: https://godbolt.org/z/EvMd6hev8
> >>>
> >>
> >> The issue here is that C uses one keyword for two distinct things:
> >> file private members and local variables that keep state across
> calls,
> >> i.e. real static variables.
> >
> > That's an interesting problem, but I'm afraid the current EDK2 coding
> > style would recommend STATIC for local variables too.
> >
> > https://tianocore-docs.github.io/edk2-
> CCodingStandardsSpecification/release-
> 2.20/5_source_files/56_declarations_and_types.html#56-declarations-and-
> types
> > says:
> >
> > 5.6.1.2 The use of int, unsigned, char, void, static, long is a
> > violation of the coding convention.
> >
> > so:
> >
> > INT Foo()
> > {
> > STATIC INT Variable = 0;
> > return Variable++;
> > }
> >
> > would be the sanctioned way to pull off this kind of stuff. So STATIC
> > gains us nothing (neither does INT, LONG, CHAR, VOID, or CONST).
> >
>
> Yeah, so what we did in Mu was leverage the fact that static locals are
> relatively uncommon and code coverage is extremely low, so that there
> was only one current instance of a static local under test. And we
> changed that to lowercase static. So now STATIC bought us that we
> could undef it when building HOST_APPLICATIONs.
>
> Was I happy with that approach? No. But, we were trying to evaluate
> the usefulness of GoogleTest and this was one issue that had to be
> fixed in order for us to use it.
>
> Oliver
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120641): https://edk2.groups.io/g/devel/message/120641
Mute This Topic: https://groups.io/mt/108941574/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-10-21 20:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-11 1:20 [edk2-devel] [edk2-CCodingStandardsSpecification PATCH 1/1] Prefer use of `static` C keyword over EDK2 type `STATIC` Rebecca Cran
2024-10-11 3:41 ` Sean
2024-10-11 16:47 ` Rebecca Cran
2024-10-14 15:22 ` Oliver Smith-Denny
2024-10-14 16:47 ` Rebecca Cran
2024-10-14 17:09 ` Oliver Smith-Denny
2024-10-15 21:12 ` Michael D Kinney
2024-10-21 14:49 ` Rebecca Cran
2024-10-21 15:46 ` Michael D Kinney
2024-10-21 19:42 ` Pedro Falcato
2024-10-21 20:05 ` Oliver Smith-Denny
2024-10-21 20:21 ` Pedro Falcato
2024-10-21 20:26 ` Oliver Smith-Denny
2024-10-21 20:35 ` Michael D Kinney [this message]
2024-10-21 20:37 ` Oliver Smith-Denny
2024-10-21 21:04 ` Michael D Kinney
2024-10-21 21:11 ` Pedro Falcato
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=CO1PR11MB4929E48A471FEB464E5AD75DD2432@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