Skip to content

Commit

Permalink
Remove asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Jan 8, 2023
1 parent 84b0546 commit daa9e35
Show file tree
Hide file tree
Showing 52 changed files with 67 additions and 320 deletions.
19 changes: 2 additions & 17 deletions audio/audio_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <string/stdstring.h>
#include <encodings/utf.h>
#include <clamping.h>
#include <retro_assert.h>
#include <memalign.h>
#include <audio/conversion/float_to_s16.h>
#include <audio/conversion/s16_to_float.h>
Expand Down Expand Up @@ -584,10 +583,6 @@ bool audio_driver_init_internal(
convert_s16_to_float_init_simd();
convert_float_to_s16_init_simd();

/* Used for recording even if audio isn't enabled. */
retro_assert(conv_buf != NULL);
retro_assert(audio_buf != NULL);

if (!conv_buf || !audio_buf)
goto error;

Expand All @@ -602,10 +597,7 @@ bool audio_driver_init_internal(
#ifdef HAVE_REWIND
/* Needs to be able to hold full content of a full max_bufsamples
* in addition to its own. */
rewind_buf = (int16_t*)memalign_alloc(64, max_bufsamples * sizeof(int16_t));
retro_assert(rewind_buf != NULL);

if (!rewind_buf)
if (!(rewind_buf = (int16_t*)memalign_alloc(64, max_bufsamples * sizeof(int16_t))))
goto error;

audio_driver_st.rewind_buf = rewind_buf;
Expand Down Expand Up @@ -727,14 +719,7 @@ bool audio_driver_init_internal(

audio_driver_st.data_ptr = 0;

retro_assert(settings->uints.audio_output_sample_rate <
audio_driver_st.input * AUDIO_MAX_RATIO);

samples_buf = (float*)memalign_alloc(64, outsamples_max * sizeof(float));

retro_assert(samples_buf != NULL);

if (!samples_buf)
if (!(samples_buf = (float*)memalign_alloc(64, outsamples_max * sizeof(float))))
goto error;

audio_driver_st.output_samples_buf = (float*)samples_buf;
Expand Down
49 changes: 6 additions & 43 deletions audio/librsound.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@

#include <compat/strl.h>
#include <retro_inline.h>
#include <retro_assert.h>
#include <retro_miscellaneous.h>
#include <retro_timers.h>

Expand Down Expand Up @@ -224,7 +223,6 @@ static INLINE int rsnd_format_to_samplesize ( uint16_t fmt )

int rsd_samplesize( rsound_t *rd )
{
retro_assert(rd != NULL);
return rd->samplesize;
}

Expand Down Expand Up @@ -1315,7 +1313,6 @@ int rsd_stop(rsound_t *rd)
{
const char buf[] = "RSD 5 STOP";

retro_assert(rd != NULL);
rsnd_stop_thread(rd);

/* Do not really care about errors here.
Expand All @@ -1329,7 +1326,6 @@ int rsd_stop(rsound_t *rd)
size_t rsd_write( rsound_t *rsound, const void* buf, size_t size)
{
size_t max_write, written = 0;
retro_assert(rsound != NULL);
if ( !rsound->ready_for_data )
return 0;

Expand All @@ -1354,21 +1350,13 @@ size_t rsd_write( rsound_t *rsound, const void* buf, size_t size)

int rsd_start(rsound_t *rsound)
{
retro_assert(rsound != NULL);
retro_assert(rsound->rate > 0);
retro_assert(rsound->channels > 0);
retro_assert(rsound->host != NULL);
retro_assert(rsound->port != NULL);

if ( rsnd_create_connection(rsound) < 0 )
return -1;

return 0;
}

int rsd_exec(rsound_t *rsound)
{
retro_assert(rsound != NULL);
RSD_DEBUG("[RSound] rsd_exec().\n");

/* Makes sure we have a working connection */
Expand Down Expand Up @@ -1419,8 +1407,6 @@ int rsd_exec(rsound_t *rsound)
/* ioctl()-ish param setting :D */
int rsd_set_param(rsound_t *rd, enum rsd_settings option, void* param)
{
retro_assert(rd != NULL);
retro_assert(param != NULL);
int retval = 0;

switch(option)
Expand Down Expand Up @@ -1517,44 +1503,31 @@ void rsd_delay_wait(rsound_t *rd)

size_t rsd_pointer(rsound_t *rsound)
{
retro_assert(rsound != NULL);
int ptr;

ptr = rsnd_get_ptr(rsound);

return ptr;
return rsnd_get_ptr(rsound);
}

size_t rsd_get_avail(rsound_t *rd)
{
retro_assert(rd != NULL);
int ptr;
ptr = rsnd_get_ptr(rd);
return rd->buffer_size - ptr;
return rd->buffer_size - rsnd_get_ptr(rd);
}

size_t rsd_delay(rsound_t *rd)
{
retro_assert(rd != NULL);
int ptr = rsnd_get_delay(rd);
if ( ptr < 0 )
if (ptr < 0)
ptr = 0;

return ptr;
}

size_t rsd_delay_ms(rsound_t* rd)
{
retro_assert(rd);
retro_assert(rd->rate > 0 && rd->channels > 0);

return (rsd_delay(rd) * 1000) / ( rd->rate * rd->channels * rd->samplesize );
}

int rsd_pause(rsound_t* rsound, int enable)
{
retro_assert(rsound != NULL);
if ( enable )
if (enable)
return rsd_stop(rsound);

return rsd_start(rsound);
Expand All @@ -1567,8 +1540,6 @@ int rsd_init(rsound_t** rsound)
if (*rsound == NULL)
return -1;

retro_assert(rsound != NULL);

(*rsound)->conn.socket = -1;
(*rsound)->conn.ctl_socket = -1;

Expand Down Expand Up @@ -1629,17 +1600,10 @@ int rsd_simple_start(rsound_t** rsound, const char* host, const char* port, cons

void rsd_set_callback(rsound_t *rsound, rsd_audio_callback_t audio_cb, rsd_error_callback_t err_cb, size_t max_size, void *userdata)
{
retro_assert(rsound != NULL);

rsound->audio_callback = audio_cb;
rsound->error_callback = err_cb;
rsound->cb_max_size = max_size;
rsound->cb_data = userdata;

if (rsound->audio_callback)
{
retro_assert(rsound->error_callback);
}
rsound->cb_max_size = max_size;
rsound->cb_data = userdata;
}

void rsd_callback_lock(rsound_t *rsound)
Expand All @@ -1654,7 +1618,6 @@ void rsd_callback_unlock(rsound_t *rsound)

int rsd_free(rsound_t *rsound)
{
retro_assert(rsound != NULL);
if (rsound->fifo_buffer)
fifo_free(rsound->fifo_buffer);
if (rsound->host)
Expand Down
4 changes: 0 additions & 4 deletions camera/drivers/video4linux2.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <malloc.h>
#endif
#include <string.h>
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <fcntl.h>
Expand All @@ -37,7 +36,6 @@

#include <memmap.h>

#include <retro_assert.h>
#include <retro_miscellaneous.h>
#include <gfx/scaler/scaler.h>
#include <gfx/video_frame.h>
Expand Down Expand Up @@ -380,8 +378,6 @@ static bool preprocess_image(void *data)
return false;
}

retro_assert(buf.index < v4l->n_buffers);

ctx = &v4l->scaler;

scaler_ctx_scale_direct(ctx, v4l->buffer_output, (const uint8_t*)v4l->buffers[buf.index].start);
Expand Down
17 changes: 0 additions & 17 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <file/file_path.h>
#include <compat/strl.h>
#include <compat/posix_string.h>
#include <retro_assert.h>
#include <string/stdstring.h>
#include <streams/file_stream.h>
#include <array/rhmap.h>
Expand Down Expand Up @@ -2717,22 +2716,6 @@ void config_set_defaults(void *data)
input_remapping_deinit(false);
input_remapping_set_defaults(false);

/* Verify that binds are in proper order. */
for (i = 0; i < MAX_USERS; i++)
{
for (j = 0; j < RARCH_BIND_LIST_END; j++)
{
const struct retro_keybind *keyval = &input_config_binds[i][j];

/* No need to verify hotkeys for all users */
if (i > 0 && j > RARCH_CUSTOM_BIND_LIST_END)
continue;

if (keyval->valid)
retro_assert(j == keyval->id);
}
}

configuration_set_string(settings,
settings->paths.network_buildbot_url, DEFAULT_BUILDBOT_SERVER_URL);
configuration_set_string(settings,
Expand Down
3 changes: 0 additions & 3 deletions core_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#include <retro_assert.h>
#include <compat/strl.h>
#include <string/stdstring.h>
#include <file/config_file.h>
Expand Down Expand Up @@ -386,7 +385,6 @@ static bool CCJSONEndObjectHandler(void *context)
&& (pCtx->array_depth == 1))
pCtx->to_core_file_id = false;

retro_assert(pCtx->object_depth > 0);
pCtx->object_depth--;

return true;
Expand All @@ -406,7 +404,6 @@ static bool CCJSONEndArrayHandler(void *context)
if ((pCtx->object_depth == 2) && (pCtx->array_depth == 2))
pCtx->to_firmware = false;

retro_assert(pCtx->array_depth > 0);
pCtx->array_depth--;

return true;
Expand Down
1 change: 0 additions & 1 deletion cores/libretro-ffmpeg/ffmpeg_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <assert.h>
#include <stdarg.h>

#ifdef RARCH_INTERNAL
Expand Down
1 change: 0 additions & 1 deletion cores/libretro-imageviewer/image_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

#include <boolean.h>
#include <lists/dir_list.h>
Expand Down
15 changes: 5 additions & 10 deletions frontend/drivers/platform_darwin.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@

#include <boolean.h>
#include <compat/apple_compat.h>
#include <retro_assert.h>
#include <retro_miscellaneous.h>
#include <file/file_path.h>
#include <streams/file_stream.h>
Expand Down Expand Up @@ -368,17 +367,13 @@ static void frontend_darwin_get_env(int *argc, char *argv[],

#if TARGET_OS_IPHONE
if (realpath(home_dir_buf, resolved_home_dir_buf))
{
retro_assert(strlcpy(home_dir_buf,
strlcpy(home_dir_buf,
resolved_home_dir_buf,
sizeof(home_dir_buf)) < sizeof(home_dir_buf));
}
sizeof(home_dir_buf));
if (realpath(bundle_path_buf, resolved_bundle_dir_buf))
{
retro_assert(strlcpy(bundle_path_buf,
resolved_bundle_dir_buf,
sizeof(bundle_path_buf)) < sizeof(bundle_path_buf));
}
strlcpy(bundle_path_buf,
resolved_bundle_dir_buf,
sizeof(bundle_path_buf);
#endif

strlcat(home_dir_buf, "/RetroArch", sizeof(home_dir_buf));
Expand Down
2 changes: 0 additions & 2 deletions gfx/common/angle_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

#include <stdlib.h>

#include <retro_assert.h>

#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
Expand Down
1 change: 0 additions & 1 deletion gfx/common/d3d10_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ d3d10_get_closest_match(D3D10Device device,
break;
format++;
}
assert(*format);
return *format;
}

Expand Down
1 change: 0 additions & 1 deletion gfx/common/d3d11_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ d3d11_get_closest_match(D3D11Device device, DXGI_FORMAT desired_format, UINT des
break;
format++;
}
assert(*format);
return *format;
}

Expand Down
1 change: 0 additions & 1 deletion gfx/common/d3d11_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#endif
#include <d3d11.h>

#include <assert.h>
#include <boolean.h>
#include <retro_math.h>
#include <gfx/math/matrix_4x4.h>
Expand Down
Loading

0 comments on commit daa9e35

Please sign in to comment.