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

Re: [PATCH] mv: prevent mismatched data when ignoring errors.

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 18, 2014, 22:31 UTC
Message-ID
<xmqqtxav5ebl.fsf@gitster.dls.corp.google.com>
In-Reply-To
<53270FC2.2030701@alum.mit.edu>
Michael Haggerty <mhagger@alum.mit.edu> writes:
Show 17 quoted lines
> I had recently been thinking along the same lines.  In many of the
> potential callers that I noticed, ALLOC_GROW() was used immediately
> before making space in the array for a new element.  So I suggest
> something more like
>
> +#define MOVE_DOWN(array, nr, at, count)	\
> +	memmove((array) + (at) + (count),		\
> +		(array) + (at),				\
> +		sizeof((array)[0]) * ((nr) - (at)))
> +#define ALLOC_INSERT_GAP(array, nr, at, count, alloc)		     \
> +	do {							     \
> +		ALLOC_GROW((array), (nr) + (count), (alloc));        \
> +		MOVE_DOWN((array), (nr), (at), (count));	     \
> +	} while (0)
>
> Also, count==1 is so frequent that this special case might deserve its
> own macro pair.
Yeah, probably.
> I'm not inspired by these macro names, though.
Me neither, about ups and downs.

Peff's suggestion to name these around the concept of "gap" sounded sensible.

Previous: Jeff KingNext: brian m. carlson
Message 19 of 21 in “git 1.9.0 segfault”
  1. Guillaume GelinMar 8, 2014
  2. brian m. carlsonMar 8, 2014
  3. John KeepingMar 8, 2014
  4. builtin/mv: fix out of bounds writeJohn Keeping, Mar 8, 2014
  5. brian m. carlsonMar 8, 2014
  6. builtin/mv: fix out of bounds writeJohn Keeping, Mar 8, 2014
  7. mv: prevent mismatched data when ignoring errors.brian m. carlson, Mar 8, 2014
  8. Jeff KingMar 11, 2014
  9. brian m. carlsonMar 11, 2014
  10. Junio C HamanoMar 11, 2014
  11. brian m. carlsonMar 12, 2014
  12. Thomas RastMar 15, 2014
  13. Jeff KingMar 16, 2014
  14. Junio C HamanoMar 16, 2014
  15. Junio C HamanoMar 17, 2014
  16. Michael HaggertyMar 17, 2014
  17. Eric SunshineMar 17, 2014
  18. Jeff KingMar 17, 2014
  19. Junio C HamanoMar 18, 2014
  20. mv: prevent mismatched data when ignoring errors.brian m. carlson, Mar 15, 2014
  21. Jeff KingMar 16, 2014

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.