# [PATCH 1/2] ref-filter: mark a file-local symbol as static

5 messages from 2018-03-02 to 2018-03-02. Participants: Ramsay Jones, Jonathan Nieder, Junio C Hamano.
Thread: https://gitlist.dev/t/47957

## Ramsay Jones, 2018-03-02 02:54

Subject: [PATCH 1/2] ref-filter: mark a file-local symbol as static
Message-ID: <1d28d866-535c-6d37-4cb9-5decedab3acb@ramsayjones.plus.com>
URL: https://gitlist.dev/e/1d28d866-535c-6d37-4cb9-5decedab3acb%40ramsayjones.plus.com

```

Commit fcfba37337 ('ref-filter: make "--contains <id>" less chatty if
<id> is invalid', 2018-02-23) added the add_str_to_commit_list()
function, which causes sparse to issue a "... not declared. Should it
be static?" warning for that symbol.

In order to suppress the warning, mark that function as static.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
 ref-filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ref-filter.c b/ref-filter.c
index f375e7670..69bf7b587 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2000,7 +2000,7 @@ static void do_merge_filter(struct ref_filter_cbdata *ref_cbdata)
 	free(to_clear);
 }
 
-int add_str_to_commit_list(struct string_list_item *item, void *commit_list)
+static int add_str_to_commit_list(struct string_list_item *item, void *commit_list)
 {
 	struct object_id oid;
 	struct commit *commit;
-- 
2.16.0

```

## Jonathan Nieder, 2018-03-02 03:59

Subject: Re: [PATCH 1/2] ref-filter: mark a file-local symbol as static
Message-ID: <20180302035904.GA238112@aiede.svl.corp.google.com>
URL: https://gitlist.dev/e/20180302035904.GA238112%40aiede.svl.corp.google.com
In-Reply-To: <1d28d866-535c-6d37-4cb9-5decedab3acb@ramsayjones.plus.com>

```
Hi,

Ramsay Jones wrote:

> Commit fcfba37337 ('ref-filter: make "--contains <id>" less chatty if
> <id> is invalid', 2018-02-23) added the add_str_to_commit_list()
> function, which causes sparse to issue a "... not declared. Should it
> be static?" warning for that symbol.

Thanks for catching it!

> In order to suppress the warning, mark that function as static.

Isn't this closer to

	Indeed, the function is only used in this one compilation
	unit. Mark it static.

?  In other words, sparse's warning is accurate, and this is not about
trying to quiet a false positive but about addressing a true positive.

> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
> ---
>  ref-filter.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks,
Jonathan

```

## Ramsay Jones, 2018-03-02 17:06

Subject: Re: [PATCH 1/2] ref-filter: mark a file-local symbol as static
Message-ID: <733494ed-56b1-9072-3c9d-cedc35acd215@ramsayjones.plus.com>
URL: https://gitlist.dev/e/733494ed-56b1-9072-3c9d-cedc35acd215%40ramsayjones.plus.com
In-Reply-To: <20180302035904.GA238112@aiede.svl.corp.google.com>

```


On 02/03/18 03:59, Jonathan Nieder wrote:
> Hi,
> 
> Ramsay Jones wrote:
> 
>> Commit fcfba37337 ('ref-filter: make "--contains <id>" less chatty if
>> <id> is invalid', 2018-02-23) added the add_str_to_commit_list()
>> function, which causes sparse to issue a "... not declared. Should it
>> be static?" warning for that symbol.
> 
> Thanks for catching it!
> 
>> In order to suppress the warning, mark that function as static.
> 
> Isn't this closer to
> 
> 	Indeed, the function is only used in this one compilation
> 	unit. Mark it static.
> 
> ?  In other words, sparse's warning is accurate, and this is not about
> trying to quiet a false positive but about addressing a true positive.

I thought that was implied by the commit subject line. :-D

However, it certainly doesn't hurt to be more explicit.

Junio, do you want me to re-roll, or would you mind tweaking the
commit message while queueing?

Thanks!

ATB,
Ramsay Jones



```

## Junio C Hamano, 2018-03-02 17:19

Subject: Re: [PATCH 1/2] ref-filter: mark a file-local symbol as static
Message-ID: <xmqqinaecs3q.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqinaecs3q.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <733494ed-56b1-9072-3c9d-cedc35acd215@ramsayjones.plus.com>

```
Ramsay Jones <ramsay@ramsayjones.plus.com> writes:

> Junio, do you want me to re-roll, or would you mind tweaking the
> commit message while queueing?

Perfect timing ;-)  I was about to get to these two patches.  Here
is what is queued.

commit 2d7cb07e3718d0af6547e2abb35f9cff9b10c1f5
Author: Ramsay Jones <ramsay@ramsayjones.plus.com>
Date:   Fri Mar 2 02:54:02 2018 +0000

    ref-filter: mark a file-local symbol as static
    
    Commit fcfba37337 ('ref-filter: make "--contains <id>" less chatty if
    <id> is invalid', 2018-02-23) added the add_str_to_commit_list()
    function, which causes sparse to issue a "... not declared. Should it
    be static?" warning for that symbol.
    
    Indeed, the function is only used in this one compilation unit. Mark
    it static.
    
    Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff --git a/ref-filter.c b/ref-filter.c
index aa282a27f4..ed993d32d8 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2000,7 +2000,7 @@ static void do_merge_filter(struct ref_filter_cbdata *ref_cbdata)
 	free(to_clear);
 }
 
-int add_str_to_commit_list(struct string_list_item *item, void *commit_list)
+static int add_str_to_commit_list(struct string_list_item *item, void *commit_list)
 {
 	struct object_id oid;
 	struct commit *commit;


```

## Ramsay Jones, 2018-03-02 17:56

Subject: Re: [PATCH 1/2] ref-filter: mark a file-local symbol as static
Message-ID: <07197560-a6b6-91a0-3750-b17ed7dc5f69@ramsayjones.plus.com>
URL: https://gitlist.dev/e/07197560-a6b6-91a0-3750-b17ed7dc5f69%40ramsayjones.plus.com
In-Reply-To: <xmqqinaecs3q.fsf@gitster-ct.c.googlers.com>

```


On 02/03/18 17:19, Junio C Hamano wrote:
> Ramsay Jones <ramsay@ramsayjones.plus.com> writes:
> 
>> Junio, do you want me to re-roll, or would you mind tweaking the
>> commit message while queueing?
> 
> Perfect timing ;-)  I was about to get to these two patches.  Here
> is what is queued.

Thanks!

ATB,
Ramsay Jones

> commit 2d7cb07e3718d0af6547e2abb35f9cff9b10c1f5
> Author: Ramsay Jones <ramsay@ramsayjones.plus.com>
> Date:   Fri Mar 2 02:54:02 2018 +0000
> 
>     ref-filter: mark a file-local symbol as static
>     
>     Commit fcfba37337 ('ref-filter: make "--contains <id>" less chatty if
>     <id> is invalid', 2018-02-23) added the add_str_to_commit_list()
>     function, which causes sparse to issue a "... not declared. Should it
>     be static?" warning for that symbol.
>     
>     Indeed, the function is only used in this one compilation unit. Mark
>     it static.
>     
>     Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
>     Signed-off-by: Junio C Hamano <gitster@pobox.com>
> 
> diff --git a/ref-filter.c b/ref-filter.c
> index aa282a27f4..ed993d32d8 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -2000,7 +2000,7 @@ static void do_merge_filter(struct ref_filter_cbdata *ref_cbdata)
>  	free(to_clear);
>  }
>  
> -int add_str_to_commit_list(struct string_list_item *item, void *commit_list)
> +static int add_str_to_commit_list(struct string_list_item *item, void *commit_list)
>  {
>  	struct object_id oid;
>  	struct commit *commit;
> 
> 

```
