git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 01/13] packfile.h: drop extern from function declarations

From
Jeff King <peff@peff.net>
Date
Apr 8, 2019, 20:32 UTC
Message-ID
<20190408203252.GA5696@sigill.intra.peff.net>
In-Reply-To
<xmqqzhp19j0y.fsf@gitster-ct.c.googlers.com>
On Mon, Apr 08, 2019 at 02:13:17PM +0900, Junio C Hamano wrote:
Show 23 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > On Fri, Apr 05, 2019 at 08:19:30PM +0100, Ramsay Jones wrote:
> >
> >> >  /* global flag to enable extra checks when accessing packed objects */
> >> > -extern int do_check_packed_object_crc;
> >> > +int do_check_packed_object_crc;
> >> 
> >> ... removing this 'extern' on an int variable sends 'sparse'
> >> into a frenzy of warnings! :-D
> >> 
> >> [You didn't use a global s/extern// by any chance?]
> >
> > Oh my. I did look at each one, but probably via replace-and-confirm in
> > vim. I don't know how I managed to botch that one so badly.
> 
> Perhaps we should keep 'extern' even when declaring (not defining) a
> public function in the header file to avoid a gotcha like this?
> 
> What was the reasoning behind the insn in CodingGuidelines?  "As it
> is already the default" does qualify as a reasonable justification
> for telling "extern is not needed for functions" to our readers, but
> not quite enough for "extern should not be used for functions".

I think the reasoning is just that it's useless noise, so it makes the resulting lines longer (which are often already too-long) and harder to read.

For this particular patch, I don't care that much about the existing functions, which I'm not touching, but rather was adding a new one. And my options were:

  - use "extern" there to match; even if we don't want to go through the
    code churn of cleaning up existing cases, I think we shouldn't be
    encouraging it in new ones. Even more crazy to me would actually
    be review telling somebody to add an extern.
  - intermingle it with the existing extern ones. Low risk, but leaves
    people wondering why some have extern and some do not.
  - clean up the existing cases first

I dunno. Like all code churn, these kinds of clean-ups have the possibility of accidentally screwing something up. But they are at least a one-time pain, as long as we do not keep changing our mind back and forth.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 31 of 48 in “a rabbit hole of update-server-info fixes”
  1. 0/12 a rabbit hole of update-server-info fixesJeff King, Apr 4, 2019
  2. 01/12 t5319: fix bogus cat-file argumentJeff King, Apr 4, 2019
  3. Ramsay JonesApr 5, 2019
  4. Jeff KingApr 5, 2019
  5. Jeff KingApr 5, 2019
  6. 02/12 t5319: drop useless --buffer from cat-fileJeff King, Apr 4, 2019
  7. 03/12 packfile: factor out .pack to .idx name conversionJeff King, Apr 4, 2019
  8. 04/12 packfile: check midx coverage with .idx rather than .packJeff King, Apr 4, 2019
  9. René ScharfeApr 5, 2019
  10. Jeff KingApr 5, 2019
  11. Jeff KingApr 5, 2019
  12. SZEDER GáborApr 5, 2019
  13. Jeff KingApr 5, 2019
  14. 05/12 http: simplify parsing of remote objects/info/packsJeff King, Apr 4, 2019
  15. René ScharfeApr 5, 2019
  16. Jeff KingApr 5, 2019
  17. René ScharfeApr 5, 2019
  18. 06/12 server-info: fix blind pointer arithmeticJeff King, Apr 4, 2019
  19. 07/12 server-info: simplify cleanup in parse_pack_def()Jeff King, Apr 4, 2019
  20. 08/12 server-info: use strbuf to read old info/packs fileJeff King, Apr 4, 2019
  21. 09/12 server-info: drop nr_alloc struct memberJeff King, Apr 4, 2019
  22. 10/12 packfile.h: drop extern from function declarationsJeff King, Apr 4, 2019
  23. 11/12 server-info: drop objdirlen pointer arithmeticJeff King, Apr 4, 2019
  24. 12/12 update_info_refs(): drop unused force parameterJeff King, Apr 4, 2019
  25. Junio C HamanoApr 5, 2019
  26. 0/13 a rabbit hole of update-server-info (and midx!) fixesJeff King, Apr 5, 2019
  27. 01/13 packfile.h: drop extern from function declarationsJeff King, Apr 5, 2019
  28. Ramsay JonesApr 5, 2019
  29. Jeff KingApr 5, 2019
  30. Junio C HamanoApr 8, 2019
  31. Jeff KingApr 8, 2019
  32. Junio C HamanoApr 9, 2019
  33. Jeff KingApr 9, 2019
  34. 02/13 pack-revindex: open index if necessaryJeff King, Apr 5, 2019
  35. 03/13 t5319: fix bogus cat-file argumentJeff King, Apr 5, 2019
  36. 04/13 t5319: drop useless --buffer from cat-fileJeff King, Apr 5, 2019
  37. 05/13 midx: check both pack and index names for containmentJeff King, Apr 5, 2019
  38. René ScharfeApr 5, 2019
  39. 06/13 packfile: fix pack basename computationJeff King, Apr 5, 2019
  40. 07/13 http: simplify parsing of remote objects/info/packsJeff King, Apr 5, 2019
  41. 08/13 server-info: fix blind pointer arithmeticJeff King, Apr 5, 2019
  42. 09/13 server-info: simplify cleanup in parse_pack_def()Jeff King, Apr 5, 2019
  43. Jeff KingApr 5, 2019
  44. 10/13 server-info: use strbuf to read old info/packs fileJeff King, Apr 5, 2019
  45. 11/13 server-info: drop nr_alloc struct memberJeff King, Apr 5, 2019
  46. 12/13 server-info: drop objdirlen pointer arithmeticJeff King, Apr 5, 2019
  47. 13/13 update_info_refs(): drop unused force parameterJeff King, Apr 5, 2019
  48. Jeff KingApr 5, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.