mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
Cleanups - Replace '== NULL'
This commit is contained in:
parent
f762ea6412
commit
74cd84399f
@ -45,7 +45,7 @@ static void *ra_init(const char *device, unsigned rate, unsigned latency,
|
||||
|
||||
(void)latency;
|
||||
|
||||
if ((vss = roar_vs_new_simple(device, "RetroArch", rate, 2, ROAR_CODEC_PCM_S, 16, ROAR_DIR_PLAY, &err)) == NULL)
|
||||
if (!(vss = roar_vs_new_simple(device, "RetroArch", rate, 2, ROAR_CODEC_PCM_S, 16, ROAR_DIR_PLAY, &err)))
|
||||
{
|
||||
RARCH_ERR("RoarAudio: \"%s\"\n", roar_vs_strerr(err));
|
||||
free(roar);
|
||||
|
@ -234,7 +234,7 @@ static int rsnd_connect_server( rsound_t *rd )
|
||||
if (!isdigit(rd->host[0]))
|
||||
{
|
||||
struct hostent *host = gethostbyname(rd->host);
|
||||
if (host == NULL)
|
||||
if (!host)
|
||||
return -1;
|
||||
|
||||
addr.sin_addr.s_addr = inet_addr(host->h_addr_list[0]);
|
||||
@ -295,7 +295,7 @@ static int rsnd_send_header_info(rsound_t *rd)
|
||||
/* Defines the size of a wave header */
|
||||
#define HEADER_SIZE 44
|
||||
char *header = calloc(1, HEADER_SIZE);
|
||||
if (header == NULL)
|
||||
if (!header)
|
||||
{
|
||||
RSD_ERR("[RSound] Could not allocate memory.");
|
||||
return -1;
|
||||
@ -472,7 +472,7 @@ static int rsnd_get_backend_info ( rsound_t *rd )
|
||||
if ( rd->fifo_buffer != NULL )
|
||||
fifo_free(rd->fifo_buffer);
|
||||
rd->fifo_buffer = fifo_new (rd->buffer_size);
|
||||
if ( rd->fifo_buffer == NULL )
|
||||
if (!rd->fifo_buffer)
|
||||
{
|
||||
RSD_ERR("[RSound] Failed to create FIFO buffer.\n");
|
||||
return -1;
|
||||
@ -963,7 +963,7 @@ static int rsnd_close_ctl(rsound_t *rd)
|
||||
return -1;
|
||||
|
||||
subchar = strrchr(buf, 'R');
|
||||
if ( subchar == NULL )
|
||||
if (!subchar)
|
||||
index = 0;
|
||||
else
|
||||
{
|
||||
@ -1023,7 +1023,7 @@ static int rsnd_update_server_info(rsound_t *rd)
|
||||
|
||||
temp[RSD_PROTO_CHUNKSIZE] = '\0';
|
||||
|
||||
if ( (substr = strstr(temp, "RSD")) == NULL )
|
||||
if (!(substr = strstr(temp, "RSD")))
|
||||
return -1;
|
||||
|
||||
// Jump over "RSD" in header
|
||||
@ -1038,7 +1038,7 @@ static int rsnd_update_server_info(rsound_t *rd)
|
||||
|
||||
// We only bother if this is an INFO message.
|
||||
substr = strstr(temp, "INFO");
|
||||
if ( substr == NULL )
|
||||
if (!substr)
|
||||
continue;
|
||||
|
||||
// Jump over "INFO" in header
|
||||
@ -1548,7 +1548,7 @@ int rsd_pause(rsound_t* rsound, int enable)
|
||||
int rsd_init(rsound_t** rsound)
|
||||
{
|
||||
*rsound = calloc(1, sizeof(rsound_t));
|
||||
if ( *rsound == NULL )
|
||||
if (*rsound == NULL)
|
||||
return -1;
|
||||
|
||||
retro_assert(rsound != NULL);
|
||||
|
@ -176,7 +176,7 @@ static void x11_set_window_pid(Display *dpy, Window win)
|
||||
errno = 0;
|
||||
if ((scret = sysconf(_SC_HOST_NAME_MAX)) == -1 && errno)
|
||||
return;
|
||||
if ((hostname = (char*)malloc(scret + 1)) == NULL)
|
||||
if (!(hostname = (char*)malloc(scret + 1)))
|
||||
return;
|
||||
|
||||
if (gethostname(hostname, scret + 1) == -1)
|
||||
|
@ -507,7 +507,7 @@ static void dispmanx_set_texture_frame(void *data, const void *frame, bool rgb32
|
||||
return;
|
||||
|
||||
/* If menu is active in this frame but our menu surface is NULL, we allocate a new one.*/
|
||||
if (_dispvars->menu_surface == NULL)
|
||||
if (!_dispvars->menu_surface)
|
||||
{
|
||||
_dispvars->menu_width = width;
|
||||
_dispvars->menu_height = height;
|
||||
|
@ -337,8 +337,6 @@ static int omapfb_setup_pages(omapfb_data_t *pdata)
|
||||
|
||||
static int omapfb_mmap(omapfb_data_t *pdata)
|
||||
{
|
||||
retro_assert(pdata->fb_mem == NULL);
|
||||
|
||||
pdata->fb_mem = mmap(NULL, pdata->current_state->mi.size, PROT_WRITE,
|
||||
MAP_SHARED, pdata->fd, 0);
|
||||
|
||||
@ -357,8 +355,6 @@ static int omapfb_backup_state(omapfb_data_t *pdata)
|
||||
{
|
||||
void* mem = NULL;
|
||||
|
||||
retro_assert(pdata->saved_state == NULL);
|
||||
|
||||
pdata->saved_state = calloc(1, sizeof(omapfb_state_t));
|
||||
if (!pdata->saved_state) return -1;
|
||||
|
||||
@ -383,7 +379,7 @@ static int omapfb_backup_state(omapfb_data_t *pdata)
|
||||
pdata->saved_state->mem = malloc(pdata->saved_state->mi.size);
|
||||
mem = mmap(NULL, pdata->saved_state->mi.size, PROT_WRITE|PROT_READ,
|
||||
MAP_SHARED, pdata->fd, 0);
|
||||
if (pdata->saved_state->mem == NULL || mem == MAP_FAILED)
|
||||
if (!pdata->saved_state->mem || mem == MAP_FAILED)
|
||||
{
|
||||
RARCH_ERR("[video_omap]: backup layer (mem backup) failed\n");
|
||||
munmap(mem, pdata->saved_state->mi.size);
|
||||
@ -404,8 +400,6 @@ static int omapfb_alloc_mem(omapfb_data_t *pdata)
|
||||
const struct retro_game_geometry *geom = NULL;
|
||||
struct retro_system_av_info *av_info = NULL;
|
||||
|
||||
retro_assert(pdata->current_state == NULL);
|
||||
|
||||
pdata->current_state = (omapfb_state_t*)calloc(1, sizeof(omapfb_state_t));
|
||||
|
||||
if (!pdata->current_state)
|
||||
|
@ -52,9 +52,8 @@ extern pad_connection_interface_t wiiu_gca_pad_connection;
|
||||
|
||||
static void *wiiu_gca_init(void *handle)
|
||||
{
|
||||
RARCH_LOG("[gca]: allocating driver instance...\n");
|
||||
hid_wiiu_gca_instance_t *instance = calloc(1, sizeof(hid_wiiu_gca_instance_t));
|
||||
if(instance == NULL)
|
||||
if (!instance)
|
||||
return NULL;
|
||||
memset(instance, 0, sizeof(hid_wiiu_gca_instance_t));
|
||||
instance->handle = handle;
|
||||
@ -129,12 +128,12 @@ static void wiiu_gca_update_pad_state(hid_wiiu_gca_instance_t *instance)
|
||||
|
||||
if(port_connected > GCA_PORT_POWERED)
|
||||
{
|
||||
if(pad == NULL)
|
||||
if (!pad)
|
||||
{
|
||||
RARCH_LOG("[gca]: Gamepad at port %d connected.\n", port+1);
|
||||
instance->pads[port] = hid_pad_register(instance, &wiiu_gca_pad_connection);
|
||||
pad = instance->pads[port];
|
||||
if(pad == NULL)
|
||||
if (!pad)
|
||||
{
|
||||
RARCH_ERR("[gca]: Failed to register pad.\n");
|
||||
break;
|
||||
@ -153,11 +152,12 @@ static void wiiu_gca_update_pad_state(hid_wiiu_gca_instance_t *instance)
|
||||
|
||||
static void wiiu_gca_unregister_pad(hid_wiiu_gca_instance_t *instance, int slot)
|
||||
{
|
||||
if(!instance || slot < 0 || slot >= 4 || instance->pads[slot] == NULL)
|
||||
joypad_connection_t *pad = NULL;
|
||||
if(!instance || slot < 0 || slot >= 4 || !instance->pads[slot])
|
||||
return;
|
||||
|
||||
joypad_connection_t *pad = instance->pads[slot];
|
||||
instance->pads[slot] = NULL;
|
||||
pad = instance->pads[slot];
|
||||
instance->pads[slot] = NULL;
|
||||
|
||||
hid_pad_deregister(pad);
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ static int remove_adapter(void *data, struct libusb_device *dev)
|
||||
struct libusb_adapter *adapter = (struct libusb_adapter*)&adapters;
|
||||
struct libusb_hid *hid = (struct libusb_hid*)data;
|
||||
|
||||
while (adapter->next == NULL)
|
||||
while (!adapter->next)
|
||||
return -1;
|
||||
|
||||
if (adapter->next->device == dev)
|
||||
|
@ -331,7 +331,7 @@ static void log_device(HIDDevice *device)
|
||||
static uint8_t try_init_driver(wiiu_adapter_t *adapter)
|
||||
{
|
||||
adapter->driver_handle = adapter->driver->init(adapter);
|
||||
if (adapter->driver_handle == NULL)
|
||||
if (!adapter->driver_handle)
|
||||
{
|
||||
RARCH_ERR("[hid]: Failed to initialize driver: %s\n",
|
||||
adapter->driver->name);
|
||||
|
@ -1162,7 +1162,7 @@ static void test_config_file_parse_contains(
|
||||
if (!val)
|
||||
return;
|
||||
|
||||
if (out == NULL)
|
||||
if (!out)
|
||||
out = strdup("");
|
||||
if (strcmp(out, val) != 0)
|
||||
abort();
|
||||
|
@ -782,10 +782,12 @@ dg__dynarr_grow(void** arr, dg__dynarr_md* md, size_t itemsize, size_t min_neede
|
||||
DG_DYNARR_INLINE void
|
||||
dg__dynarr_init(void** p, dg__dynarr_md* md, void* buf, size_t buf_cap)
|
||||
{
|
||||
*p = buf;
|
||||
md->cnt = 0;
|
||||
if(buf == NULL) md->cap = 0;
|
||||
else md->cap = (DG__DYNARR_SIZE_T_MSB | buf_cap);
|
||||
*p = buf;
|
||||
md->cnt = 0;
|
||||
if(!buf)
|
||||
md->cap = 0;
|
||||
else
|
||||
md->cap = (DG__DYNARR_SIZE_T_MSB | buf_cap);
|
||||
}
|
||||
|
||||
DG_DYNARR_INLINE int
|
||||
@ -952,7 +954,7 @@ dg__dynarr_grow(void** arr, dg__dynarr_md* md, size_t itemsize, size_t min_neede
|
||||
else
|
||||
{
|
||||
void* p = DG_DYNARR_REALLOC(*arr, itemsize, md->cnt, newcap);
|
||||
if(p == NULL) DG_DYNARR_FREE(*arr); /* realloc failed, at least don't leak memory */
|
||||
if (!p) DG_DYNARR_FREE(*arr); /* realloc failed, at least don't leak memory */
|
||||
*arr = p;
|
||||
}
|
||||
|
||||
|
@ -451,7 +451,7 @@ static void threaded_worker(void *userdata)
|
||||
|
||||
/* Get first task to run */
|
||||
task = tasks_running.front;
|
||||
if (task == NULL)
|
||||
if (!task)
|
||||
{
|
||||
scond_wait(worker_cond, running_lock);
|
||||
slock_unlock(running_lock);
|
||||
|
@ -144,7 +144,7 @@ static void tpool_worker(void *arg)
|
||||
* Also, the working_cnt can't be changed (except the thread holding the lock).
|
||||
* At this point if there isn't any work processing and if there is no work
|
||||
* signal this is the case. */
|
||||
if (!tp->stop && tp->working_cnt == 0 && tp->work_first == NULL)
|
||||
if (!tp->stop && tp->working_cnt == 0 && !tp->work_first)
|
||||
scond_signal(tp->working_cond);
|
||||
slock_unlock(tp->work_mutex);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user