[vlc-commits] input/decoder: return-statement with expression is ill-formed

Filip Roséen git at videolan.org
Thu Jun 9 19:48:30 CEST 2016


vlc | branch: master | Filip Roséen <filip at videolabs.io> | Thu Jun  9 18:01:45 2016 +0200| [8a052fe34a5b760a71d5d6d6f4b1cb4ae570794e] | committer: Rémi Denis-Courmont

input/decoder: return-statement with expression is ill-formed

Having written too much C++ in my days, I wrongfully assumed that it
was legal to have a return-statement with an expression in a function
returning void, as long as the expression would yield void, in C (as
it is in C++).

However, according to the C99 ISO Standard (section 6.8.6.4p1) this is
not the case.

> [ :: 6.8.6.4p1 :: ]
>
> A return statement with an expression shall not appear in a function
> whose return type is void. A return statement without an expression
> shall only appear in a function whose return type is void.

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8a052fe34a5b760a71d5d6d6f4b1cb4ae570794e
---

 src/input/decoder.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 2df09a9..06e569d 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1330,14 +1330,17 @@ static void DecoderProcess( decoder_t *p_dec, block_t *p_block )
 
 #ifdef ENABLE_SOUT
     if( p_owner->p_sout != NULL )
-        return DecoderProcessSout( p_dec, p_block );
+    {
+        DecoderProcessSout( p_dec, p_block );
+        return;
+    }
 #endif
 
     switch( p_dec->fmt_out.i_cat )
     {
-        case VIDEO_ES: return DecoderProcessVideo( p_dec, p_block );
-        case AUDIO_ES: return DecoderProcessAudio( p_dec, p_block );
-        case   SPU_ES: return DecoderProcessSpu( p_dec, p_block );
+        case VIDEO_ES: DecoderProcessVideo( p_dec, p_block ); return;
+        case AUDIO_ES: DecoderProcessAudio( p_dec, p_block ); return;
+        case   SPU_ES: DecoderProcessSpu( p_dec, p_block ); return;
 
         default:
             msg_Err( p_dec, "unknown ES format" );



More information about the vlc-commits mailing list