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

Re: [PATCH] fetch-pack: Remove unused struct 'loose_object_iter'

From
DGDr. David Alan Gilbert <dave@treblig.org>
Date
May 15, 2024, 10:41 UTC
Message-ID
<ZkSRbSgQ-whUdms-@gallifrey>
In-Reply-To
<20240515064658.GE110841@coredump.intra.peff.net>
* Jeff King (peff@peff.net) wrote:
Show 8 quoted lines
> On Sun, May 12, 2024 at 01:59:13AM +0100, Dr. David Alan Gilbert wrote:
> 
> > 'loose_object_iter' in fetch-pack.c is unused since
> > commit 97b2fa08b6b9ee3e ("fetch-pack: drop custom loose object cache")
> > Remove it.
> 
> Thanks, this was my fault for leaving it in. The patch looks obviously
> good.

Thanks. Most projects I've looked at seem to have one or more.

> I wish there was a good way to get the compiler to report on unused
> types, but I don't think there is (it's a complicated problem in
> general, but file-local ones like this feel like they should be easy to
> spot).
Alas not.
Show 12 quoted lines
> Here's a really hacky (and quadratic) attempt to find defined structs
> that aren't mentioned elsewhere:
> 
>   for i in $(git grep -ho '^struct [a-z_]* {' | cut -d' ' -f2)
>   do
> 	used=$(git grep -Phc "\b$i\b" |
> 	       perl -ne '$x += $_; END { print $x }')
> 	echo "$used $i"
>   done |
>   sort -n
> 
> which finds exactly one unused struct, the one in this patch.
My similarly hacky script was:
  
  grep -r '^struct [^(=]* {'| tr ':' ' ' |
  while read FNAME STRUCT NAME TAIL
  do
    echo "$FNAME" | grep -q '[.]c$' || continue
  echo ">>>" $FNAME ' : ' $NAME
  echo -n "Count: "
  grep $NAME $FNAME | wc -l 
  #grep $VARNAME $FNAME
  done
(A count of 1 being the unused ones).
Dave
> 
> -Peff
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
Previous: Jeff King
Message 5 of 5 in “fetch-pack: Remove unused struct 'loose_object_iter'”
  1. fetch-pack: Remove unused struct 'loose_object_iter'Dr. David Alan Gilbert, May 12, 2024
  2. Patrick SteinhardtMay 13, 2024
  3. Junio C HamanoMay 13, 2024
  4. Jeff KingMay 15, 2024
  5. Dr. David Alan GilbertMay 15, 2024

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.