diff options
author | Ramsay Jones <ramsay@ramsayjones.plus.com> | 2017-05-08 21:45:56 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-26 12:33:55 +0900 |
commit | b0a642ac4624740187212aecec62b35a2eab38cb (patch) | |
tree | ed2e8e8b6bafc6dd97beea232b3844e321397cb5 /git-compat-util.h | |
parent | d2bbb7c2bcf6e77ebfcabf4e12110fe6d5c91de6 (diff) | |
download | git-b0a642ac4624740187212aecec62b35a2eab38cb.tar.gz |
git_fopen: fix a sparse 'not declared' warning
If git is built with the FREAD_READS_DIRECTORIES build variable set, this
would cause sparse to issue a 'not declared, should it be static?' warning
on Linux. This is a result of the method employed by 'compat/fopen.c' to
suppress the (possible) redefinition of the (system) fopen macro, which
also removes the extern declaration of the git_fopen function.
In order to suppress the warning, introduce a new macro to suppress the
definition (or possibly the re-definition) of the fopen symbol as a macro
override. This new macro (SUPPRESS_FOPEN_REDEFINITION) is only defined in
'compat/fopen.c', just prior to the inclusion of the 'git-compat-util.h'
header file.
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r-- | git-compat-util.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/git-compat-util.h b/git-compat-util.h index bd04564a69..6be55cf8b3 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -689,10 +689,12 @@ char *gitstrdup(const char *s); #endif #ifdef FREAD_READS_DIRECTORIES -#ifdef fopen -#undef fopen -#endif -#define fopen(a,b) git_fopen(a,b) +# if !defined(SUPPRESS_FOPEN_REDEFINITION) +# ifdef fopen +# undef fopen +# endif +# define fopen(a,b) git_fopen(a,b) +# endif extern FILE *git_fopen(const char*, const char*); #endif |