Commit 80d88b05 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

Mark unreachable code on GCC even if NDEBUG

This might suppress some warnings (and very slightly reduce code size)
when assertions are disabled. Not that I particularly like to create
VLC-specific macros.
parent c63f722d
......@@ -112,13 +112,17 @@
/* Branch prediction */
#ifdef __GNUC__
# define likely(p) __builtin_expect(!!(p), 1)
# define unlikely(p) __builtin_expect(!!(p), 0)
# define likely(p) __builtin_expect(!!(p), 1)
# define unlikely(p) __builtin_expect(!!(p), 0)
# define unreachable() __builtin_unreachable()
#else
# define likely(p) (!!(p))
# define unlikely(p) (!!(p))
# define likely(p) (!!(p))
# define unlikely(p) (!!(p))
# define unreachable() ((void)0)
#endif
#define vlc_assert_unreachable() (assert(!"unreachable"), unreachable())
/* Linkage */
#ifdef __cplusplus
# define VLC_EXTERN extern "C"
......
......@@ -373,7 +373,7 @@ int event_attach( libvlc_event_manager_t * p_event_manager,
free(listener);
fprintf( stderr, "This object event manager doesn't know about '%s' events",
libvlc_event_type_name(event_type) );
assert(0);
vlc_assert_unreachable();
return -1;
}
......
......@@ -773,7 +773,7 @@ static int onMouseEvent(vlc_object_t *p_vout, const char *psz_var, vlc_value_t o
bd_mouse_select(p_sys->bluray, now, val.coords.x, val.coords.y);
bd_user_input(p_sys->bluray, now, BD_VK_MOUSE_ACTIVATE);
} else {
assert(0);
vlc_assert_unreachable();
}
return VLC_SUCCESS;
}
......
......@@ -2108,7 +2108,7 @@ void en50221_Poll( cam_t * p_cam )
case CA_CI:
return;
default:
assert( 0 );
vlc_assert_unreachable();
}
for ( unsigned i_slot = 0; i_slot < p_cam->i_nb_slots; i_slot++ )
......
......@@ -366,7 +366,7 @@ static ssize_t StreamRead (access_t *p_access, uint8_t *p_buffer, size_t i_len)
static int NoSeek (access_t *p_access, uint64_t i_pos)
{
/* assert(0); ?? */
/* vlc_assert_unreachable(); ?? */
(void) p_access; (void) i_pos;
return VLC_EGENERIC;
}
......
......@@ -429,7 +429,7 @@ connect:
break;
default:
assert(0);
vlc_assert_unreachable();
}
if( p_sys->i_code == 401 )
......
......@@ -2107,7 +2107,7 @@ static void* TimeoutPrevention( void *p_data )
msleep (((int64_t)p_timeout->p_sys->i_timeout - 2) * CLOCK_FREQ);
}
assert(0); /* dead code */
vlc_assert_unreachable(); /* dead code */
}
/*****************************************************************************
......
......@@ -1573,7 +1573,7 @@ static void *KeepAliveThread( void *p_data )
msleep( 10 * CLOCK_FREQ );
}
assert(0);
vlc_assert_unreachable();
}
static void KeepAliveStart( access_t *p_access )
......
......@@ -172,7 +172,7 @@ static int ControlSetCallback (vlc_object_t *obj, const char *var,
ret = ControlSetStr (ctrl, cur.psz_string);
break;
default:
assert (0);
vlc_assert_unreachable ();
}
if (ret)
......
......@@ -631,7 +631,7 @@ static void *MmapThread (void *data)
#endif
}
assert (0);
vlc_assert_unreachable ();
}
static void *ReadThread (void *data)
......@@ -693,7 +693,7 @@ static void *ReadThread (void *data)
GrabVBI (demux, sys->vbi);
#endif
}
assert (0);
vlc_assert_unreachable ();
}
static int DemuxControl( demux_t *demux, int query, va_list args )
......
......@@ -159,8 +159,7 @@ static inline uint32_t CanonicaliseChannels( uint32_t i_physical_channels )
if( (i_physical_channels & ~valid_channels[i]) == 0 )
return valid_channels[i];
assert( false );
return 0;
vlc_assert_unreachable();
}
/*****************************************************************************
......
......@@ -224,7 +224,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *fmt)
fmt->i_physical_channels = AOUT_CHANS_7_1;
break;
default:
assert(0);
vlc_assert_unreachable();
}
fmt->i_format = VLC_CODEC_S16N;
......
......@@ -611,8 +611,7 @@ JNIThread( void *data )
&p_sys->p_cmd->out.time_get.i_delay );
break;
default:
assert( false );
break;
vlc_assert_unreachable();
}
if( b_error )
p_sys->b_thread_run = false;
......
......@@ -430,7 +430,7 @@ static void context_cb(pa_context *ctx, pa_subscription_event_type_t type,
break;
default: /* unsubscribed facility?! */
assert(0);
vlc_assert_unreachable();
}
}
......
......@@ -479,7 +479,7 @@ static int Eia608GetWritingScreenIndex( eia608_t *h )
return h->i_screen;
default:
/* It cannot happen, else it is a bug */
assert( 0 );
vlc_assert_unreachable();
return 0;
}
}
......
......@@ -273,7 +273,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_packetizer )
p_dec->fmt_out.i_codec = VLC_CODEC_WIDI_LPCM;
break;
default:
assert(0);
vlc_assert_unreachable();
case LPCM_BD:
p_dec->fmt_out.i_codec = VLC_CODEC_BD_LPCM;
break;
......@@ -451,7 +451,7 @@ static block_t *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
AobExtract( p_aout_buffer, p_block, i_bits, p_aob_group );
break;
default:
assert(0);
vlc_assert_unreachable();
case LPCM_BD:
BdExtract( p_aout_buffer, p_block, i_frame_length, i_channels, i_channels_padding, i_bits );
break;
......@@ -575,7 +575,7 @@ static block_t *EncodeFrames( encoder_t *p_enc, block_t *p_aout_buf )
i_freq_code = 3;
break;
default:
assert(0);
vlc_assert_unreachable();
}
int i_bytes_consumed = 0;
......
......@@ -630,7 +630,7 @@ static void ProcessEvents( intf_thread_t *p_intf,
break;
}
default:
assert(0);
vlc_assert_unreachable();
}
free( p_events[i] );
}
......@@ -1015,7 +1015,7 @@ static int AllCallback( vlc_object_t *p_this, const char *psz_var,
else if( !strcmp( "can-pause", psz_var ) )
info.signal = SIGNAL_CAN_PAUSE;
else
assert(0);
vlc_assert_unreachable();
if( info.signal == SIGNAL_NONE )
return VLC_SUCCESS;
......
......@@ -188,7 +188,7 @@ static void *RunIntf( void *data )
vlc_restorecancel( canc );
}
assert(0);
vlc_assert_unreachable();
}
#undef LOW_THRESHOLD
#undef HIGH_THRESHOLD
......@@ -194,7 +194,7 @@ static int GetOrientation( motion_sensors_t *motion )
return 0;
#endif
default:
assert( 0 );
vlc_assert_unreachable();
}
}
......
......@@ -1540,7 +1540,7 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
}
else
/* This case can't happen */
assert( 0 );
vlc_assert_unreachable();
if( newval.psz_string && *newval.psz_string )
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment