changeset 2609:eec0c81ede06 gsoc2008_force_feedback

CONVERT now checks for overflows.
author Edgar Simo <bobbens@gmail.com>
date Tue, 05 Aug 2008 18:26:11 +0000
parents 7c7a63f22afa
children 71a835ee438a
files src/haptic/darwin/SDL_syshaptic.c src/haptic/win32/SDL_syshaptic.c
diffstat 2 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/haptic/darwin/SDL_syshaptic.c	Tue Aug 05 18:01:09 2008 +0000
+++ b/src/haptic/darwin/SDL_syshaptic.c	Tue Aug 05 18:26:11 2008 +0000
@@ -576,7 +576,7 @@
    }
 }
 
-#define CONVERT(x)   (((x)*10000) / 0x7FFF)
+#define CONVERT(x)   (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
 /*
  * Creates the FFEFFECT from a SDL_HapticEffect.
  */
--- a/src/haptic/win32/SDL_syshaptic.c	Tue Aug 05 18:01:09 2008 +0000
+++ b/src/haptic/win32/SDL_syshaptic.c	Tue Aug 05 18:26:11 2008 +0000
@@ -575,7 +575,7 @@
    }
 }
 
-#define CONVERT(x)   (((x)*10000) / 0x7FFF)
+#define CONVERT(x)   (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
 /*
  * Creates the DIEFFECT from a SDL_HapticEffect.
  */