Clang-Tidy fixes (#6725)

(cherry picked from commit 3c501b963d)
This commit is contained in:
Pierre Wendling
2022-12-01 16:07:03 -05:00
committed by Sam Lantinga
parent e29c0661cc
commit d0bbfdbfb8
179 changed files with 1260 additions and 1101 deletions

View File

@@ -240,12 +240,13 @@ int SDL_JoystickIsHaptic(SDL_Joystick *joystick)
ret = SDL_SYS_JoystickIsHaptic(joystick);
if (ret > 0)
if (ret > 0) {
return SDL_TRUE;
else if (ret == 0)
} else if (ret == 0) {
return SDL_FALSE;
else
return -1;
}
return -1;
}
/*

View File

@@ -167,7 +167,6 @@ void SDL_SYS_HapticClose(SDL_Haptic *haptic)
{
((SDL_hapticlist_item *)haptic->hwdata)->haptic = NULL;
haptic->hwdata = NULL;
return;
}
void SDL_SYS_HapticQuit(void)
@@ -223,11 +222,9 @@ int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
{
return;
}
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic,
struct haptic_effect *effect)
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect)
{
return 0;
}

View File

@@ -1204,8 +1204,9 @@ int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
/* Check if it's infinite. */
if (iterations == SDL_HAPTIC_INFINITY) {
iter = FF_INFINITE;
} else
} else {
iter = iterations;
}
/* Run the effect. */
ret = FFEffectStart(effect->hweffect->ref, iter, 0);

View File

@@ -160,8 +160,7 @@ int SDL_SYS_HapticInit(void)
*/
i = 0;
for (j = 0; j < MAX_HAPTICS; ++j) {
SDL_snprintf(path, PATH_MAX, joydev_pattern, i++);
(void)SDL_snprintf(path, PATH_MAX, joydev_pattern, i++);
MaybeAddDevice(path);
}
@@ -673,9 +672,9 @@ static int SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection *src)
break;
case SDL_HAPTIC_CARTESIAN:
if (!src->dir[1])
if (!src->dir[1]) {
*dest = (src->dir[0] >= 0 ? 0x4000 : 0xC000);
else if (!src->dir[0])
} else if (!src->dir[0]) {
*dest = (src->dir[1] >= 0 ? 0x8000 : 0);
else {
float f = SDL_atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */

View File

@@ -664,10 +664,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
dest->lpvTypeSpecificParams = constant;
/* Generics */
dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
dest->dwDuration = hap_constant->length * 1000UL; /* In microseconds. */
dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button);
dest->dwTriggerRepeatInterval = hap_constant->interval;
dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */
dest->dwStartDelay = hap_constant->delay * 1000UL; /* In microseconds. */
/* Direction. */
if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) {
@@ -680,9 +680,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
dest->lpEnvelope = NULL;
} else {
envelope->dwAttackLevel = CCONVERT(hap_constant->attack_level);
envelope->dwAttackTime = hap_constant->attack_length * 1000;
envelope->dwAttackTime = hap_constant->attack_length * 1000UL;
envelope->dwFadeLevel = CCONVERT(hap_constant->fade_level);
envelope->dwFadeTime = hap_constant->fade_length * 1000;
envelope->dwFadeTime = hap_constant->fade_length * 1000UL;
}
break;
@@ -710,10 +710,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
dest->lpvTypeSpecificParams = periodic;
/* Generics */
dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
dest->dwDuration = hap_periodic->length * 1000UL; /* In microseconds. */
dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button);
dest->dwTriggerRepeatInterval = hap_periodic->interval;
dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */
dest->dwStartDelay = hap_periodic->delay * 1000UL; /* In microseconds. */
/* Direction. */
if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) {
@@ -726,9 +726,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
dest->lpEnvelope = NULL;
} else {
envelope->dwAttackLevel = CCONVERT(hap_periodic->attack_level);
envelope->dwAttackTime = hap_periodic->attack_length * 1000;
envelope->dwAttackTime = hap_periodic->attack_length * 1000UL;
envelope->dwFadeLevel = CCONVERT(hap_periodic->fade_level);
envelope->dwFadeTime = hap_periodic->fade_length * 1000;
envelope->dwFadeTime = hap_periodic->fade_length * 1000UL;
}
break;
@@ -761,10 +761,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
dest->lpvTypeSpecificParams = condition;
/* Generics */
dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */
dest->dwDuration = hap_condition->length * 1000UL; /* In microseconds. */
dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button);
dest->dwTriggerRepeatInterval = hap_condition->interval;
dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */
dest->dwStartDelay = hap_condition->delay * 1000UL; /* In microseconds. */
/* Direction. */
if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) {
@@ -792,10 +792,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
dest->lpvTypeSpecificParams = ramp;
/* Generics */
dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */
dest->dwDuration = hap_ramp->length * 1000UL; /* In microseconds. */
dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button);
dest->dwTriggerRepeatInterval = hap_ramp->interval;
dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */
dest->dwStartDelay = hap_ramp->delay * 1000UL; /* In microseconds. */
/* Direction. */
if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
@@ -808,9 +808,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
dest->lpEnvelope = NULL;
} else {
envelope->dwAttackLevel = CCONVERT(hap_ramp->attack_level);
envelope->dwAttackTime = hap_ramp->attack_length * 1000;
envelope->dwAttackTime = hap_ramp->attack_length * 1000UL;
envelope->dwFadeLevel = CCONVERT(hap_ramp->fade_level);
envelope->dwFadeTime = hap_ramp->fade_length * 1000;
envelope->dwFadeTime = hap_ramp->fade_length * 1000UL;
}
break;
@@ -825,7 +825,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
/* Specifics */
custom->cChannels = hap_custom->channels;
custom->dwSamplePeriod = hap_custom->period * 1000;
custom->dwSamplePeriod = hap_custom->period * 1000UL;
custom->cSamples = hap_custom->samples;
custom->rglForceData =
SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
@@ -836,10 +836,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
dest->lpvTypeSpecificParams = custom;
/* Generics */
dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */
dest->dwDuration = hap_custom->length * 1000UL; /* In microseconds. */
dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button);
dest->dwTriggerRepeatInterval = hap_custom->interval;
dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */
dest->dwStartDelay = hap_custom->delay * 1000UL; /* In microseconds. */
/* Direction. */
if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) {
@@ -852,9 +852,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
dest->lpEnvelope = NULL;
} else {
envelope->dwAttackLevel = CCONVERT(hap_custom->attack_level);
envelope->dwAttackTime = hap_custom->attack_length * 1000;
envelope->dwAttackTime = hap_custom->attack_length * 1000UL;
envelope->dwFadeLevel = CCONVERT(hap_custom->fade_level);
envelope->dwFadeTime = hap_custom->fade_length * 1000;
envelope->dwFadeTime = hap_custom->fade_length * 1000UL;
}
break;
@@ -893,6 +893,7 @@ static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT *effect, int type)
/*
* Gets the effect type from the generic SDL haptic effect wrapper.
*/
/* NOLINTNEXTLINE(readability-const-return-type): Can't fix Windows' headers */
static REFGUID SDL_SYS_HapticEffectType(SDL_HapticEffect *effect)
{
switch (effect->type) {
@@ -1088,7 +1089,7 @@ int SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain)
dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = gain * 100; /* 0 to 10,000 */
dipdw.dwData = (DWORD)gain * 100; /* 0 to 10,000 */
/* Try to set the autocenter. */
ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,

View File

@@ -93,7 +93,7 @@ int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid)
/* !!! FIXME: I'm not bothering to query for a real name right now (can we even?) */
{
char buf[64];
SDL_snprintf(buf, sizeof(buf), "XInput Controller #%u", (unsigned int)(userid + 1));
(void)SDL_snprintf(buf, sizeof buf, "XInput Controller #%u", userid + 1);
item->name = SDL_strdup(buf);
}
@@ -204,7 +204,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us
return SDL_SetError("Couldn't create XInput haptic mutex");
}
SDL_snprintf(threadName, sizeof(threadName), "SDLXInputDev%d", (int)userid);
(void)SDL_snprintf(threadName, sizeof threadName, "SDLXInputDev%u", userid);
haptic->hwdata->thread = SDL_CreateThreadInternal(SDL_RunXInputHaptic, threadName, 64 * 1024, haptic->hwdata);
if (haptic->hwdata->thread == NULL) {