git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v3 0/3] delta-islands: avoid unused function messages
@ 2018-10-25 11:04 Carlo Marcelo Arenas Belón
  2018-10-25 11:04 ` [PATCH v3 1/3] commit-slab: move MAYBE_UNUSED into git-compat-util Carlo Marcelo Arenas Belón
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Carlo Marcelo Arenas Belón @ 2018-10-25 11:04 UTC (permalink / raw)
  To: git
  Cc: pclouds, peff, chriscool, l.s.r, ramsay,
	Carlo Marcelo Arenas Belón

the macro generated code from delta-islands (using khash) triggers
some unused function warnings in macOS, OpenBSD and some linux with a
newer version of clang because of its use of static functions.

Changes from v2:
* Relay in the C code including git-compat-util as suggested by Jeff
* Commit message cleanup
* Make changes hdr-check clean

Changes from v1:
* Use MAYBE_UNUSED for all cases as suggested by Duy

Carlo Marcelo Arenas Belón (3):
  commit-slab: move MAYBE_UNUSED into git-compat-util
  khash: silence -Wunused-function in delta-islands from khash
  commit-slab: missing definitions and forward declarations (hdr-check)

 commit-slab-impl.h | 4 ++--
 commit-slab.h      | 2 ++
 git-compat-util.h  | 2 ++
 khash.h            | 2 +-
 4 files changed, 7 insertions(+), 3 deletions(-)

-- 
2.19.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/3] commit-slab: move MAYBE_UNUSED into git-compat-util
  2018-10-25 11:04 [PATCH v3 0/3] delta-islands: avoid unused function messages Carlo Marcelo Arenas Belón
@ 2018-10-25 11:04 ` Carlo Marcelo Arenas Belón
  2018-10-25 11:04 ` [PATCH v3 2/3] khash: silence -Wunused-function in delta-islands from khash Carlo Marcelo Arenas Belón
  2018-10-25 11:04 ` [PATCH v3 3/3] commit-slab: missing definitions and forward declarations (hdr-check) Carlo Marcelo Arenas Belón
  2 siblings, 0 replies; 9+ messages in thread
From: Carlo Marcelo Arenas Belón @ 2018-10-25 11:04 UTC (permalink / raw)
  To: git
  Cc: pclouds, peff, chriscool, l.s.r, ramsay,
	Carlo Marcelo Arenas Belón, Junio C Hamano

after 36da893114 ("config.mak.dev: enable -Wunused-function", 2018-10-18)
it is expected to be used to prevent -Wunused-function warnings for code
that was macro generated

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 commit-slab-impl.h | 4 +---
 git-compat-util.h  | 2 ++
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/commit-slab-impl.h b/commit-slab-impl.h
index ac1e6d409a..e352c2f8c1 100644
--- a/commit-slab-impl.h
+++ b/commit-slab-impl.h
@@ -1,10 +1,8 @@
 #ifndef COMMIT_SLAB_IMPL_H
 #define COMMIT_SLAB_IMPL_H
 
-#define MAYBE_UNUSED __attribute__((__unused__))
-
 #define implement_static_commit_slab(slabname, elemtype) \
-	implement_commit_slab(slabname, elemtype, static MAYBE_UNUSED)
+	implement_commit_slab(slabname, elemtype, MAYBE_UNUSED static)
 
 #define implement_shared_commit_slab(slabname, elemtype) \
 	implement_commit_slab(slabname, elemtype, )
diff --git a/git-compat-util.h b/git-compat-util.h
index 48c955541e..8121b73b4a 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -408,6 +408,8 @@ static inline char *git_find_last_dir_sep(const char *path)
 #define LAST_ARG_MUST_BE_NULL
 #endif
 
+#define MAYBE_UNUSED __attribute__((__unused__))
+
 #include "compat/bswap.h"
 
 #include "wildmatch.h"
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 2/3] khash: silence -Wunused-function in delta-islands from khash
  2018-10-25 11:04 [PATCH v3 0/3] delta-islands: avoid unused function messages Carlo Marcelo Arenas Belón
  2018-10-25 11:04 ` [PATCH v3 1/3] commit-slab: move MAYBE_UNUSED into git-compat-util Carlo Marcelo Arenas Belón
@ 2018-10-25 11:04 ` Carlo Marcelo Arenas Belón
  2018-10-25 11:30   ` SZEDER Gábor
  2018-10-25 11:04 ` [PATCH v3 3/3] commit-slab: missing definitions and forward declarations (hdr-check) Carlo Marcelo Arenas Belón
  2 siblings, 1 reply; 9+ messages in thread
From: Carlo Marcelo Arenas Belón @ 2018-10-25 11:04 UTC (permalink / raw)
  To: git
  Cc: pclouds, peff, chriscool, l.s.r, ramsay,
	Carlo Marcelo Arenas Belón, Junio C Hamano

showing the following when compiled with latest clang (OpenBSD, Fedora
and macOS):

delta-islands.c:23:1: warning: unused function 'kh_destroy_str'
      [-Wunused-function]
delta-islands.c:23:1: warning: unused function 'kh_clear_str'
      [-Wunused-function]
delta-islands.c:23:1: warning: unused function 'kh_del_str' [-Wunused-function]

Reported-by: René Scharfe <l.s.r@web.de>
Suggested-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 khash.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/khash.h b/khash.h
index d10caa0c35..532109c87f 100644
--- a/khash.h
+++ b/khash.h
@@ -234,7 +234,7 @@ static const double __ac_HASH_UPPER = 0.77;
 	__KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
 
 #define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
-	KHASH_INIT2(name, static inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
+	KHASH_INIT2(name, MAYBE_UNUSED static inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
 
 /* Other convenient macros... */
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 3/3] commit-slab: missing definitions and forward declarations (hdr-check)
  2018-10-25 11:04 [PATCH v3 0/3] delta-islands: avoid unused function messages Carlo Marcelo Arenas Belón
  2018-10-25 11:04 ` [PATCH v3 1/3] commit-slab: move MAYBE_UNUSED into git-compat-util Carlo Marcelo Arenas Belón
  2018-10-25 11:04 ` [PATCH v3 2/3] khash: silence -Wunused-function in delta-islands from khash Carlo Marcelo Arenas Belón
@ 2018-10-25 11:04 ` Carlo Marcelo Arenas Belón
  2018-10-25 18:54   ` Ramsay Jones
  2 siblings, 1 reply; 9+ messages in thread
From: Carlo Marcelo Arenas Belón @ 2018-10-25 11:04 UTC (permalink / raw)
  To: git
  Cc: pclouds, peff, chriscool, l.s.r, ramsay,
	Carlo Marcelo Arenas Belón

struct commmit needs to be defined before commit-slab can generate
working code, object_id should be at least known through a forward
declaration

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 commit-slab-impl.h | 2 ++
 commit-slab.h      | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/commit-slab-impl.h b/commit-slab-impl.h
index e352c2f8c1..db7cf3f19b 100644
--- a/commit-slab-impl.h
+++ b/commit-slab-impl.h
@@ -1,6 +1,8 @@
 #ifndef COMMIT_SLAB_IMPL_H
 #define COMMIT_SLAB_IMPL_H
 
+#include "commit.h"
+
 #define implement_static_commit_slab(slabname, elemtype) \
 	implement_commit_slab(slabname, elemtype, MAYBE_UNUSED static)
 
diff --git a/commit-slab.h b/commit-slab.h
index 69bf0c807c..722252de61 100644
--- a/commit-slab.h
+++ b/commit-slab.h
@@ -1,6 +1,8 @@
 #ifndef COMMIT_SLAB_H
 #define COMMIT_SLAB_H
 
+struct object_id;
+
 #include "commit-slab-decl.h"
 #include "commit-slab-impl.h"
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 2/3] khash: silence -Wunused-function in delta-islands from khash
  2018-10-25 11:04 ` [PATCH v3 2/3] khash: silence -Wunused-function in delta-islands from khash Carlo Marcelo Arenas Belón
@ 2018-10-25 11:30   ` SZEDER Gábor
  0 siblings, 0 replies; 9+ messages in thread
From: SZEDER Gábor @ 2018-10-25 11:30 UTC (permalink / raw)
  To: Carlo Marcelo Arenas Belón
  Cc: git, pclouds, peff, chriscool, l.s.r, ramsay, Junio C Hamano

On Thu, Oct 25, 2018 at 04:04:26AM -0700, Carlo Marcelo Arenas Belón wrote:
> showing the following when compiled with latest clang (OpenBSD, Fedora
> and macOS):

s/^s/S/
This applies to your other commit messages as well.

But more importantly, please be explicit about the compiler version
that emits the warning, so others won't have to guess when stumbling
upon this commit in a few months or years time.

> delta-islands.c:23:1: warning: unused function 'kh_destroy_str'
>       [-Wunused-function]
> delta-islands.c:23:1: warning: unused function 'kh_clear_str'
>       [-Wunused-function]
> delta-islands.c:23:1: warning: unused function 'kh_del_str' [-Wunused-function]
> 
> Reported-by: René Scharfe <l.s.r@web.de>
> Suggested-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  khash.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/khash.h b/khash.h
> index d10caa0c35..532109c87f 100644
> --- a/khash.h
> +++ b/khash.h
> @@ -234,7 +234,7 @@ static const double __ac_HASH_UPPER = 0.77;
>  	__KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
>  
>  #define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
> -	KHASH_INIT2(name, static inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
> +	KHASH_INIT2(name, MAYBE_UNUSED static inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
>  
>  /* Other convenient macros... */
>  
> -- 
> 2.19.1
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 3/3] commit-slab: missing definitions and forward declarations (hdr-check)
  2018-10-25 11:04 ` [PATCH v3 3/3] commit-slab: missing definitions and forward declarations (hdr-check) Carlo Marcelo Arenas Belón
@ 2018-10-25 18:54   ` Ramsay Jones
  2018-10-25 21:08     ` Ramsay Jones
  0 siblings, 1 reply; 9+ messages in thread
From: Ramsay Jones @ 2018-10-25 18:54 UTC (permalink / raw)
  To: Carlo Marcelo Arenas Belón, git; +Cc: pclouds, peff, chriscool, l.s.r



On 25/10/2018 12:04, Carlo Marcelo Arenas Belón wrote:
> struct commmit needs to be defined before commit-slab can generate
> working code, object_id should be at least known through a forward
> declaration
> 
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
>  commit-slab-impl.h | 2 ++
>  commit-slab.h      | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/commit-slab-impl.h b/commit-slab-impl.h
> index e352c2f8c1..db7cf3f19b 100644
> --- a/commit-slab-impl.h
> +++ b/commit-slab-impl.h
> @@ -1,6 +1,8 @@
>  #ifndef COMMIT_SLAB_IMPL_H
>  #define COMMIT_SLAB_IMPL_H
>  
> +#include "commit.h"
> +
>  #define implement_static_commit_slab(slabname, elemtype) \
>  	implement_commit_slab(slabname, elemtype, MAYBE_UNUSED static)
>  
> diff --git a/commit-slab.h b/commit-slab.h
> index 69bf0c807c..722252de61 100644
> --- a/commit-slab.h
> +++ b/commit-slab.h
> @@ -1,6 +1,8 @@
>  #ifndef COMMIT_SLAB_H
>  #define COMMIT_SLAB_H
>  
> +struct object_id;
> +
>  #include "commit-slab-decl.h"
>  #include "commit-slab-impl.h"
>  
> 

Hmm, sorry, I don't see how this patch has anything to do
with the other two patches! ;-)

Also, I have a patch to fix up the 'commit-reach.h' header
(it was part of my original series, just had to update the
commit message), which adds these very #includes and forward
declarations when _using_ the commit-slab.

I haven't tried applying your patches yet, which may answer
my questions, so I am a little puzzled.

ATB,
Ramsay Jones


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 3/3] commit-slab: missing definitions and forward declarations (hdr-check)
  2018-10-25 18:54   ` Ramsay Jones
@ 2018-10-25 21:08     ` Ramsay Jones
  2018-10-26  3:15       ` Carlo Arenas
  0 siblings, 1 reply; 9+ messages in thread
From: Ramsay Jones @ 2018-10-25 21:08 UTC (permalink / raw)
  To: Carlo Marcelo Arenas Belón, git; +Cc: pclouds, peff, chriscool, l.s.r



On 25/10/2018 19:54, Ramsay Jones wrote:
> 
> 
> On 25/10/2018 12:04, Carlo Marcelo Arenas Belón wrote:
>> struct commmit needs to be defined before commit-slab can generate
>> working code, object_id should be at least known through a forward
>> declaration
>>
>> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
>> ---
>>  commit-slab-impl.h | 2 ++
>>  commit-slab.h      | 2 ++
>>  2 files changed, 4 insertions(+)
>>
>> diff --git a/commit-slab-impl.h b/commit-slab-impl.h
>> index e352c2f8c1..db7cf3f19b 100644
>> --- a/commit-slab-impl.h
>> +++ b/commit-slab-impl.h
>> @@ -1,6 +1,8 @@
>>  #ifndef COMMIT_SLAB_IMPL_H
>>  #define COMMIT_SLAB_IMPL_H
>>  
>> +#include "commit.h"
>> +
>>  #define implement_static_commit_slab(slabname, elemtype) \
>>  	implement_commit_slab(slabname, elemtype, MAYBE_UNUSED static)
>>  
>> diff --git a/commit-slab.h b/commit-slab.h
>> index 69bf0c807c..722252de61 100644
>> --- a/commit-slab.h
>> +++ b/commit-slab.h
>> @@ -1,6 +1,8 @@
>>  #ifndef COMMIT_SLAB_H
>>  #define COMMIT_SLAB_H
>>  
>> +struct object_id;
>> +
>>  #include "commit-slab-decl.h"
>>  #include "commit-slab-impl.h"
>>  
>>
> 
> Hmm, sorry, I don't see how this patch has anything to do
> with the other two patches! ;-)
> 
> Also, I have a patch to fix up the 'commit-reach.h' header
> (it was part of my original series, just had to update the
> commit message), which adds these very #includes and forward
> declarations when _using_ the commit-slab.
> 
> I haven't tried applying your patches yet, which may answer
> my questions, so I am a little puzzled.

So, having now applied your patches, I still don't see what this
patch has to do with the others! I suppose it is dependent on the
compiler/version? (the most up-to-date version of clang available
to me is 5.0.1).

Yes, this will 'fix' the 'commit-reach.h' header (not surprising),
but I prefer my patch. ;-)

Still puzzled.

ATB,
Ramsay Jones


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 3/3] commit-slab: missing definitions and forward declarations (hdr-check)
  2018-10-25 21:08     ` Ramsay Jones
@ 2018-10-26  3:15       ` Carlo Arenas
  2018-10-27  1:45         ` Ramsay Jones
  0 siblings, 1 reply; 9+ messages in thread
From: Carlo Arenas @ 2018-10-26  3:15 UTC (permalink / raw)
  To: ramsay; +Cc: git, pclouds, peff, chriscool, l.s.r

On Thu, Oct 25, 2018 at 2:09 PM Ramsay Jones
<ramsay@ramsayjones.plus.com> wrote:
> Yes, this will 'fix' the 'commit-reach.h' header (not surprising),
> but I prefer my patch. ;-)

I apologize, I joined the list recently and so might had missed a
reroll; the merged series in pu doesn't seem to include it and the
error was around the code I changed, so wanted to make sure it would
be addressed sooner rather than later.

eitherway, I agree with you my patch (or something better) would fit
better in your topic branch than on mine and while I haven't seen your
patch I am sure is most likely better.

> Still puzzled.

this are the last lines of a `make hdr-check` in Fedora Rawhide, it
should behave the same regardless of OS or compiler used IMHO

    HDR commit-reach.h
commit-reach.h:45:28: warning: ‘struct object_id’ declared inside
parameter list will not be visible outside of this definition or
declaration
 int ref_newer(const struct object_id *new_oid, const struct object_id
*old_oid);
                            ^~~~~~~~~
In file included from commit-slab.h:5,
                 from commit-reach.h:4:
commit-reach.h: In function ‘contains_cache_at_peek’:
commit-slab-impl.h:47:14: error: dereferencing pointer to incomplete
type ‘const struct commit’
  nth_slab = c->index / s->slab_size;    \
              ^~
commit-slab-impl.h:7:2: note: in expansion of macro ‘implement_commit_slab’
  implement_commit_slab(slabname, elemtype, static MAYBE_UNUSED)
  ^~~~~~~~~~~~~~~~~~~~~
commit-slab.h:49:2: note: in expansion of macro ‘implement_static_commit_slab’
  implement_static_commit_slab(slabname, elemtype)
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
commit-reach.h:57:1: note: in expansion of macro ‘define_commit_slab’
 define_commit_slab(contains_cache, enum contains_result);
 ^~~~~~~~~~~~~~~~~~
commit-reach.h: At top level:
commit-reach.h:69:41: warning: ‘struct object_array’ declared inside
parameter list will not be visible outside of this definition or
declaration
 int can_all_from_reach_with_flag(struct object_array *from,
                                         ^~~~~~~~~~~~
make: *** [Makefile:2685: commit-reach.hco] Error 1

Carlo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 3/3] commit-slab: missing definitions and forward declarations (hdr-check)
  2018-10-26  3:15       ` Carlo Arenas
@ 2018-10-27  1:45         ` Ramsay Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Ramsay Jones @ 2018-10-27  1:45 UTC (permalink / raw)
  To: Carlo Arenas; +Cc: git, pclouds, peff, chriscool, l.s.r



On 26/10/2018 04:15, Carlo Arenas wrote:
> On Thu, Oct 25, 2018 at 2:09 PM Ramsay Jones
> <ramsay@ramsayjones.plus.com> wrote:
>> Yes, this will 'fix' the 'commit-reach.h' header (not surprising),
>> but I prefer my patch. ;-)
> 
> I apologize, I joined the list recently and so might had missed a
> reroll; the merged series in pu doesn't seem to include it and the
> error was around the code I changed, so wanted to make sure it would
> be addressed sooner rather than later.
> 
> eitherway, I agree with you my patch (or something better) would fit
> better in your topic branch than on mine and while I haven't seen your
> patch I am sure is most likely better.

Hmm, I don't know about that!

Since the original series has progressed, any additions will now
result in a new set of patches, rather than a re-roll.

The original 'commit-reach.h' patch was not applied as part of the
last series, since the commit message was felt to be lacking (well,
it was actually non-existent!). ;-)

I have been making some additional changes to the 'hdr-check' target
in the Makefile, but I haven't quite finished. I will send the other
(non-Makefile) changes soon. [These patches will make the 'master'
and 'next' branches 'hdr-check' clean for me].

ATB,
Ramsay Jones

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-10-27  1:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-25 11:04 [PATCH v3 0/3] delta-islands: avoid unused function messages Carlo Marcelo Arenas Belón
2018-10-25 11:04 ` [PATCH v3 1/3] commit-slab: move MAYBE_UNUSED into git-compat-util Carlo Marcelo Arenas Belón
2018-10-25 11:04 ` [PATCH v3 2/3] khash: silence -Wunused-function in delta-islands from khash Carlo Marcelo Arenas Belón
2018-10-25 11:30   ` SZEDER Gábor
2018-10-25 11:04 ` [PATCH v3 3/3] commit-slab: missing definitions and forward declarations (hdr-check) Carlo Marcelo Arenas Belón
2018-10-25 18:54   ` Ramsay Jones
2018-10-25 21:08     ` Ramsay Jones
2018-10-26  3:15       ` Carlo Arenas
2018-10-27  1:45         ` Ramsay Jones

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).