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

@ -167,9 +167,9 @@ static void SDL_EVDEV_UpdateKeyboardMute(void)
int SDL_EVDEV_Init(void)
{
if (_this == NULL) {
if (!_this) {
_this = (SDL_EVDEV_PrivateData *)SDL_calloc(1, sizeof(*_this));
if (_this == NULL) {
if (!_this) {
return SDL_OutOfMemory();
}
@ -231,7 +231,7 @@ int SDL_EVDEV_Init(void)
void SDL_EVDEV_Quit(void)
{
if (_this == NULL) {
if (!_this) {
return;
}
@ -244,14 +244,14 @@ void SDL_EVDEV_Quit(void)
#endif /* SDL_USE_LIBUDEV */
/* Remove existing devices */
while (_this->first != NULL) {
while (_this->first) {
SDL_EVDEV_device_removed(_this->first->path);
}
SDL_EVDEV_kbd_quit(_this->kbd);
SDL_assert(_this->first == NULL);
SDL_assert(_this->last == NULL);
SDL_assert(!_this->first);
SDL_assert(!_this->last);
SDL_assert(_this->num_devices == 0);
SDL_free(_this);
@ -263,7 +263,7 @@ void SDL_EVDEV_Quit(void)
static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class,
const char *dev_path)
{
if (dev_path == NULL) {
if (!dev_path) {
return;
}
@ -301,7 +301,7 @@ int SDL_EVDEV_GetDeviceCount(int device_class)
SDL_evdevlist_item *item;
int count = 0;
for (item = _this->first; item != NULL; item = item->next) {
for (item = _this->first; item; item = item->next) {
if ((item->udev_class & device_class) == device_class) {
++count;
}
@ -331,7 +331,7 @@ void SDL_EVDEV_Poll(void)
mouse = SDL_GetMouse();
for (item = _this->first; item != NULL; item = item->next) {
for (item = _this->first; item; item = item->next) {
while ((len = read(item->fd, events, sizeof(events))) > 0) {
len /= sizeof(events[0]);
for (i = 0; i < len; ++i) {
@ -643,7 +643,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
}
item->touchscreen_data = SDL_calloc(1, sizeof(*item->touchscreen_data));
if (item->touchscreen_data == NULL) {
if (!item->touchscreen_data) {
return SDL_OutOfMemory();
}
@ -654,7 +654,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
}
item->touchscreen_data->name = SDL_strdup(name);
if (item->touchscreen_data->name == NULL) {
if (!item->touchscreen_data->name) {
SDL_free(item->touchscreen_data);
return SDL_OutOfMemory();
}
@ -709,7 +709,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
item->touchscreen_data->slots = SDL_calloc(
item->touchscreen_data->max_slots,
sizeof(*item->touchscreen_data->slots));
if (item->touchscreen_data->slots == NULL) {
if (!item->touchscreen_data->slots) {
SDL_free(item->touchscreen_data->name);
SDL_free(item->touchscreen_data);
return SDL_OutOfMemory();
@ -770,7 +770,7 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
sizeof(*mt_req_values) * item->touchscreen_data->max_slots;
mt_req_code = SDL_calloc(1, mt_req_size);
if (mt_req_code == NULL) {
if (!mt_req_code) {
return;
}
@ -875,14 +875,14 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
unsigned long relbit[NBITS(REL_MAX)] = { 0 };
/* Check to make sure it's not already in list. */
for (item = _this->first; item != NULL; item = item->next) {
for (item = _this->first; item; item = item->next) {
if (SDL_strcmp(dev_path, item->path) == 0) {
return -1; /* already have this one */
}
}
item = (SDL_evdevlist_item *)SDL_calloc(1, sizeof(SDL_evdevlist_item));
if (item == NULL) {
if (!item) {
return SDL_OutOfMemory();
}
@ -893,7 +893,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
}
item->path = SDL_strdup(dev_path);
if (item->path == NULL) {
if (!item->path) {
close(item->fd);
SDL_free(item);
return SDL_OutOfMemory();
@ -928,7 +928,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
}
}
if (_this->last == NULL) {
if (!_this->last) {
_this->first = _this->last = item;
} else {
_this->last->next = item;
@ -947,10 +947,10 @@ static int SDL_EVDEV_device_removed(const char *dev_path)
SDL_evdevlist_item *item;
SDL_evdevlist_item *prev = NULL;
for (item = _this->first; item != NULL; item = item->next) {
for (item = _this->first; item; item = item->next) {
/* found it, remove it. */
if (SDL_strcmp(dev_path, item->path) == 0) {
if (prev != NULL) {
if (prev) {
prev->next = item->next;
} else {
SDL_assert(_this->first == item);