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

@@ -268,7 +268,7 @@ CreateHwData(const char *path)
hw = (struct joystick_hwdata *)
SDL_calloc(1, sizeof(struct joystick_hwdata));
if (hw == NULL) {
if (!hw) {
close(fd);
SDL_OutOfMemory();
return NULL;
@@ -291,7 +291,7 @@ CreateHwData(const char *path)
}
}
hw->repdesc = hid_get_report_desc(fd);
if (hw->repdesc == NULL) {
if (!hw->repdesc) {
SDL_SetError("%s: USB_GET_REPORT_DESC: %s", path,
strerror(errno));
goto usberr;
@@ -318,7 +318,7 @@ CreateHwData(const char *path)
#else
hdata = hid_start_parse(hw->repdesc, 1 << hid_input);
#endif
if (hdata == NULL) {
if (!hdata) {
SDL_SetError("%s: Cannot start HID parser", path);
goto usberr;
}
@@ -398,7 +398,7 @@ static int MaybeAddDevice(const char *path)
SDL_joylist_item *item;
struct joystick_hwdata *hw;
if (path == NULL) {
if (!path) {
return -1;
}
@@ -407,14 +407,14 @@ static int MaybeAddDevice(const char *path)
}
/* Check to make sure it's not already in list. */
for (item = SDL_joylist; item != NULL; item = item->next) {
for (item = SDL_joylist; item; item = item->next) {
if (sb.st_rdev == item->devnum) {
return -1; /* already have this one */
}
}
hw = CreateHwData(path);
if (hw == NULL) {
if (!hw) {
return -1;
}
@@ -444,14 +444,14 @@ static int MaybeAddDevice(const char *path)
}
#endif /* USB_GET_DEVICEINFO */
}
if (name == NULL) {
if (!name) {
name = SDL_strdup(path);
guid = SDL_CreateJoystickGUIDForName(name);
}
FreeHwData(hw);
item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item));
if (item == NULL) {
if (!item) {
SDL_free(name);
return -1;
}
@@ -461,13 +461,13 @@ static int MaybeAddDevice(const char *path)
item->name = name;
item->guid = guid;
if ((item->path == NULL) || (item->name == NULL)) {
if ((!item->path) || (!item->name)) {
FreeJoylistItem(item);
return -1;
}
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;
@@ -526,7 +526,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;
}
@@ -583,12 +583,12 @@ static int BSD_JoystickOpen(SDL_Joystick *joy, int device_index)
SDL_joylist_item *item = GetJoystickByDevIndex(device_index);
struct joystick_hwdata *hw;
if (item == NULL) {
if (!item) {
return SDL_SetError("No such device");
}
hw = CreateHwData(item->path);
if (hw == NULL) {
if (!hw) {
return -1;
}
@@ -664,7 +664,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy)
#else
hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
#endif
if (hdata == NULL) {
if (!hdata) {
/*fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path);*/
continue;
}
@@ -793,7 +793,7 @@ static int report_alloc(struct report *r, struct report_desc *rd, int repind)
r->buf = SDL_malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) +
r->size);
#endif
if (r->buf == NULL) {
if (!r->buf) {
return SDL_OutOfMemory();
}
} else {