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

Re: [PATCH] git: remove unneeded casts

From
Jeff King <peff@peff.net>
Date
Dec 17, 2022, 13:32 UTC
Message-ID
<Y53E7PNu05VTdvXG@coredump.intra.peff.net>
In-Reply-To
<xmqqh6xxv946.fsf@gitster.g>
On Thu, Dec 15, 2022 at 08:49:45AM +0900, Junio C Hamano wrote:
Show 11 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > I'll stop here for now. It's a fair bit of leg-work digging
> > these up (though again, I do think there's value in
> > understanding why the cast was there, even if we know it
> > isn't _currently_ doing anything).
> 
> I agree with the value of understanding why each of these casts has
> become unnecessary, and thanks for demonstrating how a rerolled
> version should justify its changes with its findings behind each of
> the unnecessary casts.

I almost didn't write my earlier email, because I was worried that I was creating work where it didn't need to exist (and all of the cases I looked at seemed like good changes). But the cases that Phillip found are a good reminder of the value of being careful here.

Show 8 quoted lines
> What do you recommend the next round should look like?  Multi patch
> series, each of which removes one cast with its proposed log message
> explains how it has become unneeded?  A single patch with a gigantic
> proposed log message that lists the findings for each and all casts
> that are removed?  Somewhere in between, perhaps split along the
> file boundary, or grouped by the event that made them unneeded
> (e.g. "cmd_main() used to take non-const but when we made it to take
> const, all of these casts we remove in this patch became unneeded")?

When I've done fixes across the code base like this in the past, I'd usually try to group them into patches by root cause. So perhaps:

  - this used to be "char **argv" because of main(), but either because
    of becoming a builtin or cmd_main() it is now const
  - this used to require casting from non-const to const to free()
  - etc, with one-offs for cases that don't fit in any group

The keeps a single patch's explanation from being too overwhelming, and avoids repeating yourself when the same logic applies to multiple cases.

That said, I am happy with any solution that explains why we are sure each case is OK to do. :)

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 8 in “git: remove unneeded casts”
  1. git: remove unneeded castsRose via GitGitGadget, Dec 14, 2022
  2. Jeff KingDec 14, 2022
  3. Junio C HamanoDec 14, 2022
  4. Jeff KingDec 17, 2022
  5. Junio C HamanoDec 19, 2022
  6. Ævar Arnfjörð BjarmasonDec 15, 2022
  7. Jeff KingDec 17, 2022
  8. Phillip WoodDec 15, 2022

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.