git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Denton Liu <liu.denton@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [RFC PATCH] Makefile: create externcheck target
Date: Thu, 08 Oct 2020 19:45:09 -0700	[thread overview]
Message-ID: <xmqqy2kgungq.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: 1c2ee1c40ccde18a008262aeaf23a17da2064eae.1602142232.git.liu.denton@gmail.com

Denton Liu <liu.denton@gmail.com> writes:

> +externcheck: $(filter-out $(THIRD_PARTY_SOURCES),$(filter %.c %.h,$(shell $(FIND_SOURCE_FILES))))
> +	sed -i 's/^\(\s*\)extern \([^(]*([^*]\)/\1\2/' $^

I am not enthused by this particular patch for a few reasons, and I
am moderately negative on the whole idea.

 - We don't aim to support "only GNU and some BSD"; let's not do
   "-i" which as far as I know is used only in config.mak.uname for
   vcxproj target (which is OK as we know that is run only on a very
   narrow target, but probably is a bad idea as it would be another
   source of copy-and-paste for those who do not even think why it
   is acceptable there but not in all other places).

 - Same for \s.  If it is easy enough to write [        ]*, why
   risk breaking for somebody you don't even know?

 - The initial [^*] may be an attempt to avoid triggering on a
   global pointer-to-function, but doesn't it also make the pattern
   fail to trigger on a global function whose return type is a
   pointer-to-function?

 - If this is a "check" target, we shouldn't apply a wholesale
   transformation that is potentially buggy to user's files.  Using
   "grep" to just point out the places where your opinion differ
   from user's (and to fail the "make foocheck" operation) would be
   more appropriate.

Quite honestly, I suspect that the "push" that b199d714 (*.[ch]:
remove extern from function declarations using sed, 2019-04-29)
talks about was misguided in the first place.

Sure, we can write these external function declarations without
'extern' in front, because the language allows it and without
'static' in front, it by default is 'extern'.  It however does
not automatically mean we _should_ drop 'extern'.

Sure, for function decls, it may not make a difference to have or
not have "extern" in front, but for decls of data (including
pointers to functions), it makes a whole lot of difference.  Not
standardising to the rule "our external declarations always are
marked with leading 'extern', regardless of the type of the
identifier being declared" forces us to spend our brain cycles to
think if we should or should not write 'extern' in front.  And is
that a good thing to spend our brain cycles on, or just waste of our
effort?  I am moderately in favor of saying that it is a waste.

In addition, seeing these 'extern ' in header files will train our
eyes to spot the same in the source files more easily.  External
decls in the source (as opposed to inclusion of a header that does
the decls) can happen but they ought to be exceptions and it is good
to make them stand out.

      parent reply	other threads:[~2020-10-09  2:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07  8:31 [PATCH] compat/mingw.h: drop extern from function declaration Denton Liu
2020-10-07  6:44 ` Johannes Schindelin
2020-10-08  7:30 ` [RFC PATCH] Makefile: create externcheck target Denton Liu
2020-10-08  9:32   ` Johannes Schindelin
2020-10-08  9:52     ` Denton Liu
2020-10-08 14:26       ` Johannes Schindelin
2020-10-09  2:45   ` Junio C Hamano [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqy2kgungq.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=liu.denton@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).