Pedantic fixes for Apple clang
cover Pedantic fixes for Apple clang
Following up on my previous series bb/pedantic for gcc, here are two fixes for pedantic compilation under MacOS 10.13.6 (High Sierra) with the command line tools of Xcode Version 9.4.1 (9F2000).
Beat Bolli (2):
packfile: drop a repeated enum declaration
remote-odb: un-inline function remote_odb_reinit
packfile.h | 1 - remote-odb.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
Signature · 1 line
2.18.0
PATCH 2/2 remote-odb: un-inline function remote_odb_reinit
When compiling under Apple LLVM version 9.1.0 (clang-902.0.39.2) with "make DEVELOPER=1 DEVOPTS=pedantic", the compiler says
remote-odb.c:87:2: error: static function 'remote_odb_do_init' is used in an inline function with external linkage [-Werror,-Wstatic-in-inline]
Remove the inline specifier that would only make sense if remote_odb_reinit were defined in the header file. Moving it into the header is not possible because the called function remote_odb_do_init is static and thus not visible from the includers of the header.
--- remote-odb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
remote-odb.c +1 -1
@@ -82,7 +82,7 @@ static inline void remote_odb_init(void)remote_odb_do_init (0 ); } -inline void remote_odb_reinit (void ) +void remote_odb_reinit (void ) {remote_odb_do_init (1 ); }
Signature · 1 line
2.18.0
PATCH 1/2 packfile: drop a repeated enum declaration
In reply to Beat BolliWhen compiling under Apple LLVM version 9.1.0 (clang-902.0.39.2) with "make DEVELOPER=1 DEVOPTS=pedantic", the compiler says
error: redeclaration of already-defined enum 'object_type' is a GNU extension [-Werror,-Wgnu-redeclared-enum]
According to https://en.cppreference.com/w/c/language/declarations
(section "Redeclaration"), a repeated declaration after the definition is only legal for structs and unions, but not for enums.
Drop the belated declaration of enum object_type. It seems that each includer of packfile.h includes the definition of the enum before including packfile.h.
--- packfile.h | 1 - 1 file changed, 1 deletion(-)
packfile.h +0 -1
@@ -6,7 +6,6 @@/* in object-store.h */ struct packed_git ;struct object_info ; -enum object_type ;/* * Generate the filename to be used for a pack file with checksum "sha1" and
Signature · 1 line
2.18.0
Re: [PATCH 1/2] packfile: drop a repeated enum declaration
Hi,
packfile.h line 11
Quoted 10 lines · Beat Bolli
packfile.h +0
-1@@ -6,7 +6,6 @@/* in object-store.h */ struct packed_git ;struct object_info ; -enum object_type ;/* * Generate the filename to be used for a pack file with checksum "sha1" and
Good catch. This means packfile.h should #include "cache.h" --- otherwise, it is not usable in a file that does
#include "git-compat-util.h" #include "packfile.h"
Thanks and hope that helps,
Jonathan
Re: [PATCH 2/2] remote-odb: un-inline function remote_odb_reinit
In reply to Beat BolliHi,
Quoted 12 lines · Beat Bolli
When compiling under Apple LLVM version 9.1.0 (clang-902.0.39.2) with "make DEVELOPER=1 DEVOPTS=pedantic", the compiler says
remote-odb.c:87:2: error: static function '
remote_odb_do_init' is used in an inline function with external linkage [-Werror,-Wstatic-in-inline]Remove the inline specifier that would only make sense if
remote_odb_reinitwere defined in the header file. Moving it into the header is not possible because the called functionremote_odb_do_initis static and thus not visible from the includers of the header.
Quoted 4 lines
Signed-off-by Beat Bolli <[email protected]>--- remote-odb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
What branch does this apply to?
[...]
remote-odb.c static inline void remote_odb_init(void) · line 85
Quoted 8 lines
remote-odb.c +1
-1@@ -82,7 +82,7 @@ static inline void remote_odb_init(void)remote_odb_do_init (0 ); } -inline void remote_odb_reinit (void ) +void remote_odb_reinit (void )
This looks like an oversight in
https://public-inbox.org/git/[email protected]/:
there isn't any reason for this function to be inline.
Christian, can you squash it in on your next reroll?
Thanks,
Jonathan
Re: [PATCH 2/2] remote-odb: un-inline function remote_odb_reinit
Hi Jonathan
Quoted 16 lines · Jonathan Nieder
Hi,
Quoted 12 lines · Beat Bolli
When compiling under Apple LLVM version 9.1.0 (clang-902.0.39.2) with "make DEVELOPER=1 DEVOPTS=pedantic", the compiler says
remote-odb.c:87:2: error: static function '
remote_odb_do_init' is used in an inline function with external linkage [-Werror,-Wstatic-in-inline]Remove the inline specifier that would only make sense if
remote_odb_reinitwere defined in the header file. Moving it into the header is not possible because the called functionremote_odb_do_initis static and thus not visible from the includers of the header.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Beat Bolli <[email protected]>--- remote-odb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)What branch does this apply to?
To pu as of today.
Quoted 7 lines
[...]
Quoted 6 lines
remote-odb.c +0
-0@@ -82,7 +82,7 @@ static inline void remote_odb_init(void)remote_odb_do_init (0 ); }
Quoted 8 lines
remote-odb.c static inline void remote_odb_init(void) · line 85
Quoted 2 lines
remote-odb.c +1
-1-inline void remote_odb_reinit (void ) +void remote_odb_reinit (void )This looks like an oversight in
https://public-inbox.org/git/[email protected]/:
there isn't any reason for this function to be inline.Christian, can you squash it in on your next reroll?
That would probably make sense. I didn't check how mature the topics were that caused errors.
Beat
Re: [PATCH 2/2] remote-odb: un-inline function remote_odb_reinit
Hi,
Quoted 12 lines · Beat Bolli
Quoted 10 lines · Jonathan Nieder
remote-odb.c static inline void remote_odb_init(void) · line 85
Quoted 2 lines · Beat Bolli
remote-odb.c +1
-1-inline void remote_odb_reinit (void ) +void remote_odb_reinit (void )This looks like an oversight in
https://public-inbox.org/git/[email protected]/:
there isn't any reason for this function to be inline.
Quoted 4 lines
Quoted 1 line
Christian, can you squash it in on your next reroll?
That would probably make sense. I didn't check how mature the topics were that caused errors.
Ok, it is in the next version I will send.
Thanks,
Christian.
Re: [PATCH 2/2] remote-odb: un-inline function remote_odb_reinit
Quoted 15 lines · Christian Couder
Hi,
Quoted 12 lines · Beat Bolli
Quoted 10 lines · Jonathan Nieder
remote-odb.c static inline void remote_odb_init(void) · line 85
Quoted 2 lines · Beat Bolli
remote-odb.c +1
-1-inline void remote_odb_reinit (void ) +void remote_odb_reinit (void )This looks like an oversight in
https://public-inbox.org/git/[email protected]/:
there isn't any reason for this function to be inline.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Christian, can you squash it in on your next reroll?
That would probably make sense. I didn't check how mature the topics were that caused errors.
Ok, it is in the next version I will send.
OK, then I'll ignore this one for now.