Bläddra i källkod

Fixed analyze warnings in SDL_xinputhaptic.c

warning C6340: Mismatch on sign: 'int' passed as _Param_(4) when some unsigned type is required in call to 'SDL_snprintf_REAL'.
warning C6340: Mismatch on sign: 'const unsigned char' passed as _Param_(4) when some signed type is required in call to 'SDL_snprintf_REAL'.
warning C26451: Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
Sam Lantinga 1 år sedan
förälder
incheckning
b8840801cc
1 ändrade filer med 3 tillägg och 3 borttagningar
  1. 3 3
      src/haptic/windows/SDL_xinputhaptic.c

+ 3 - 3
src/haptic/windows/SDL_xinputhaptic.c

@@ -86,7 +86,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];
-        (void)SDL_snprintf(buf, sizeof(buf), "XInput Controller #%u", userid + 1);
+        (void)SDL_snprintf(buf, sizeof(buf), "XInput Controller #%d", 1 + userid);
         item->name = SDL_strdup(buf);
     }
 
@@ -196,7 +196,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us
         return SDL_SetError("Couldn't create XInput haptic mutex");
     }
 
-    (void)SDL_snprintf(threadName, sizeof(threadName), "SDLXInputDev%d", 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) {
@@ -283,7 +283,7 @@ int SDL_XINPUT_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
     } else if ((!effect->effect.leftright.length) || (!iterations)) {
         /* do nothing. Effect runs for zero milliseconds. */
     } else {
-        haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.leftright.length * iterations);
+        haptic->hwdata->stopTicks = SDL_GetTicks() + ((Uint64)effect->effect.leftright.length * iterations);
     }
     SDL_UnlockMutex(haptic->hwdata->mutex);
     return (XINPUTSETSTATE(haptic->hwdata->userid, vib) == ERROR_SUCCESS) ? 0 : -1;