Skip to content

Commit

Permalink
Cleanup != NULL comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed May 19, 2020
1 parent 6d37d01 commit ad1aa59
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion camera/drivers/video4linux2.c
Expand Up @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions frontend/drivers/platform_unix.c
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gfx/common/dbus_common.c
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion gfx/drivers/dispmanx_gfx.c
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gfx/drivers/drm_gfx.c
Expand Up @@ -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). */
Expand Down
4 changes: 2 additions & 2 deletions gfx/drivers/exynos_gfx.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions gfx/drivers_context/x_ctx.c
Expand Up @@ -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')
)
Expand All @@ -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')
)
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion input/drivers_joypad/udev_joypad.c
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion input/drivers_joypad/wiiu_joypad.c
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion menu/menu_setting.c
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions network/netplay/netplay_room_parse.c
Expand Up @@ -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;
Expand All @@ -461,7 +461,7 @@ int netplay_rooms_get_count(void)
if (!room)
return count;

while(room != NULL)
while (room)
{
count++;

Expand Down
14 changes: 7 additions & 7 deletions wifi/drivers/connmanctl.c
Expand Up @@ -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';
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit ad1aa59

Please sign in to comment.