[vlc-devel] [PATCH] Add dummy return values to silence	the	compiler warnings NO RETURN IN NON-VOID function. The	compiler can't know	that this function can't reach the end	(typically due to for ( ; ;	).	Arguably the compiler should see an assert(), but it keeps on	warning	(openSUSE'sBuild System, and possibly others, raise	this to an error due to	potentual undefined behaviour due to	undefined random data being returned.
    Laurent Aimar 
    fenrir at elivagar.org
       
    Tue May  4 01:31:33 CEST 2010
    
    
  
Hi,
On Tue, 2010-05-04 at 01:24 +0200, Dominique Leuenberger wrote:
> diff --git a/modules/access/mms/mmstu.c b/modules/access/mms/mmstu.c
> index 45e363d..8da2bc2 100644
> --- a/modules/access/mms/mmstu.c
> +++ b/modules/access/mms/mmstu.c
> @@ -1570,6 +1570,7 @@ static void *KeepAliveThread( void *p_data )
>          msleep( 10 * CLOCK_FREQ );
>      }
>      assert(0);
> +    return NULL; /* dead code, but the compiler can't know */
>  }
>  
>  static void KeepAliveStart( access_t *p_access )
> diff --git a/modules/control/netsync.c b/modules/control/netsync.c
> index 455be18..01d30cd 100644
> --- a/modules/control/netsync.c
> +++ b/modules/control/netsync.c
> @@ -268,6 +268,7 @@ static void *Slave(void *handle)
>      wait:
>          msleep(INTF_IDLE_SLEEP);
>      }
> +    return NULL; /* dead code, but the compiler can't know */
>  }
>  
>  static int InputEvent(vlc_object_t *object, char const *cmd,
> diff --git a/modules/control/signals.c b/modules/control/signals.c
> index 5cb6f36..96a5389 100644
> --- a/modules/control/signals.c
> +++ b/modules/control/signals.c
> @@ -129,4 +129,5 @@ static void *SigThread (void *data)
>      pthread_sigmask (SIG_UNBLOCK, &set, NULL);
>      for (;;)
>          pause ();
> +    return NULL; /* dead code, but the compiler can't know */
>  }
> diff --git a/modules/demux/live555.cpp b/modules/demux/live555.cpp
> index e6fab0a..8e0cac8 100644
> --- a/modules/demux/live555.cpp
> +++ b/modules/demux/live555.cpp
> @@ -1900,6 +1900,7 @@ static void* TimeoutPrevention( void *p_data )
>          msleep (((int64_t)p_timeout->p_sys->i_timeout - 2) * CLOCK_FREQ);
>      }
>      assert(0); /* dead code */
> +    return NULL; /* dead code, but the compiler can't know */
>  }
>  
>  /*****************************************************************************
> diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
> index ab3907b..a5ff658 100644
> --- a/modules/stream_out/rtp.c
> +++ b/modules/stream_out/rtp.c
> @@ -1672,6 +1672,7 @@ static void *rtp_listen_thread( void *data )
>      }
>  
>      assert( 0 );
> +    return NULL; /* dead code, but the compiler can't know */
>  }
>  
For all those above, the compiler can know it.
 for (;;) code_without_break_and_return;
will obviously not quit ...
I think that with some version of compiler you may then introduce
warning about dead code.
> 
> diff --git a/src/modules/cache.c b/src/modules/cache.c
> index 3f09ad8..045525a 100644
> --- a/src/modules/cache.c
> +++ b/src/modules/cache.c
> @@ -333,6 +333,7 @@ static int dummy_callback (vlc_object_t *obj, const char *name,
>  {
>      (void) obj; (void)name; (void)oldval; (void)newval; (void)data;
>      assert (0);
> +    return 0; /* dead code, but the compiler can't know */
>  }
 For this one, I agree it might be better to add it as the compiler
can't know it, but I will let Rémi comments.
-- 
fenrir
    
    
More information about the vlc-devel
mailing list