Use retro_assert everywhere

This commit is contained in:
twinaphex 2016-09-08 11:59:44 +02:00
parent ea4f85d860
commit db6171676a
9 changed files with 100 additions and 82 deletions

View File

@ -24,6 +24,7 @@
#include <jack/ringbuffer.h>
#include <boolean.h>
#include <retro_assert.h>
#include <rthreads/rthreads.h>
#include "../audio_driver.h"
@ -51,7 +52,7 @@ typedef struct jack
static int process_cb(jack_nframes_t nframes, void *data)
{
int i;
jack_nframes_t f, avail[2], min_avail;
jack_nframes_t avail[2], min_avail;
jack_t *jd = (jack_t*)data;
if (nframes <= 0)
@ -62,8 +63,8 @@ static int process_cb(jack_nframes_t nframes, void *data)
return 0;
}
avail[0] = jack_ringbuffer_read_space(jd->buffer[0]);
avail[1] = jack_ringbuffer_read_space(jd->buffer[1]);
avail[0] = jack_ringbuffer_read_space(jd->buffer[0]);
avail[1] = jack_ringbuffer_read_space(jd->buffer[1]);
min_avail = ((avail[0] < avail[1]) ? avail[0] : avail[1]) / sizeof(jack_default_audio_sample_t);
if (min_avail > nframes)
@ -71,8 +72,10 @@ static int process_cb(jack_nframes_t nframes, void *data)
for (i = 0; i < 2; i++)
{
jack_nframes_t f;
jack_default_audio_sample_t *out = (jack_default_audio_sample_t*)jack_port_get_buffer(jd->ports[i], nframes);
assert(out);
retro_assert(out);
jack_ringbuffer_read(jd->buffer[i], (char*)out, min_avail * sizeof(jack_default_audio_sample_t));
for (f = min_avail; f < nframes; f++)

View File

@ -65,13 +65,13 @@
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdarg.h>
#include <time.h>
#include <errno.h>
#include <compat/strl.h>
#include <retro_inline.h>
#include <retro_assert.h>
#include <retro_miscellaneous.h>
/*
@ -212,7 +212,7 @@ static INLINE int rsnd_format_to_samplesize ( uint16_t fmt )
int rsd_samplesize( rsound_t *rd )
{
assert(rd != NULL);
retro_assert(rd != NULL);
return rd->samplesize;
}
@ -1298,7 +1298,7 @@ static int rsnd_reset(rsound_t *rd)
int rsd_stop(rsound_t *rd)
{
assert(rd != NULL);
retro_assert(rd != NULL);
rsnd_stop_thread(rd);
const char buf[] = "RSD 5 STOP";
@ -1314,7 +1314,7 @@ 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;
assert(rsound != NULL);
retro_assert(rsound != NULL);
if ( !rsound->ready_for_data )
return 0;
@ -1339,11 +1339,11 @@ size_t rsd_write( rsound_t *rsound, const void* buf, size_t size)
int rsd_start(rsound_t *rsound)
{
assert(rsound != NULL);
assert(rsound->rate > 0);
assert(rsound->channels > 0);
assert(rsound->host != NULL);
assert(rsound->port != NULL);
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;
@ -1353,7 +1353,7 @@ int rsd_start(rsound_t *rsound)
int rsd_exec(rsound_t *rsound)
{
assert(rsound != NULL);
retro_assert(rsound != NULL);
RSD_DEBUG("[RSound] rsd_exec().\n");
// Makes sure we have a working connection
@ -1406,8 +1406,8 @@ int rsd_exec(rsound_t *rsound)
/* ioctl()-ish param setting :D */
int rsd_set_param(rsound_t *rd, enum rsd_settings option, void* param)
{
assert(rd != NULL);
assert(param != NULL);
retro_assert(rd != NULL);
retro_assert(param != NULL);
int retval = 0;
switch(option)
@ -1505,7 +1505,7 @@ void rsd_delay_wait(rsound_t *rd)
size_t rsd_pointer(rsound_t *rsound)
{
assert(rsound != NULL);
retro_assert(rsound != NULL);
int ptr;
ptr = rsnd_get_ptr(rsound);
@ -1515,7 +1515,7 @@ size_t rsd_pointer(rsound_t *rsound)
size_t rsd_get_avail(rsound_t *rd)
{
assert(rd != NULL);
retro_assert(rd != NULL);
int ptr;
ptr = rsnd_get_ptr(rd);
return rd->buffer_size - ptr;
@ -1523,7 +1523,7 @@ size_t rsd_get_avail(rsound_t *rd)
size_t rsd_delay(rsound_t *rd)
{
assert(rd != NULL);
retro_assert(rd != NULL);
int ptr = rsnd_get_delay(rd);
if ( ptr < 0 )
ptr = 0;
@ -1533,28 +1533,29 @@ size_t rsd_delay(rsound_t *rd)
size_t rsd_delay_ms(rsound_t* rd)
{
assert(rd);
assert(rd->rate > 0 && rd->channels > 0);
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)
{
assert(rsound != NULL);
retro_assert(rsound != NULL);
if ( enable )
return rsd_stop(rsound);
else
return rsd_start(rsound);
return rsd_start(rsound);
}
int rsd_init(rsound_t** rsound)
{
assert(rsound != NULL);
*rsound = calloc(1, sizeof(rsound_t));
if ( *rsound == NULL )
return -1;
retro_assert(rsound != NULL);
(*rsound)->conn.socket = -1;
(*rsound)->conn.ctl_socket = -1;
@ -1616,7 +1617,7 @@ 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)
{
assert(rsound != NULL);
retro_assert(rsound != NULL);
rsound->audio_callback = audio_cb;
rsound->error_callback = err_cb;
@ -1624,7 +1625,9 @@ void rsd_set_callback(rsound_t *rsound, rsd_audio_callback_t audio_cb, rsd_error
rsound->cb_data = userdata;
if (rsound->audio_callback)
assert(rsound->error_callback);
{
retro_assert(rsound->error_callback);
}
}
void rsd_callback_lock(rsound_t *rsound)
@ -1639,7 +1642,7 @@ void rsd_callback_unlock(rsound_t *rsound)
int rsd_free(rsound_t *rsound)
{
assert(rsound != NULL);
retro_assert(rsound != NULL);
if (rsound->fifo_buffer)
fifo_free(rsound->fifo_buffer);
if (rsound->host)

View File

@ -21,6 +21,7 @@
#include <assert.h>
#include <stdbool.h>
#include <retro_assert.h>
#include <retro_miscellaneous.h>
@ -122,7 +123,7 @@ static void calculate_fft(const float *data, complex double *butterfly_buf, size
unsigned i;
/* Enforce POT. */
assert((samples & (samples - 1)) == 0);
retro_assert((samples & (samples - 1)) == 0);
for (i = 0; i < samples; i++)
butterfly_buf[i] = data[2 * i];
@ -154,7 +155,7 @@ static void calculate_ifft(complex double *butterfly_buf, size_t samples, bool n
unsigned step_size;
/* Enforce POT. */
assert((samples & (samples - 1)) == 0);
retro_assert((samples & (samples - 1)) == 0);
interleave(butterfly_buf, samples);
@ -297,8 +298,8 @@ int main(int argc, char *argv[])
output = calloc(sizeof(float), (fft_samples + 16) * 2);
butterfly_buf = calloc(sizeof(complex double), fft_samples / 2);
assert(input);
assert(output);
retro_assert(input);
retro_assert(output);
if (!rarch_resampler_realloc(&re, &resampler, RESAMPLER_IDENT, ratio))
{

View File

@ -22,13 +22,13 @@
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <assert.h>
#include <drm_fourcc.h>
#include <libdrm/exynos_drmif.h>
#include <exynos/exynos_fimg2d.h>
#include <retro_inline.h>
#include <retro_assert.h>
#include <string/stdstring.h>
#include "../common/drm_common.h"
@ -265,7 +265,8 @@ static const char *exynos_buffer_name(enum exynos_buffer_type type)
case EXYNOS_BUFFER_AUX:
return "aux";
default:
assert(false);
retro_assert(false);
break;
}
return NULL;

View File

@ -33,6 +33,7 @@
#include <linux/omapfb.h>
#include <retro_inline.h>
#include <retro_assert.h>
#include <gfx/scaler/scaler.h>
#include <string/stdstring.h>
@ -333,7 +334,7 @@ static int omapfb_setup_pages(omapfb_data_t *pdata)
static int omapfb_mmap(omapfb_data_t *pdata)
{
assert(pdata->fb_mem == NULL);
retro_assert(pdata->fb_mem == NULL);
pdata->fb_mem = mmap(NULL, pdata->current_state->mi.size, PROT_WRITE,
MAP_SHARED, pdata->fd, 0);
@ -351,9 +352,9 @@ static int omapfb_mmap(omapfb_data_t *pdata)
static int omapfb_backup_state(omapfb_data_t *pdata)
{
void* mem;
void* mem = NULL;
assert(pdata->saved_state == NULL);
retro_assert(pdata->saved_state == NULL);
pdata->saved_state = calloc(1, sizeof(omapfb_state_t));
if (!pdata->saved_state) return -1;
@ -393,14 +394,14 @@ static int omapfb_backup_state(omapfb_data_t *pdata)
static int omapfb_alloc_mem(omapfb_data_t *pdata)
{
unsigned mem_size;
struct omapfb_plane_info pi;
struct omapfb_mem_info mi;
unsigned mem_size;
void* mem = NULL;
void *mem = NULL;
const struct retro_game_geometry *geom = NULL;
struct retro_system_av_info *av_info = NULL;
struct retro_system_av_info *av_info = NULL;
assert(pdata->current_state == NULL);
retro_assert(pdata->current_state == NULL);
pdata->current_state = (omapfb_state_t*)calloc(1, sizeof(omapfb_state_t));
@ -678,14 +679,14 @@ static int omapfb_set_mode(omapfb_data_t *pdata, int width, int height)
static void omapfb_prepare(omapfb_data_t *pdata)
{
omapfb_page_t *page;
omapfb_page_t *page = NULL;
/* issue flip before getting free page */
omapfb_page_flip(pdata);
page = omapfb_get_page(pdata);
assert(page != NULL);
retro_assert(page != NULL);
pdata->old_page = pdata->cur_page;
pdata->cur_page = page;

View File

@ -28,9 +28,10 @@
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <rhash.h>
#include <retro_assert.h>
#include "libretrodb.h"
static void dat_converter_exit(int rc)
@ -163,8 +164,8 @@ static dat_converter_bt_node_t* dat_converter_bt_node_insert(
dat_converter_bt_node_t** node,
dat_converter_map_t* map)
{
assert(map->key);
assert(list->type == DAT_CONVERTER_MAP_LIST);
retro_assert(map->key);
retro_assert(list->type == DAT_CONVERTER_MAP_LIST);
if (!*node)
{
@ -189,7 +190,8 @@ static dat_converter_bt_node_t* dat_converter_bt_node_insert(
if (map->type == DAT_CONVERTER_LIST_MAP)
{
int i;
assert(list->values[(*node)->index].map.value.list->type
retro_assert(list->values[(*node)->index].map.value.list->type
== map->value.list->type);
for (i = 0; i < map->value.list->count; i++)
@ -457,7 +459,7 @@ static const char* dat_converter_get_match(
{
int i;
assert(match_key);
retro_assert(match_key);
if (list->type != DAT_CONVERTER_MAP_LIST)
return NULL;
@ -466,15 +468,16 @@ static const char* dat_converter_get_match(
{
if (list->values[i].map.hash == match_key->hash)
{
assert(!strcmp(list->values[i].map.key, match_key->value));
retro_assert(!strcmp(list->values[i].map.key, match_key->value));
if (match_key->next)
return dat_converter_get_match(
list->values[i].map.value.list, match_key->next);
else if ((list->values[i].map.type == DAT_CONVERTER_STRING_MAP))
if ((list->values[i].map.type == DAT_CONVERTER_STRING_MAP))
return list->values[i].map.value.string;
else
return NULL;
return NULL;
}
}
@ -486,12 +489,12 @@ static dat_converter_list_t* dat_converter_parser(
dat_converter_list_t* lexer_list,
dat_converter_match_key_t* match_key)
{
bool skip = true;
dat_converter_list_item_t* current = lexer_list->values;
dat_converter_map_t map;
dat_converter_list_item_t* current = lexer_list->values;
bool skip = true;
map.key = NULL;
map.type = DAT_CONVERTER_LIST_MAP;
map.key = NULL;
map.type = DAT_CONVERTER_LIST_MAP;
if (!target)
{
@ -637,6 +640,8 @@ static int dat_converter_value_provider(
dat_converter_list_item_t** current_item, struct rmsgpack_dom_value* out)
{
int i;
struct rmsgpack_dom_pair* current = NULL;
out->type = RDT_MAP;
out->val.map.len = 0;
out->val.map.items = calloc((sizeof(rdb_mappings) / sizeof(*rdb_mappings)),
@ -644,16 +649,16 @@ static int dat_converter_value_provider(
(*current_item)--;
assert((*current_item)->map.type == DAT_CONVERTER_LIST_MAP);
retro_assert((*current_item)->map.type == DAT_CONVERTER_LIST_MAP);
dat_converter_list_t* list = (*current_item)->map.value.list;
if (!list)
return 1;
assert(list->type == DAT_CONVERTER_MAP_LIST);
retro_assert(list->type == DAT_CONVERTER_MAP_LIST);
struct rmsgpack_dom_pair* current = out->val.map.items;
current = out->val.map.items;
for (i = 0; i < (sizeof(rdb_mappings) / sizeof(*rdb_mappings)); i++)
{
@ -720,7 +725,7 @@ static int dat_converter_value_provider(
}
break;
default:
assert(0);
retro_assert(0);
break;
}
current++;

View File

@ -18,11 +18,11 @@
#pragma comment(lib, "ws2_32")
#endif
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <compat/strl.h>
#include <retro_assert.h>
#include <net/net_compat.h>
#include <net/net_socket.h>
#include <retro_endianness.h>
@ -64,7 +64,7 @@ static void warn_hangup(void)
*/
bool check_netplay_synched(netplay_t* netplay)
{
assert(netplay);
retro_assert(netplay);
return netplay->frame_count < (netplay->flip_frame + 2 * UDP_FRAME_PACKETS);
}
@ -907,7 +907,7 @@ bool netplay_command(netplay_t* netplay, enum netplay_cmd cmd,
bool host_only = !!(flags & CMD_OPT_HOST_ONLY);
bool require_sync = !!(flags & CMD_OPT_REQUIRE_SYNC);
assert(netplay);
retro_assert(netplay);
if (netplay->spectate.enabled && !allowed_spectate)
{
@ -1063,7 +1063,7 @@ int16_t input_state_spectate_client(unsigned port, unsigned device,
**/
void netplay_pre_frame(netplay_t *netplay)
{
assert(netplay && netplay->net_cbs->pre_frame);
retro_assert(netplay && netplay->net_cbs->pre_frame);
netplay->net_cbs->pre_frame(netplay);
}
@ -1077,7 +1077,7 @@ void netplay_pre_frame(netplay_t *netplay)
**/
void netplay_post_frame(netplay_t *netplay)
{
assert(netplay && netplay->net_cbs->post_frame);
retro_assert(netplay && netplay->net_cbs->post_frame);
netplay->net_cbs->post_frame(netplay);
}

View File

@ -20,7 +20,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <retro_assert.h>
#include <compat/msvc.h>
#include <boolean.h>
#include <queues/fifo_queue.h>
#include <rthreads/rthreads.h>
#include <gfx/scaler/scaler.h>
#include <file/config_file.h>
#include <conversion/float_to_s16.h>
#include <conversion/s16_to_float.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
@ -53,15 +63,6 @@ extern "C" {
}
#endif
#include <compat/msvc.h>
#include <boolean.h>
#include <queues/fifo_queue.h>
#include <rthreads/rthreads.h>
#include <gfx/scaler/scaler.h>
#include <file/config_file.h>
#include <conversion/float_to_s16.h>
#include <conversion/s16_to_float.h>
#include "../record_driver.h"
@ -675,7 +676,7 @@ static bool init_thread(ffmpeg_t *handle)
handle->can_sleep = true;
handle->thread = sthread_create(ffmpeg_thread, handle);
assert(handle->lock && handle->cond_lock &&
retro_assert(handle->lock && handle->cond_lock &&
handle->cond && handle->audio_fifo &&
handle->attr_fifo && handle->video_fifo && handle->thread);
@ -1371,14 +1372,14 @@ static bool ffmpeg_finalize(void *data)
static void ffmpeg_thread(void *data)
{
size_t audio_buf_size;
void *audio_buf;
ffmpeg_t *ff = (ffmpeg_t*)data;
void *audio_buf = NULL;
ffmpeg_t *ff = (ffmpeg_t*)data;
/* For some reason, FFmpeg has a tendency to crash
* if we don't overallocate a bit. */
void *video_buf = av_malloc(2 * ff->params.fb_width *
ff->params.fb_height * ff->video.pix_size);
assert(video_buf);
retro_assert(video_buf);
audio_buf_size = ff->config.audio_enable ?
(ff->audio.codec->frame_size * ff->params.channels * sizeof(int16_t)) : 0;

View File

@ -20,6 +20,9 @@
#ifdef HAVE_COCOA
#include "../ui_cocoa.h"
#endif
#include <retro_assert.h>
#include "../../../verbosity.h"
/* Define compatibility symbols and categories. */
@ -343,7 +346,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
/* Creata a video device and input from that Device. Add the input to the capture session. */
videoDevice = (AVCaptureDevice*)[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if (videoDevice == nil)
assert(0);
retro_assert(0);
/* Add the device to the session. */
input = (AVCaptureDeviceInput*)[AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
@ -351,7 +354,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
if (error)
{
RARCH_ERR("video device input %s\n", error.localizedDescription.UTF8String);
assert(0);
retro_assert(0);
}
[_session addInput:input];