mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 07:59:42 +00:00
Cleanup != NULL comparisons
This commit is contained in:
parent
6d37d014a0
commit
ad1aa59ce1
@ -402,7 +402,7 @@ static bool v4l_poll(void *data,
|
||||
|
||||
if (preprocess_image(data))
|
||||
{
|
||||
if (frame_raw_cb != NULL)
|
||||
if (frame_raw_cb)
|
||||
frame_raw_cb(v4l->buffer_output, v4l->width,
|
||||
v4l->height, v4l->width * 4);
|
||||
return true;
|
||||
|
@ -164,7 +164,7 @@ int system_property_get(const char *command,
|
||||
|
||||
while (!feof(pipe))
|
||||
{
|
||||
if (fgets(buffer, 128, pipe) != NULL)
|
||||
if (fgets(buffer, 128, pipe))
|
||||
{
|
||||
int curlen = strlen(buffer);
|
||||
|
||||
@ -306,11 +306,11 @@ static void* onSaveInstanceState(
|
||||
while (!android_app->stateSaved)
|
||||
scond_wait(android_app->cond, android_app->mutex);
|
||||
|
||||
if (android_app->savedState != NULL)
|
||||
if (android_app->savedState)
|
||||
{
|
||||
savedState = android_app->savedState;
|
||||
*outLen = android_app->savedStateSize;
|
||||
android_app->savedState = NULL;
|
||||
savedState = android_app->savedState;
|
||||
*outLen = android_app->savedStateSize;
|
||||
android_app->savedState = NULL;
|
||||
android_app->savedStateSize = 0;
|
||||
}
|
||||
|
||||
@ -451,9 +451,9 @@ static struct android_app* android_app_create(ANativeActivity* activity,
|
||||
android_app->mutex = slock_new();
|
||||
android_app->cond = scond_new();
|
||||
|
||||
if (savedState != NULL)
|
||||
if (savedState)
|
||||
{
|
||||
android_app->savedState = malloc(savedStateSize);
|
||||
android_app->savedState = malloc(savedStateSize);
|
||||
android_app->savedStateSize = savedStateSize;
|
||||
memcpy(android_app->savedState, savedState, savedStateSize);
|
||||
}
|
||||
@ -1783,10 +1783,10 @@ static void free_saved_state(struct android_app* android_app)
|
||||
{
|
||||
slock_lock(android_app->mutex);
|
||||
|
||||
if (android_app->savedState != NULL)
|
||||
if (android_app->savedState)
|
||||
{
|
||||
free(android_app->savedState);
|
||||
android_app->savedState = NULL;
|
||||
android_app->savedState = NULL;
|
||||
android_app->savedStateSize = 0;
|
||||
}
|
||||
|
||||
@ -2414,7 +2414,7 @@ enum retro_language frontend_unix_get_user_language(void)
|
||||
#else
|
||||
char *envvar = getenv("LANG");
|
||||
|
||||
if (envvar != NULL)
|
||||
if (envvar)
|
||||
lang = rarch_get_language_from_iso(envvar);
|
||||
#endif
|
||||
#endif
|
||||
|
@ -93,7 +93,7 @@ bool dbus_screensaver_inhibit(void)
|
||||
reply = dbus_connection_send_with_reply_and_block(dbus_connection,
|
||||
msg, 300, NULL);
|
||||
|
||||
if (reply != NULL)
|
||||
if (reply)
|
||||
{
|
||||
if (!dbus_message_get_args(reply, NULL,
|
||||
DBUS_TYPE_UINT32, &dbus_screensaver_cookie,
|
||||
|
@ -457,7 +457,7 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
_dispvars->core_pitch = pitch;
|
||||
_dispvars->aspect_ratio = aspect;
|
||||
|
||||
if (_dispvars->main_surface != NULL)
|
||||
if (_dispvars->main_surface)
|
||||
dispmanx_surface_free(_dispvars, &_dispvars->main_surface);
|
||||
|
||||
/* Internal resolution or ratio has changed, so we need
|
||||
|
@ -770,7 +770,7 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
_drmvars->core_height = height;
|
||||
_drmvars->core_pitch = pitch;
|
||||
|
||||
if (_drmvars->main_surface != NULL)
|
||||
if (_drmvars->main_surface)
|
||||
drm_surface_free(_drmvars, &_drmvars->main_surface);
|
||||
|
||||
/* We need to recreate the main surface and it's pages (buffers). */
|
||||
|
@ -247,7 +247,7 @@ static void exynos_clean_up_pages(struct exynos_page *p, unsigned cnt)
|
||||
|
||||
for (i = 0; i < cnt; ++i)
|
||||
{
|
||||
if (p[i].bo != NULL)
|
||||
if (p[i].bo)
|
||||
{
|
||||
if (p[i].buf_id != 0)
|
||||
drmModeRmFB(p[i].buf_id, p[i].bo->handle);
|
||||
@ -1271,7 +1271,7 @@ static void exynos_gfx_free(void *data)
|
||||
|
||||
free(pdata);
|
||||
|
||||
if (vid->font != NULL && vid->font_driver != NULL)
|
||||
if (vid->font && vid->font_driver)
|
||||
vid->font_driver->free(vid->font);
|
||||
|
||||
free(vid);
|
||||
|
@ -132,7 +132,7 @@ static int GLXExtensionSupported(Display *dpy, const char *extension)
|
||||
const char *client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS);
|
||||
const char *pos = strstr(extensionsString, extension);
|
||||
|
||||
if ( (pos != NULL) &&
|
||||
if ( pos &&
|
||||
(pos == extensionsString || pos[-1] == ' ') &&
|
||||
(pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0')
|
||||
)
|
||||
@ -141,7 +141,7 @@ static int GLXExtensionSupported(Display *dpy, const char *extension)
|
||||
pos = strstr(client_extensions, extension);
|
||||
|
||||
if (
|
||||
(pos != NULL) &&
|
||||
pos &&
|
||||
(pos == extensionsString || pos[-1] == ' ') &&
|
||||
(pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0')
|
||||
)
|
||||
@ -878,7 +878,7 @@ static bool gfx_ctx_x_set_video_mode(void *data,
|
||||
x->g_glx_win, x->g_glx_win, x->g_ctx);
|
||||
|
||||
version = (const char*)glGetString(GL_VERSION);
|
||||
if (strstr(version, " Mesa ") != NULL || !x->g_core_es)
|
||||
if (strstr(version, " Mesa ") || !x->g_core_es)
|
||||
{
|
||||
/* we are done, break switch case */
|
||||
XSetErrorHandler(old_handler);
|
||||
|
@ -582,7 +582,7 @@ static bool udev_joypad_init(void *data)
|
||||
struct udev_device *dev = udev_device_new_from_syspath(udev_joypad_fd, name);
|
||||
const char *devnode = udev_device_get_devnode(dev);
|
||||
|
||||
if (devnode != NULL)
|
||||
if (devnode)
|
||||
udev_check_device(dev, devnode);
|
||||
udev_device_unref(dev);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ static bool wiiu_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
return ready &&
|
||||
pad < MAX_USERS &&
|
||||
pad_drivers[pad] != NULL &&
|
||||
pad_drivers[pad] &&
|
||||
pad_drivers[pad]->query_pad(pad);
|
||||
}
|
||||
|
||||
|
@ -950,7 +950,7 @@ int setting_set_with_string_representation(rarch_setting_t* setting,
|
||||
case ST_STRING:
|
||||
case ST_STRING_OPTIONS:
|
||||
case ST_ACTION:
|
||||
if ( setting->value.target.string != NULL)
|
||||
if (setting->value.target.string)
|
||||
strlcpy(setting->value.target.string, value, setting->size);
|
||||
break;
|
||||
case ST_BOOL:
|
||||
|
@ -436,7 +436,7 @@ struct netplay_room* netplay_room_get(int index)
|
||||
if (index < 0)
|
||||
return NULL;
|
||||
|
||||
while (room != NULL)
|
||||
while (room)
|
||||
{
|
||||
if (cur == index)
|
||||
break;
|
||||
@ -461,7 +461,7 @@ int netplay_rooms_get_count(void)
|
||||
if (!room)
|
||||
return count;
|
||||
|
||||
while(room != NULL)
|
||||
while (room)
|
||||
{
|
||||
count++;
|
||||
|
||||
|
@ -111,7 +111,7 @@ static void connmanctl_tether_toggle(bool switch_on, char* apname, char* passkey
|
||||
RARCH_LOG("[CONNMANCTL] Tether toggle: command: \"%s\"\n",
|
||||
command);
|
||||
|
||||
while (fgets(output, sizeof(output), command_file) != NULL)
|
||||
while (fgets(output, sizeof(output), command_file))
|
||||
{
|
||||
if (output[strlen(output)-1] == '\n')
|
||||
output[strlen(output)-1] = '\0';
|
||||
@ -176,7 +176,7 @@ static void connmanctl_scan(void)
|
||||
MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
|
||||
serv_file = popen("connmanctl services", "r");
|
||||
while (fgets (line, 512, serv_file) != NULL)
|
||||
while (fgets(line, 512, serv_file))
|
||||
{
|
||||
size_t len = strlen(line);
|
||||
if (len > 0 && line[len-1] == '\n')
|
||||
@ -236,7 +236,7 @@ static bool connmanctl_ssid_is_online(unsigned i)
|
||||
|
||||
command_file = popen(command, "r");
|
||||
|
||||
while (fgets (ln, 512, command_file) != NULL)
|
||||
while (fgets(ln, 512, command_file))
|
||||
{
|
||||
connman_cache[i] = true;
|
||||
return true;
|
||||
@ -333,7 +333,7 @@ static bool connmanctl_connect_ssid(unsigned idx, const char* passphrase)
|
||||
|
||||
command_file = popen(command, "r");
|
||||
|
||||
while (fgets (ln, sizeof(ln), command_file) != NULL)
|
||||
while (fgets(ln, sizeof(ln), command_file))
|
||||
{
|
||||
#ifdef HAVE_GFX_WIDGETS
|
||||
if (!gfx_widgets_ready())
|
||||
@ -414,7 +414,7 @@ static void connmanctl_get_connected_servicename(char* servicename, size_t buffe
|
||||
RARCH_LOG("[CONNMANCTL] Testing configured services for activity: command: \"%s\"\n",
|
||||
command);
|
||||
|
||||
while (fgets(temp, buffersize, command_file) != NULL)
|
||||
while (fgets(temp, buffersize, command_file))
|
||||
{
|
||||
if (strlen(temp) > 0)
|
||||
if (temp[strlen(temp)-1] == '\n')
|
||||
@ -547,7 +547,7 @@ static void connmanctl_tether_start_stop(bool start, char* configfile)
|
||||
RARCH_LOG("[CONNMANCTL] Tether start stop: parsing command: \"%s\"\n",
|
||||
command);
|
||||
|
||||
while (fgets(ln, sizeof(ln), command_file) != NULL)
|
||||
while (fgets(ln, sizeof(ln), command_file))
|
||||
{
|
||||
i++;
|
||||
if (strlen(ln) > 1)
|
||||
@ -632,7 +632,7 @@ static void connmanctl_tether_start_stop(bool start, char* configfile)
|
||||
RARCH_LOG("[CONNMANCTL] Tether start stop: disconnecting from service \"%s\", command: \"%s\"\n",
|
||||
service, command);
|
||||
|
||||
while (fgets(ln, sizeof(ln), command_file) != NULL)
|
||||
while (fgets(ln, sizeof(ln), command_file))
|
||||
{
|
||||
if (ln[strlen(ln)-1] == '\n')
|
||||
ln[strlen(ln)-1] = '\0';
|
||||
|
Loading…
Reference in New Issue
Block a user