Re: [PATCH 8/8] Enable GIT_DEBUG_MEMCHECK on git_pathname()
- From
Ramkumar Ramachandra <artagnon@gmail.com>
- Date
- Nov 17, 2011, 10:35 UTC
- Message-ID
- <CALkWK0ndE1Q_jNSV7CBB5W2NyVhcy7kgNO5woWWOw6CXx3cxcA@mail.gmail.com>
- In-Reply-To
- <1321522335-24193-9-git-send-email-pclouds@gmail.com>
Hi Nguyễn,
Nguyễn Thái Ngọc Duy writes:
Show 19 quoted lines
> diff --git a/cache.h b/cache.h > index feb44a5..66365fb 100644 > --- a/cache.h > +++ b/cache.h > @@ -661,10 +661,13 @@ extern char *git_pathdup(const char *fmt, ...) > __attribute__((format (printf, 1, 2))); > > /* Return a statically allocated filename matching the sha1 signature */ > -extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2))); > -extern char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2))); > -extern char *git_path_submodule(const char *path, const char *fmt, ...) > - __attribute__((format (printf, 2, 3))); > +#define mkpath(...) mkpath_real(__FUNCTION__, __LINE__, __VA_ARGS__) > +extern char *mkpath_real(const char *file, int line, const char *fmt, ...) __attribute__((format (printf, 3, 4))); > +#define git_path( ...) git_path_real(__FUNCTION__, __LINE__, __VA_ARGS__) > +extern char *git_path_real(const char *file, int line, const char *fmt, ...) __attribute__((format (printf, 3, 4))); > +#define git_path_submodule(path, ...) git_path_submodule_real(__FUNCTION__, __LINE__, path, __VA_ARGS__) > +extern char *git_path_submodule_real(const char *file, int line, const char *path, const char *fmt, ...) > + __attribute__((format (printf, 4, 5)));
The macros __FILE__, __LINE__ and __VA_ARGS__ are gcc-specific extensions, no? I was curious to see if some other parts of Git are using this: a quick grep returns mailmap.c and notes-merge.c. They both use __VA_ARGS__ it for debugging purposes. So, nothing new.
What happens if GIT_DEBUG_MEMCHECK is set, but I'm not using gcc? Also, it's probably worth mentioning in the commit message that this debugging trick is gcc-specific.
Thanks for working on this.
-- Ram