From 8627d638e1d05c64152475d4aba7ecc7a57f09b1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 4 Feb 2020 06:05:00 +0100 Subject: [PATCH] Cleanups --- camera/drivers/android.c | 2 +- cores/libretro-ffmpeg/packet_buffer.c | 2 +- ctr/exec-3dsx/exec_3dsx.c | 11 ++++++----- ctr/exec-3dsx/exec_cia.c | 11 ++++++----- frontend/drivers/platform_gx.c | 2 +- frontend/drivers/platform_wii.c | 2 +- libretro-db/bintree.c | 2 +- location/drivers/android.c | 2 +- tasks/task_database.c | 2 +- 9 files changed, 19 insertions(+), 17 deletions(-) diff --git a/camera/drivers/android.c b/camera/drivers/android.c index 7643cc0bb9..274d5a8a63 100644 --- a/camera/drivers/android.c +++ b/camera/drivers/android.c @@ -57,7 +57,7 @@ static void *android_camera_init(const char *device, uint64_t caps, goto dealloc; GET_OBJECT_CLASS(env, class, android_app->activity->clazz); - if (class == NULL) + if (!class) goto dealloc; GET_METHOD_ID(env, androidcamera->onCameraInit, class, diff --git a/cores/libretro-ffmpeg/packet_buffer.c b/cores/libretro-ffmpeg/packet_buffer.c index da4cd4654c..5b9fd7a06b 100644 --- a/cores/libretro-ffmpeg/packet_buffer.c +++ b/cores/libretro-ffmpeg/packet_buffer.c @@ -99,7 +99,7 @@ void packet_buffer_get_packet(packet_buffer_t *packet_buffer, AVPacket *pkt) { AVPacketNode_t *new_tail = NULL; - if (packet_buffer->tail == NULL) + if (!packet_buffer->tail) return; av_packet_move_ref(pkt, packet_buffer->tail->data); diff --git a/ctr/exec-3dsx/exec_3dsx.c b/ctr/exec-3dsx/exec_3dsx.c index 09f3aa52a5..6b3d3cea03 100644 --- a/ctr/exec-3dsx/exec_3dsx.c +++ b/ctr/exec-3dsx/exec_3dsx.c @@ -19,10 +19,11 @@ static int exec_3dsx_actual(const char* path, const char** args, bool appendPath bool fileExists; bool inited; - if(path == NULL || path[0] == '\0'){ - errno = EINVAL; - return -1; - } + if (!path || path[0] == '\0') + { + errno = EINVAL; + return -1; + } fileExists = stat(path, &sBuff) == 0; if(!fileExists){ @@ -80,4 +81,4 @@ int exec_3dsx(const char* path, const char** args){ int exec_3dsx_no_path_in_args(const char* path, const char** args){ return exec_3dsx_actual(path, args, false/*appendPath*/); -} \ No newline at end of file +} diff --git a/ctr/exec-3dsx/exec_cia.c b/ctr/exec-3dsx/exec_cia.c index 89d0ee6def..025d151654 100644 --- a/ctr/exec-3dsx/exec_cia.c +++ b/ctr/exec-3dsx/exec_cia.c @@ -35,7 +35,7 @@ static int isCiaInstalled(u64 titleId, u16 version){ return -1; titleIds = malloc(titlesToRetrieve * sizeof(uint64_t)); - if(titleIds == NULL) + if (!titleIds) return -1; failed = AM_GetTitleList(&titlesRetrieved, MEDIATYPE_SD, titlesToRetrieve, titleIds); @@ -116,10 +116,11 @@ int exec_cia(const char* path, const char** args){ bool fileExists; bool inited; - if(path == NULL || path[0] == '\0'){ - errno = EINVAL; - return -1; - } + if (!path || path[0] == '\0') + { + errno = EINVAL; + return -1; + } fileExists = stat(path, &sBuff) == 0; if(!fileExists){ diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 3a2ae6924e..f47f67e757 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -166,7 +166,7 @@ static void frontend_gx_get_environment_settings( /* This situation can happen on some loaders so we really need some fake args or else retroarch will just crash on parsing NULL pointers */ - if(*argc == 0 || argv == NULL) + if(*argc == 0 || !argv) { struct rarch_main_wrap *args = (struct rarch_main_wrap*)params_data; if (args) diff --git a/frontend/drivers/platform_wii.c b/frontend/drivers/platform_wii.c index d29b890163..a70335e579 100644 --- a/frontend/drivers/platform_wii.c +++ b/frontend/drivers/platform_wii.c @@ -148,7 +148,7 @@ void system_exec_wii(const char *_path, bool should_load_game) RARCH_LOG("Attempt to load executable: [%s]\n", path); fp = fopen(path, "rb"); - if (fp == NULL) + if (!fp) { RARCH_ERR("Could not open DOL file %s.\n", path); goto exit; diff --git a/libretro-db/bintree.c b/libretro-db/bintree.c index b68d391bf1..afd7b351ca 100644 --- a/libretro-db/bintree.c +++ b/libretro-db/bintree.c @@ -61,7 +61,7 @@ static struct bintree_node *bintree_new_nil_node(struct bintree_node *parent) static INLINE int bintree_is_nil(const struct bintree_node *node) { - return (node == NULL) || (node->value == NIL_NODE); + return !node || (node->value == NIL_NODE); } static int bintree_insert_internal(bintree_t *t, struct bintree_node *root, void *value) diff --git a/location/drivers/android.c b/location/drivers/android.c index e81401e92b..691e8514a1 100644 --- a/location/drivers/android.c +++ b/location/drivers/android.c @@ -45,7 +45,7 @@ static void *android_location_init(void) goto dealloc; GET_OBJECT_CLASS(env, class, android_app->activity->clazz); - if (class == NULL) + if (!class) goto dealloc; GET_METHOD_ID(env, androidlocation->onLocationInit, class, diff --git a/tasks/task_database.c b/tasks/task_database.c index 41ffd7101c..4069a78b7f 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -126,7 +126,7 @@ static const char *database_info_get_current_element_name( if (!handle || !handle->list) return NULL; /* Skip pruned entries */ - while (handle->list->elems[handle->list_ptr].data == NULL) + while (!handle->list->elems[handle->list_ptr].data) { if (++handle->list_ptr >= handle->list->size) return NULL;