public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: "Gao, Liming" <liming.gao@intel.com>,
	"Zhang, Shenglei" <shenglei.zhang@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "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:37:05 +0200	[thread overview]
Message-ID: <0ac435ef-e7f7-127e-a184-9fb8d45155e6@redhat.com> (raw)
In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A14E2C6745@SHSMSX104.ccr.corp.intel.com>

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).

  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).

> I agree to separate this patch as the module level. So, we can
> document which unused functions are removed in the driver.

Thanks -- given the explanation above, I'd be fine with just a commit
message update. Still, if Shenglei has the time, I think that
module-level patching would be far better.

Thanks!
Laszlo


  reply	other threads:[~2018-08-06 15:37 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 [this message]
2018-08-06 15:58       ` Ard Biesheuvel
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=0ac435ef-e7f7-127e-a184-9fb8d45155e6@redhat.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