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

Re: [PATCH 0/5] getting rid of most "static struct lock_file"s

From
Jeff King <peff@peff.net>
Date
May 8, 2018, 18:25 UTC
Message-ID
<20180508182548.GD7210@sigill.intra.peff.net>
In-Reply-To
<20180506141031.30204-1-martin.agren@gmail.com>
On Sun, May 06, 2018 at 04:10:26PM +0200, Martin Ågren wrote:
Show 13 quoted lines
> This series addresses two classes of "static struct lock_file", removing
> the staticness: Those locks that already live inside a function, and
> those that can simply be moved into the function they are used from.
> 
> The first three patches are some cleanups I noticed along the way, where
> we first take a lock using LOCK_DIE_ON_ERROR, then check whether we got
> it.
> 
> After this series, we have a small number of "static struct lock_file"
> left, namely those locks that are used from within more than one
> function. Thus, after this series, when one stumbles upon a static
> lock_file, it should be a clear warning that the lock is being
> used by more than one function.

These all look fine to me. The commit messages all made perfect sense to me, but it sounds like some people weren't aware of the new post-076aa2cbda rules. So maybe it makes sense to reference that even in the earlier commits, and to explicitly say that it's safe to convert even in the case where the lock_file goes out of scope while still active.

The only dangerous thing left to check for is anybody holding onto a pointer-to-lockfile. The only such pointer declared outside of a parameter list is in create_reflock(), and there it's just to temporarily coerce a void pointer. So unless somebody is doing something really tricky (putting a pointer-to-lock in a "void *"), I think these conversions all have to be trivially correct (famous last words...).

-Peff
Previous: Martin ÅgrenNext: Martin Ågren
Message 2 of 11 in “getting rid of most "static struct lock_file"s”
  1. 0/5 getting rid of most "static struct lock_file"sMartin Ågren, May 6, 2018
  2. Jeff KingMay 8, 2018
  3. 0/5 getting rid of most "static struct lock_file"sMartin Ågren, May 9, 2018
  4. 1/5 t/helper/test-write-cache: clean up lock-handlingMartin Ågren, May 9, 2018
  5. 2/5 refs.c: do not die if locking fails in `write_pseudoref()`Martin Ågren, May 9, 2018
  6. 3/5 refs.c: do not die if locking fails in `delete_pseudoref()`Martin Ågren, May 9, 2018
  7. 4/5 lock_file: make function-local locks non-staticMartin Ågren, May 9, 2018
  8. 5/5 lock_file: move static locks into functionsMartin Ågren, May 9, 2018
  9. Jeff KingMay 10, 2018
  10. Junio C HamanoMay 10, 2018
  11. Martin ÅgrenMay 10, 2018

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.