# [PATCH] oidset: don't return value from oidset_init

3 messages from 2018-01-07 to 2018-01-09. Participants: Thomas Gummerer, Junio C Hamano, Johannes Sixt.
Thread: https://gitlist.dev/t/47562

## Thomas Gummerer, 2018-01-07 23:04

Subject: [PATCH] oidset: don't return value from oidset_init
Message-ID: <20180107230404.23289-1-t.gummerer@gmail.com>
URL: https://gitlist.dev/e/20180107230404.23289-1-t.gummerer%40gmail.com

```
c3a9ad3117 ("oidset: add iterator methods to oidset", 2017-11-21)
introduced a 'oidset_init()' function in oidset.h, which has void as
return type, but returns an expression.

This makes the solaris compiler fail with:

    "oidset.h", line 30: void function cannot return value

As the return type is void, and even the return type of the expression
we're trying to return (oidmap_init) is void just remove the return
statement to fix the compiler error.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
---
 oidset.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/oidset.h b/oidset.h
index 783abceccd..40ec5f87fe 100644
--- a/oidset.h
+++ b/oidset.h
@@ -27,7 +27,7 @@ struct oidset {
 
 static inline void oidset_init(struct oidset *set, size_t initial_size)
 {
-	return oidmap_init(&set->map, initial_size);
+	oidmap_init(&set->map, initial_size);
 }
 
 /**
-- 
2.16.0.rc1.238.g530d649a79


```

## Junio C Hamano, 2018-01-08 23:26

Subject: Re: [PATCH] oidset: don't return value from oidset_init
Message-ID: <xmqqincc6if3.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqincc6if3.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <20180107230404.23289-1-t.gummerer@gmail.com>

```
Thomas Gummerer <t.gummerer@gmail.com> writes:

> c3a9ad3117 ("oidset: add iterator methods to oidset", 2017-11-21)
> introduced a 'oidset_init()' function in oidset.h, which has void as
> return type, but returns an expression.
> ...
> diff --git a/oidset.h b/oidset.h
> index 783abceccd..40ec5f87fe 100644
> --- a/oidset.h
> +++ b/oidset.h
> @@ -27,7 +27,7 @@ struct oidset {
>  
>  static inline void oidset_init(struct oidset *set, size_t initial_size)
>  {
> -	return oidmap_init(&set->map, initial_size);
> +	oidmap_init(&set->map, initial_size);
>  }

Makes sense.  Perhaps "inline" hids this from error-checking
compilers, I wonder?


```

## Johannes Sixt, 2018-01-09 07:33

Subject: Re: [PATCH] oidset: don't return value from oidset_init
Message-ID: <63acb4e5-4ebe-0fc3-a9ba-8141cceeee0c@kdbg.org>
URL: https://gitlist.dev/e/63acb4e5-4ebe-0fc3-a9ba-8141cceeee0c%40kdbg.org
In-Reply-To: <xmqqincc6if3.fsf@gitster.mtv.corp.google.com>

```
Am 09.01.2018 um 00:26 schrieb Junio C Hamano:
> Thomas Gummerer <t.gummerer@gmail.com> writes:
> 
>> c3a9ad3117 ("oidset: add iterator methods to oidset", 2017-11-21)
>> introduced a 'oidset_init()' function in oidset.h, which has void as
>> return type, but returns an expression.
>> ...
>> diff --git a/oidset.h b/oidset.h
>> index 783abceccd..40ec5f87fe 100644
>> --- a/oidset.h
>> +++ b/oidset.h
>> @@ -27,7 +27,7 @@ struct oidset {
>>   
>>   static inline void oidset_init(struct oidset *set, size_t initial_size)
>>   {
>> -	return oidmap_init(&set->map, initial_size);
>> +	oidmap_init(&set->map, initial_size);
>>   }
> 
> Makes sense.  Perhaps "inline" hids this from error-checking
> compilers, I wonder?

outmap_init returns void itself. It is a modern language feature, I 
guess, that this void "value" can be forwarded in a return statement.

-- Hannes

```
