Pointer as bool (libsdl-org#7214)

This commit is contained in:
Sylvain
2023-11-09 22:29:15 +01:00
committed by Sam Lantinga
parent 23db971681
commit d8600f717e
371 changed files with 2448 additions and 2442 deletions

View File

@@ -319,7 +319,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v
}
}
if (JoystickByDeviceId(device_id) != NULL || name == NULL) {
if (JoystickByDeviceId(device_id) != NULL || !name) {
goto done;
}
@@ -353,7 +353,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v
}
item = (SDL_joylist_item *)SDL_malloc(sizeof(SDL_joylist_item));
if (item == NULL) {
if (!item) {
goto done;
}
@@ -361,7 +361,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v
item->guid = guid;
item->device_id = device_id;
item->name = SDL_CreateJoystickName(vendor_id, product_id, NULL, name);
if (item->name == NULL) {
if (!item->name) {
SDL_free(item);
goto done;
}
@@ -379,7 +379,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v
item->naxes = naxes;
item->nhats = nhats;
item->device_instance = SDL_GetNextObjectID();
if (SDL_joylist_tail == NULL) {
if (!SDL_joylist_tail) {
SDL_joylist = SDL_joylist_tail = item;
} else {
SDL_joylist_tail->next = item;
@@ -412,7 +412,7 @@ int Android_RemoveJoystick(int device_id)
SDL_LockJoysticks();
/* Don't call JoystickByDeviceId here or there'll be an infinite loop! */
while (item != NULL) {
while (item) {
if (item->device_id == device_id) {
break;
}
@@ -420,7 +420,7 @@ int Android_RemoveJoystick(int device_id)
item = item->next;
}
if (item == NULL) {
if (!item) {
goto done;
}
@@ -428,7 +428,7 @@ int Android_RemoveJoystick(int device_id)
item->joystick->hwdata = NULL;
}
if (prev != NULL) {
if (prev) {
prev->next = item->next;
} else {
SDL_assert(SDL_joylist == item);
@@ -499,7 +499,7 @@ static SDL_joylist_item *GetJoystickByDevIndex(int device_index)
}
while (device_index > 0) {
SDL_assert(item != NULL);
SDL_assert(item);
device_index--;
item = item->next;
}
@@ -511,7 +511,7 @@ static SDL_joylist_item *JoystickByDeviceId(int device_id)
{
SDL_joylist_item *item = SDL_joylist;
while (item != NULL) {
while (item) {
if (item->device_id == device_id) {
return item;
}
@@ -521,7 +521,7 @@ static SDL_joylist_item *JoystickByDeviceId(int device_id)
/* Joystick not found, try adding it */
ANDROID_JoystickDetect();
while (item != NULL) {
while (item) {
if (item->device_id == device_id) {
return item;
}
@@ -564,11 +564,11 @@ static int ANDROID_JoystickOpen(SDL_Joystick *joystick, int device_index)
{
SDL_joylist_item *item = GetJoystickByDevIndex(device_index);
if (item == NULL) {
if (!item) {
return SDL_SetError("No such device");
}
if (item->joystick != NULL) {
if (item->joystick) {
return SDL_SetError("Joystick already opened");
}
@@ -616,7 +616,7 @@ static void ANDROID_JoystickUpdate(SDL_Joystick *joystick)
{
SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata;
if (item == NULL) {
if (!item) {
return;
}