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.