[SDL2] pointer boolean (#8523)

This commit is contained in:
Sylvain Becker
2023-11-10 15:30:56 +01:00
committed by GitHub
parent 4a3a9f3ad8
commit a14b948b6c
394 changed files with 2564 additions and 2559 deletions

View File

@@ -55,7 +55,7 @@ static int ValidHaptic(SDL_Haptic *haptic)
SDL_Haptic *hapticlist;
valid = 0;
if (haptic != NULL) {
if (haptic) {
hapticlist = SDL_haptics;
while (hapticlist) {
if (hapticlist == haptic) {
@@ -124,7 +124,7 @@ SDL_Haptic *SDL_HapticOpen(int device_index)
/* Create the haptic device */
haptic = (SDL_Haptic *)SDL_malloc(sizeof(*haptic));
if (haptic == NULL) {
if (!haptic) {
SDL_OutOfMemory();
return NULL;
}
@@ -296,7 +296,7 @@ SDL_Haptic *SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
/* Create the haptic device */
haptic = (SDL_Haptic *)SDL_malloc(sizeof(*haptic));
if (haptic == NULL) {
if (!haptic) {
SDL_OutOfMemory();
SDL_UnlockJoysticks();
return NULL;
@@ -609,7 +609,7 @@ int SDL_HapticSetGain(SDL_Haptic *haptic, int gain)
/* We use the envvar to get the maximum gain. */
env = SDL_getenv("SDL_HAPTIC_GAIN_MAX");
if (env != NULL) {
if (env) {
max_gain = SDL_atoi(env);
/* Check for sanity. */

View File

@@ -70,7 +70,7 @@ static SDL_hapticlist_item *HapticByOrder(int index)
return NULL;
}
while (index > 0) {
SDL_assert(item != NULL);
SDL_assert(item);
--index;
item = item->next;
}
@@ -80,7 +80,7 @@ static SDL_hapticlist_item *HapticByOrder(int index)
static SDL_hapticlist_item *HapticByDevId(int device_id)
{
SDL_hapticlist_item *item;
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
if (device_id == item->device_id) {
/*SDL_Log("=+=+=+=+=+= HapticByDevId id [%d]", device_id);*/
return item;
@@ -92,7 +92,7 @@ static SDL_hapticlist_item *HapticByDevId(int device_id)
const char *SDL_SYS_HapticName(int index)
{
SDL_hapticlist_item *item = HapticByOrder(index);
if (item == NULL) {
if (!item) {
SDL_SetError("No such device");
return NULL;
}
@@ -101,11 +101,11 @@ const char *SDL_SYS_HapticName(int index)
static SDL_hapticlist_item *OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *item)
{
if (item == NULL) {
if (!item) {
SDL_SetError("No such device");
return NULL;
}
if (item->haptic != NULL) {
if (item->haptic) {
SDL_SetError("Haptic already opened");
return NULL;
}
@@ -117,7 +117,7 @@ static SDL_hapticlist_item *OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *
haptic->neffects = 1;
haptic->nplaying = haptic->neffects;
haptic->effects = (struct haptic_effect *)SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
if (haptic->effects == NULL) {
if (!haptic->effects) {
SDL_OutOfMemory();
return NULL;
}
@@ -149,7 +149,7 @@ int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
{
SDL_hapticlist_item *item;
item = HapticByDevId(((joystick_hwdata *)joystick->hwdata)->device_id);
return (item != NULL) ? 1 : 0;
return (item) ? 1 : 0;
}
int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
@@ -257,18 +257,18 @@ int Android_AddHaptic(int device_id, const char *name)
{
SDL_hapticlist_item *item;
item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
if (item == NULL) {
if (!item) {
return -1;
}
item->device_id = device_id;
item->name = SDL_strdup(name);
if (item->name == NULL) {
if (!item->name) {
SDL_free(item);
return -1;
}
if (SDL_hapticlist_tail == NULL) {
if (!SDL_hapticlist_tail) {
SDL_hapticlist = SDL_hapticlist_tail = item;
} else {
SDL_hapticlist_tail->next = item;
@@ -284,12 +284,12 @@ int Android_RemoveHaptic(int device_id)
SDL_hapticlist_item *item;
SDL_hapticlist_item *prev = NULL;
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
/* found it, remove it. */
if (device_id == item->device_id) {
const int retval = item->haptic ? item->haptic->index : -1;
if (prev != NULL) {
if (prev) {
prev->next = item->next;
} else {
SDL_assert(SDL_hapticlist == item);

View File

@@ -157,7 +157,7 @@ int SDL_SYS_HapticInit(void)
/* Get HID devices. */
match = IOServiceMatching(kIOHIDDeviceKey);
if (match == NULL) {
if (!match) {
return SDL_SetError("Haptic: Failed to get IOServiceMatching.");
}
@@ -196,7 +196,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index)
}
while (device_index > 0) {
SDL_assert(item != NULL);
SDL_assert(item);
--device_index;
item = item->next;
}
@@ -229,7 +229,7 @@ int MacHaptic_MaybeAddDevice(io_object_t device)
}
item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
if (item == NULL) {
if (!item) {
return SDL_SetError("Could not allocate haptic storage");
}
@@ -265,7 +265,7 @@ int MacHaptic_MaybeAddDevice(io_object_t device)
CFRelease(hidProperties);
}
if (SDL_hapticlist_tail == NULL) {
if (!SDL_hapticlist_tail) {
SDL_hapticlist = SDL_hapticlist_tail = item;
} else {
SDL_hapticlist_tail->next = item;
@@ -287,12 +287,12 @@ int MacHaptic_MaybeRemoveDevice(io_object_t device)
return -1; /* not initialized. ignore this. */
}
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
/* found it, remove it. */
if (IOObjectIsEqualTo((io_object_t)item->dev, device)) {
const int retval = item->haptic ? item->haptic->index : -1;
if (prev != NULL) {
if (prev) {
prev->next = item->next;
} else {
SDL_assert(SDL_hapticlist == item);
@@ -478,7 +478,7 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic
/* Allocate the hwdata */
haptic->hwdata = (struct haptic_hwdata *)
SDL_malloc(sizeof(*haptic->hwdata));
if (haptic->hwdata == NULL) {
if (!haptic->hwdata) {
SDL_OutOfMemory();
goto creat_err;
}
@@ -516,7 +516,7 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic
/* Allocate effects memory. */
haptic->effects = (struct haptic_effect *)
SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
if (haptic->effects == NULL) {
if (!haptic->effects) {
SDL_OutOfMemory();
goto open_err;
}
@@ -530,7 +530,7 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic
open_err:
FFReleaseDevice(haptic->hwdata->device);
creat_err:
if (haptic->hwdata != NULL) {
if (haptic->hwdata) {
SDL_free(haptic->hwdata);
haptic->hwdata = NULL;
}
@@ -703,7 +703,7 @@ static int SDL_SYS_SetDirection(FFEFFECT *effect, SDL_HapticDirection *dir, int
/* Has axes. */
rglDir = SDL_malloc(sizeof(LONG) * naxes);
if (rglDir == NULL) {
if (!rglDir) {
return SDL_OutOfMemory();
}
SDL_memset(rglDir, 0, sizeof(LONG) * naxes);
@@ -776,7 +776,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
/* Envelope. */
envelope = SDL_malloc(sizeof(FFENVELOPE));
if (envelope == NULL) {
if (!envelope) {
return SDL_OutOfMemory();
}
SDL_memset(envelope, 0, sizeof(FFENVELOPE));
@@ -791,7 +791,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
}
if (dest->cAxes > 0) {
axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
if (axes == NULL) {
if (!axes) {
return SDL_OutOfMemory();
}
axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */
@@ -809,7 +809,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
case SDL_HAPTIC_CONSTANT:
hap_constant = &src->constant;
constant = SDL_malloc(sizeof(FFCONSTANTFORCE));
if (constant == NULL) {
if (!constant) {
return SDL_OutOfMemory();
}
SDL_memset(constant, 0, sizeof(FFCONSTANTFORCE));
@@ -851,7 +851,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
case SDL_HAPTIC_SAWTOOTHDOWN:
hap_periodic = &src->periodic;
periodic = SDL_malloc(sizeof(FFPERIODIC));
if (periodic == NULL) {
if (!periodic) {
return SDL_OutOfMemory();
}
SDL_memset(periodic, 0, sizeof(FFPERIODIC));
@@ -896,7 +896,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
hap_condition = &src->condition;
if (dest->cAxes > 0) {
condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes);
if (condition == NULL) {
if (!condition) {
return SDL_OutOfMemory();
}
SDL_memset(condition, 0, sizeof(FFCONDITION));
@@ -939,7 +939,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
case SDL_HAPTIC_RAMP:
hap_ramp = &src->ramp;
ramp = SDL_malloc(sizeof(FFRAMPFORCE));
if (ramp == NULL) {
if (!ramp) {
return SDL_OutOfMemory();
}
SDL_memset(ramp, 0, sizeof(FFRAMPFORCE));
@@ -977,7 +977,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
case SDL_HAPTIC_CUSTOM:
hap_custom = &src->custom;
custom = SDL_malloc(sizeof(FFCUSTOMFORCE));
if (custom == NULL) {
if (!custom) {
return SDL_OutOfMemory();
}
SDL_memset(custom, 0, sizeof(FFCUSTOMFORCE));
@@ -1037,7 +1037,7 @@ static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT *effect, int type)
effect->lpEnvelope = NULL;
SDL_free(effect->rgdwAxes);
effect->rgdwAxes = NULL;
if (effect->lpvTypeSpecificParams != NULL) {
if (effect->lpvTypeSpecificParams) {
if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */
custom = (FFCUSTOMFORCE *)effect->lpvTypeSpecificParams;
SDL_free(custom->rglForceData);
@@ -1112,14 +1112,14 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
/* Alloc the effect. */
effect->hweffect = (struct haptic_hweffect *)
SDL_malloc(sizeof(struct haptic_hweffect));
if (effect->hweffect == NULL) {
if (!effect->hweffect) {
SDL_OutOfMemory();
goto err_hweffect;
}
/* Get the type. */
type = SDL_SYS_HapticEffectType(base->type);
if (type == NULL) {
if (!type) {
goto err_hweffect;
}

View File

@@ -195,7 +195,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index)
}
while (device_index > 0) {
SDL_assert(item != NULL);
SDL_assert(item);
--device_index;
item = item->next;
}
@@ -206,7 +206,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index)
#if SDL_USE_LIBUDEV
static void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath)
{
if (devpath == NULL || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) {
if (!devpath || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) {
return;
}
@@ -232,7 +232,7 @@ static int MaybeAddDevice(const char *path)
int success;
SDL_hapticlist_item *item;
if (path == NULL) {
if (!path) {
return -1;
}
@@ -242,7 +242,7 @@ static int MaybeAddDevice(const char *path)
}
/* check for duplicates */
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
if (item->dev_num == sb.st_rdev) {
return -1; /* duplicate. */
}
@@ -266,12 +266,12 @@ static int MaybeAddDevice(const char *path)
}
item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
if (item == NULL) {
if (!item) {
return -1;
}
item->fname = SDL_strdup(path);
if (item->fname == NULL) {
if (!item->fname) {
SDL_free(item);
return -1;
}
@@ -279,7 +279,7 @@ static int MaybeAddDevice(const char *path)
item->dev_num = sb.st_rdev;
/* TODO: should we add instance IDs? */
if (SDL_hapticlist_tail == NULL) {
if (!SDL_hapticlist_tail) {
SDL_hapticlist = SDL_hapticlist_tail = item;
} else {
SDL_hapticlist_tail->next = item;
@@ -299,16 +299,16 @@ static int MaybeRemoveDevice(const char *path)
SDL_hapticlist_item *item;
SDL_hapticlist_item *prev = NULL;
if (path == NULL) {
if (!path) {
return -1;
}
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
/* found it, remove it. */
if (SDL_strcmp(path, item->fname) == 0) {
const int retval = item->haptic ? item->haptic->index : -1;
if (prev != NULL) {
if (prev) {
prev->next = item->next;
} else {
SDL_assert(SDL_hapticlist == item);
@@ -365,7 +365,7 @@ const char *SDL_SYS_HapticName(int index)
if (fd >= 0) {
name = SDL_SYS_HapticNameFromFD(fd);
if (name == NULL) {
if (!name) {
/* No name found, return device character device */
name = item->fname;
}
@@ -383,7 +383,7 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd)
/* Allocate the hwdata */
haptic->hwdata = (struct haptic_hwdata *)
SDL_malloc(sizeof(*haptic->hwdata));
if (haptic->hwdata == NULL) {
if (!haptic->hwdata) {
SDL_OutOfMemory();
goto open_err;
}
@@ -403,7 +403,7 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd)
haptic->nplaying = haptic->neffects; /* Linux makes no distinction. */
haptic->effects = (struct haptic_effect *)
SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
if (haptic->effects == NULL) {
if (!haptic->effects) {
SDL_OutOfMemory();
goto open_err;
}
@@ -416,7 +416,7 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd)
/* Error handling */
open_err:
close(fd);
if (haptic->hwdata != NULL) {
if (haptic->hwdata) {
SDL_free(haptic->hwdata);
haptic->hwdata = NULL;
}
@@ -911,7 +911,7 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
/* Allocate the hardware effect */
effect->hweffect = (struct haptic_hweffect *)
SDL_malloc(sizeof(struct haptic_hweffect));
if (effect->hweffect == NULL) {
if (!effect->hweffect) {
return SDL_OutOfMemory();
}

View File

@@ -98,7 +98,7 @@ int SDL_DINPUT_HapticInit(void)
/* Because we used CoCreateInstance, we need to Initialize it, first. */
instance = GetModuleHandle(NULL);
if (instance == NULL) {
if (!instance) {
SDL_SYS_HapticQuit();
return SDL_SetError("GetModuleHandle() failed with error code %lu.",
GetLastError());
@@ -139,7 +139,7 @@ int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance)
DIDEVCAPS capabilities;
SDL_hapticlist_item *item = NULL;
if (dinput == NULL) {
if (!dinput) {
return -1; /* not initialized. We'll pick these up on enumeration if we init later. */
}
@@ -172,7 +172,7 @@ int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance)
}
item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
if (item == NULL) {
if (!item) {
return SDL_OutOfMemory();
}
@@ -194,11 +194,11 @@ int SDL_DINPUT_HapticMaybeRemoveDevice(const DIDEVICEINSTANCE *pdidInstance)
SDL_hapticlist_item *item;
SDL_hapticlist_item *prev = NULL;
if (dinput == NULL) {
if (!dinput) {
return -1; /* not initialized, ignore this. */
}
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
if (!item->bXInputHaptic && SDL_memcmp(&item->instance, pdidInstance, sizeof(*pdidInstance)) == 0) {
/* found it, remove it. */
return SDL_SYS_RemoveHapticDevice(prev, item);
@@ -293,7 +293,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI
/* Allocate the hwdata */
haptic->hwdata = (struct haptic_hwdata *)SDL_malloc(sizeof(*haptic->hwdata));
if (haptic->hwdata == NULL) {
if (!haptic->hwdata) {
return SDL_OutOfMemory();
}
SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
@@ -407,7 +407,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI
/* Prepare effects memory. */
haptic->effects = (struct haptic_effect *)
SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
if (haptic->effects == NULL) {
if (!haptic->effects) {
SDL_OutOfMemory();
goto acquire_err;
}
@@ -480,7 +480,7 @@ int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick
}
/* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
if (!item->bXInputHaptic && WIN_IsEqualGUID(&item->instance.guidInstance, &joy_instance.guidInstance)) {
haptic->index = index;
return SDL_DINPUT_HapticOpenFromDevice(haptic, joystick->hwdata->InputDevice, SDL_TRUE);
@@ -546,7 +546,7 @@ static int SDL_SYS_SetDirection(DIEFFECT *effect, SDL_HapticDirection *dir, int
/* Has axes. */
rglDir = SDL_malloc(sizeof(LONG) * naxes);
if (rglDir == NULL) {
if (!rglDir) {
return SDL_OutOfMemory();
}
SDL_memset(rglDir, 0, sizeof(LONG) * naxes);
@@ -620,7 +620,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
/* Envelope. */
envelope = SDL_malloc(sizeof(DIENVELOPE));
if (envelope == NULL) {
if (!envelope) {
return SDL_OutOfMemory();
}
SDL_memset(envelope, 0, sizeof(DIENVELOPE));
@@ -635,7 +635,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
}
if (dest->cAxes > 0) {
axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
if (axes == NULL) {
if (!axes) {
return SDL_OutOfMemory();
}
axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */
@@ -653,7 +653,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_CONSTANT:
hap_constant = &src->constant;
constant = SDL_malloc(sizeof(DICONSTANTFORCE));
if (constant == NULL) {
if (!constant) {
return SDL_OutOfMemory();
}
SDL_memset(constant, 0, sizeof(DICONSTANTFORCE));
@@ -695,7 +695,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_SAWTOOTHDOWN:
hap_periodic = &src->periodic;
periodic = SDL_malloc(sizeof(DIPERIODIC));
if (periodic == NULL) {
if (!periodic) {
return SDL_OutOfMemory();
}
SDL_memset(periodic, 0, sizeof(DIPERIODIC));
@@ -739,7 +739,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_FRICTION:
hap_condition = &src->condition;
condition = SDL_malloc(sizeof(DICONDITION) * dest->cAxes);
if (condition == NULL) {
if (!condition) {
return SDL_OutOfMemory();
}
SDL_memset(condition, 0, sizeof(DICONDITION));
@@ -780,7 +780,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_RAMP:
hap_ramp = &src->ramp;
ramp = SDL_malloc(sizeof(DIRAMPFORCE));
if (ramp == NULL) {
if (!ramp) {
return SDL_OutOfMemory();
}
SDL_memset(ramp, 0, sizeof(DIRAMPFORCE));
@@ -818,7 +818,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_CUSTOM:
hap_custom = &src->custom;
custom = SDL_malloc(sizeof(DICUSTOMFORCE));
if (custom == NULL) {
if (!custom) {
return SDL_OutOfMemory();
}
SDL_memset(custom, 0, sizeof(DICUSTOMFORCE));
@@ -877,7 +877,7 @@ static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT *effect, int type)
effect->lpEnvelope = NULL;
SDL_free(effect->rgdwAxes);
effect->rgdwAxes = NULL;
if (effect->lpvTypeSpecificParams != NULL) {
if (effect->lpvTypeSpecificParams) {
if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */
custom = (DICUSTOMFORCE *)effect->lpvTypeSpecificParams;
SDL_free(custom->rglForceData);
@@ -943,7 +943,7 @@ int SDL_DINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
HRESULT ret;
REFGUID type = SDL_SYS_HapticEffectType(base);
if (type == NULL) {
if (!type) {
return SDL_SetError("Haptic: Unknown effect type.");
}

View File

@@ -81,7 +81,7 @@ int SDL_SYS_HapticInit(void)
int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item)
{
if (SDL_hapticlist_tail == NULL) {
if (!SDL_hapticlist_tail) {
SDL_hapticlist = SDL_hapticlist_tail = item;
} else {
SDL_hapticlist_tail->next = item;
@@ -97,7 +97,7 @@ int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item)
int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item)
{
const int retval = item->haptic ? item->haptic->index : -1;
if (prev != NULL) {
if (prev) {
prev->next = item->next;
} else {
SDL_assert(SDL_hapticlist == item);
@@ -126,7 +126,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index)
}
while (device_index > 0) {
SDL_assert(item != NULL);
SDL_assert(item);
--device_index;
item = item->next;
}
@@ -165,7 +165,7 @@ int SDL_SYS_HapticMouse(void)
int index = 0;
/* Grab the first mouse haptic device we find. */
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
if (item->capabilities.dwDevType == DI8DEVCLASS_POINTER) {
return index;
}
@@ -299,7 +299,7 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
/* Alloc the effect. */
effect->hweffect = (struct haptic_hweffect *)
SDL_malloc(sizeof(struct haptic_hweffect));
if (effect->hweffect == NULL) {
if (!effect->hweffect) {
SDL_OutOfMemory();
return -1;
}

View File

@@ -84,7 +84,7 @@ int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid)
}
item = (SDL_hapticlist_item *)SDL_malloc(sizeof(SDL_hapticlist_item));
if (item == NULL) {
if (!item) {
return SDL_OutOfMemory();
}
@@ -119,7 +119,7 @@ int SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid)
return -1;
}
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
if (item->bXInputHaptic && item->userid == userid) {
/* found it, remove it. */
return SDL_SYS_RemoveHapticDevice(prev, item);
@@ -178,7 +178,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us
/* Prepare effects memory. */
haptic->effects = (struct haptic_effect *)
SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
if (haptic->effects == NULL) {
if (!haptic->effects) {
return SDL_OutOfMemory();
}
/* Clear the memory */
@@ -186,7 +186,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us
sizeof(struct haptic_effect) * haptic->neffects);
haptic->hwdata = (struct haptic_hwdata *)SDL_malloc(sizeof(*haptic->hwdata));
if (haptic->hwdata == NULL) {
if (!haptic->hwdata) {
SDL_free(haptic->effects);
haptic->effects = NULL;
return SDL_OutOfMemory();
@@ -197,7 +197,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us
haptic->hwdata->userid = userid;
haptic->hwdata->mutex = SDL_CreateMutex();
if (haptic->hwdata->mutex == NULL) {
if (!haptic->hwdata->mutex) {
SDL_free(haptic->effects);
SDL_free(haptic->hwdata);
haptic->effects = NULL;
@@ -207,7 +207,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us
(void)SDL_snprintf(threadName, sizeof(threadName), "SDLXInputDev%d", userid);
haptic->hwdata->thread = SDL_CreateThreadInternal(SDL_RunXInputHaptic, threadName, 64 * 1024, haptic->hwdata);
if (haptic->hwdata->thread == NULL) {
if (!haptic->hwdata->thread) {
SDL_DestroyMutex(haptic->hwdata->mutex);
SDL_free(haptic->effects);
SDL_free(haptic->hwdata);
@@ -234,7 +234,7 @@ int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick
int index = 0;
/* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
if (item->bXInputHaptic && item->userid == joystick->hwdata->userid) {
haptic->index = index;
return SDL_XINPUT_HapticOpenFromUserIndex(haptic, joystick->hwdata->userid);