diff mbox series

[FFmpeg-devel] fftools/objpool: Don't use return with expression when returning void

Message ID DB6PR0101MB22149A96B17C439FB86A651B8F939@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Superseded
Headers show
Series [FFmpeg-devel] fftools/objpool: Don't use return with expression when returning void | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt July 23, 2022, 4:24 p.m. UTC
Using tail calls with functions returning void is forbidden
(C99/C11 6.8.6.4: "A return statement with an expression shall not appear
in a function whose return type is void.") GCC emits a warning
because of this when using -pedantic: "ISO C forbids ‘return’ with
expression, in function returning void"

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 fftools/objpool.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Hendrik Leppkes July 23, 2022, 4:51 p.m. UTC | #1
On Sat, Jul 23, 2022 at 6:24 PM Andreas Rheinhardt
<andreas.rheinhardt@outlook.com> wrote:
>
> Using tail calls with functions returning void is forbidden
> (C99/C11 6.8.6.4: "A return statement with an expression shall not appear
> in a function whose return type is void.") GCC emits a warning
> because of this when using -pedantic: "ISO C forbids ‘return’ with
> expression, in function returning void"
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  fftools/objpool.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fftools/objpool.c b/fftools/objpool.c
> index b1561ecd69..06e4f069a5 100644
> --- a/fftools/objpool.c
> +++ b/fftools/objpool.c
> @@ -101,11 +101,13 @@ static void *alloc_frame(void)
>
>  static void reset_packet(void *obj)
>  {
> -    return av_packet_unref(obj);
> +    av_packet_unref(obj);
> +    return;
>  }
>  static void reset_frame(void *obj)
>  {
> -    return av_frame_unref(obj);
> +    av_frame_unref(obj);
> +    return;
>  }
>

Maybe leave out the return's entirely? Its not a pattern we typically
use to have return at the end of a function.

- Hendrik
Andreas Rheinhardt July 23, 2022, 4:53 p.m. UTC | #2
Hendrik Leppkes:
> On Sat, Jul 23, 2022 at 6:24 PM Andreas Rheinhardt
> <andreas.rheinhardt@outlook.com> wrote:
>>
>> Using tail calls with functions returning void is forbidden
>> (C99/C11 6.8.6.4: "A return statement with an expression shall not appear
>> in a function whose return type is void.") GCC emits a warning
>> because of this when using -pedantic: "ISO C forbids ‘return’ with
>> expression, in function returning void"
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>>  fftools/objpool.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/fftools/objpool.c b/fftools/objpool.c
>> index b1561ecd69..06e4f069a5 100644
>> --- a/fftools/objpool.c
>> +++ b/fftools/objpool.c
>> @@ -101,11 +101,13 @@ static void *alloc_frame(void)
>>
>>  static void reset_packet(void *obj)
>>  {
>> -    return av_packet_unref(obj);
>> +    av_packet_unref(obj);
>> +    return;
>>  }
>>  static void reset_frame(void *obj)
>>  {
>> -    return av_frame_unref(obj);
>> +    av_frame_unref(obj);
>> +    return;
>>  }
>>
> 
> Maybe leave out the return's entirely? Its not a pattern we typically
> use to have return at the end of a function.
> 

Thanks for reminding me that void functions don't need a return at the
end at all. I feel stupid right now.

- Andreas
diff mbox series

Patch

diff --git a/fftools/objpool.c b/fftools/objpool.c
index b1561ecd69..06e4f069a5 100644
--- a/fftools/objpool.c
+++ b/fftools/objpool.c
@@ -101,11 +101,13 @@  static void *alloc_frame(void)
 
 static void reset_packet(void *obj)
 {
-    return av_packet_unref(obj);
+    av_packet_unref(obj);
+    return;
 }
 static void reset_frame(void *obj)
 {
-    return av_frame_unref(obj);
+    av_frame_unref(obj);
+    return;
 }
 
 static void free_packet(void **obj)