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

Re: [PATCH] mv: Fix spurious warning when moving a file in presence of submodules

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Oct 14, 2013, 05:40 UTC
Message-ID
<20131014054048.GC25344@google.com>
In-Reply-To
<vpqr4bp6wkh.fsf@anie.imag.fr>
Matthieu Moy wrote:
> Jens Lehmann <Jens.Lehmann@web.de> writes:
Show 6 quoted lines
>>  static struct lock_file lock_file;
>> +#define SUBMODULE_WITH_GITDIR ((const char *)1)
>
> I don't like very much hardcoded addresses like this. Are you 100% sure
> address 1 will never be returned by xstrdup on any platform? The risk is
> small if not negligible, but I'm unconfortable with this.

I haven't checked what the standards say, but in practice I think it's okay. An alternative would be to do something like

	static const char SUBMODULE_WITH_GITDIR[] = "*** (submodule with gitdir) ***";

which is a bit more error-prone because attempts to use it as a string wouldn't crash. We use (void *) 1 in the same way a few places currently.

Thanks, both.
Previous: Jens LehmannNext: Matthieu Moy
Message 6 of 8 in “Spurious warning when moving a file in presence of submodules”
  1. Matthieu MoyOct 11, 2013
  2. Jens LehmannOct 11, 2013
  3. mv: Fix spurious warning when moving a file in presence of submodulesJens Lehmann, Oct 13, 2013
  4. Matthieu MoyOct 13, 2013
  5. Jens LehmannOct 13, 2013
  6. Jonathan NiederOct 14, 2013
  7. Matthieu MoyOct 14, 2013
  8. Jonathan NiederOct 17, 2013

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.