From: "Michael D Kinney" <michael.d.kinney@intel.com>
To: Ard Biesheuvel <ardb@kernel.org>,
"devel@edk2.groups.io" <devel@edk2.groups.io>,
"Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: "Chang, Abner" <Abner.Chang@amd.com>,
"Ni, Ray" <ray.ni@intel.com>,
"Gao, Liming" <gaoliming@byosoft.com.cn>
Subject: Re: [edk2-devel] [PATCH] edk II C Coding Standard: Remove section 5.4.2.2 STATIC
Date: Mon, 28 Nov 2022 15:41:07 +0000 [thread overview]
Message-ID: <CO1PR11MB4929BD430D55079A0AC85BFBD2139@CO1PR11MB4929.namprd11.prod.outlook.com> (raw)
In-Reply-To: <CAMj1kXH7TxOw5tE=YAFH24+t5ZN2g66+GnrHEf5bPuaOTGEWGg@mail.gmail.com>
Ard,
I agree it should be a strong recommendation for all of these reasons.
There is a patch review for this spec for use of 'static'. Can you
please provide feedback with your recommended content?
Thanks,
Mike
> -----Original Message-----
> From: Ard Biesheuvel <ardb@kernel.org>
> Sent: Monday, November 28, 2022 1:08 AM
> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>
> Cc: Chang, Abner <Abner.Chang@amd.com>; Ni, Ray <ray.ni@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
> Subject: Re: [edk2-devel] [PATCH] edk II C Coding Standard: Remove section 5.4.2.2 STATIC
>
> On Tue, 22 Nov 2022 at 19:10, Michael D Kinney
> <michael.d.kinney@intel.com> wrote:
> >
> > Hi Abner,
> >
> > Removing that section 5.4.2.2 is required to close this bug.
> >
> > Meaning of 'static' is covered by the ANSI C standards.
> >
> > Use of 'static' for non-public variable/functions in EDK II
> > libraries/modules is recommended.
> >
> > However, it is not required. It is recommended to reduce chances
> > of symbol conflicts at link time. Current approach is if a link
> > failure occurs for multiply defined symbols and those are non-public
> > symbols, the 'static' attribute can be applied to the non-public
> > symbols in the components that generated the link failure.
> >
> > It may be good to mention this recommendation in the CSS.
> >
> > I will let you decide when this recommendation needs to be
> > added to CSS.
> >
>
> 'static' is not just a tool to avoid symbol conflicts. It also avoids
> abuse of symbols that are assumed to have a private nature but can be
> linked to nonetheless (e.g., in static libraries). Ideally, any
> library should only export the symbols that it defines as part of its
> interface, although this is not currently feasible of a library
> consists of multiple object files.
>
> Another thing to keep in mind is that static is used by the compiler
> to make inferences about the value. A static global variable can only
> be modified by the code in the same compilation unit, and so the
> compiler is free to optimize accesses or perform constant propagation
> and drop it entirely if it only observes reads and no writes from the
> variable.
>
> I consider it good developer hygiene to always use static on global
> symbols (code and data) unless the symbol needs to be shared with
> other compilation units.
next prev parent reply other threads:[~2022-11-28 15:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 4:47 [PATCH] edk II C Coding Standard: Remove section 5.4.2.2 STATIC Chang, Abner
2022-11-22 5:48 ` [edk2-devel] " Ni, Ray
2022-11-22 6:07 ` Chang, Abner
2022-11-22 16:31 ` Michael D Kinney
2022-11-22 22:12 ` Pedro Falcato
2022-11-22 22:39 ` Michael D Kinney
2022-11-26 7:44 ` Chang, Abner
2022-11-28 9:08 ` Ard Biesheuvel
2022-11-28 15:41 ` Michael D Kinney [this message]
2022-12-12 5:30 ` Chang, Abner
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=CO1PR11MB4929BD430D55079A0AC85BFBD2139@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