From: Jeff King <peff@peff.net>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] config.mak.dev: enable -Wunused-function
Date: Thu, 18 Oct 2018 13:09:34 -0400 [thread overview]
Message-ID: <20181018170934.GA21138@sigill.intra.peff.net> (raw)
In-Reply-To: <CACsJy8BOL+QOb3Vdh8RKbra-DDbJVyznTbCJgjK5h8L2y0H7yg@mail.gmail.com>
On Thu, Oct 18, 2018 at 05:48:16PM +0200, Duy Nguyen wrote:
> > - conditional compilation, where we may or may not need a
> > static helper. These generally fall into one of two
> > categories:
> >
> > - the call should not be conditional, but rather the
> > function body itself should be (and may just be a
> > no-op on one side of the #if). That keeps the
> > conditional pollution out of the main code.
> >
> > - call-chains of static helpers should all be in the
> > same #if block, so they are all-or-nothing
>
> Grouping is not always desired because it could break better function
> layout. Have a look at read-cache.c where _ieot_extension functions
> are #if'd because the only call sites are from pthread code (#if'd far
> away).
True, though as long as they are triggered by the same set of #if
conditions, that is fine. Putting them in the same block is just an
easy way to make sure that is the case. ;)
> In this particular case though I think we should be able to avoid so
> much #if if we make a wrapper for pthread api that would return an
> error or something when pthread is not available. But similar
> situation may happen elsewhere too.
Yeah, I think that is generally the preferred method anyway, just
because of readability and simplicity.
> Having said that, if people do consider MAYBE_UNUSED before #if'ing
> everywhere (and opening up more conditional build problems in future),
> I think this change is fine.
I'd like to use it as a last resort, certainly. Mostly the fact that we
compile cleanly _now_ makes me think that it probably won't be that hard
to keep it going.
I think the biggest potential problem with this is going to be obscure
configurations where some functions are used or not used. So somebody
silencing a compiler warning may inadvertently break another case if
they're not careful. But that's already a problem to some degree (and
part of why we try to push the conditionality out to the whole-function
level).
-Peff
next prev parent reply other threads:[~2018-10-18 17:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-18 7:05 [PATCH] config.mak.dev: enable -Wunused-function Jeff King
2018-10-18 7:08 ` Jeff King
2018-10-18 15:48 ` Duy Nguyen
2018-10-18 17:09 ` Jeff King [this message]
2018-10-18 18:05 ` [PATCH/RFC] thread-utils: better wrapper to avoid #ifdef NO_PTHREADS Nguyễn Thái Ngọc Duy
2018-10-23 20:28 ` Jeff King
2018-10-24 2:58 ` Junio C Hamano
2018-10-26 14:09 ` Ben Peart
2018-10-27 7:12 ` can we deprecate NO_PTHREADS?, was: " Jeff King
2018-10-27 7:26 ` [PATCH/RFC] thread-utils: " Duy Nguyen
2018-10-27 8:17 ` Jeff King
2018-10-18 17:01 ` [PATCH] config.mak.dev: enable -Wunused-function Ramsay Jones
2018-10-19 1:23 ` Junio C Hamano
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-all 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=20181018170934.GA21138@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).