From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Laszlo Ersek <lersek@redhat.com>
Cc: "Gao, Liming" <liming.gao@intel.com>,
"Zhang, Shenglei" <shenglei.zhang@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
"Dong, Eric" <eric.dong@intel.com>,
"Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH] MdeModulePkg: Remove dead code in .c and .h files
Date: Mon, 6 Aug 2018 17:58:01 +0200 [thread overview]
Message-ID: <CAKv+Gu-77PSpgUhZUNFyEvW8mL91yY2HMpw6bHTmKYK+ODKjAQ@mail.gmail.com> (raw)
In-Reply-To: <0ac435ef-e7f7-127e-a184-9fb8d45155e6@redhat.com>
On 6 August 2018 at 17:37, Laszlo Ersek <lersek@redhat.com> wrote:
> On 08/06/18 16:54, Gao, Liming wrote:
>> Laszlo: We manually search the unused functions in the module source
>> files, and also verify the build to make sure the unused functions are
>> real dead code.
>
> Works for me, but then the commit message should state exactly this.
> Such as:
>
> """
> Remove functions that have external linkage but are never called.
> (We have manually verified that no function removed in this patch is
> ever called.)
> """
>
> Because:
>
> * "Dead code" also means such code that is conditionally reachable (for
> example, there is a conditional call to the function); however deeper
> analysis reveals that the condition can never evaluate to TRUE.
>
> A patch that eliminates code for this case must stand on its own,
> because it needs non-mechanic review. From the commit message it
> wasn't clear whether such changes were in scope, and it was difficult
> to tell from the code (due to the size of the patch).
>
> * "External linkage" is relevant because it highlights that the current
> situation is at least in part the result of tooling limitations.
>
> A large number of functions in MdeModulePkg should be STATIC (= be
> given internal linkage), but they are kept with external linkage
> because some VS debugging tools cannot cope with STATIC functions (to
> my understanding).
>
Could we *please* double check if this is still the case? Is this like
the ELILO thing, where nobody remembers what version exactly needed it
and we keep cargo culting (and duplicating) the fix ad inifitum?
IMO, STATIC is a fundamental part of careful structuring of your code,
and if the tooling cannot cope, it should be fixed.
> In turn, because utility functions are never made STATIC, gcc cannot
> emit warnings when some of those functions are never actually called
> (if they were STATIC, gcc would abort the build with to warnings).
> Obviously this doesn't apply to all utility functions (some may have
> originally been called from multiple source files).
>
next prev parent reply other threads:[~2018-08-06 15:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-06 7:49 [PATCH] MdeModulePkg: Remove dead code in .c and .h files shenglei
2018-08-06 13:11 ` Laszlo Ersek
2018-08-06 14:54 ` Gao, Liming
2018-08-06 15:37 ` Laszlo Ersek
2018-08-06 15:58 ` Ard Biesheuvel [this message]
2018-08-06 17:36 ` Kinney, Michael D
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=CAKv+Gu-77PSpgUhZUNFyEvW8mL91yY2HMpw6bHTmKYK+ODKjAQ@mail.gmail.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