CONVERT now checks for overflows. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Tue, 05 Aug 2008 18:26:11 +0000
branchgsoc2008_force_feedback
changeset 2609eec0c81ede06
parent 2608 7c7a63f22afa
child 2610 71a835ee438a
CONVERT now checks for overflows.
src/haptic/darwin/SDL_syshaptic.c
src/haptic/win32/SDL_syshaptic.c
     1.1 --- a/src/haptic/darwin/SDL_syshaptic.c	Tue Aug 05 18:01:09 2008 +0000
     1.2 +++ b/src/haptic/darwin/SDL_syshaptic.c	Tue Aug 05 18:26:11 2008 +0000
     1.3 @@ -576,7 +576,7 @@
     1.4     }
     1.5  }
     1.6  
     1.7 -#define CONVERT(x)   (((x)*10000) / 0x7FFF)
     1.8 +#define CONVERT(x)   (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
     1.9  /*
    1.10   * Creates the FFEFFECT from a SDL_HapticEffect.
    1.11   */
     2.1 --- a/src/haptic/win32/SDL_syshaptic.c	Tue Aug 05 18:01:09 2008 +0000
     2.2 +++ b/src/haptic/win32/SDL_syshaptic.c	Tue Aug 05 18:26:11 2008 +0000
     2.3 @@ -575,7 +575,7 @@
     2.4     }
     2.5  }
     2.6  
     2.7 -#define CONVERT(x)   (((x)*10000) / 0x7FFF)
     2.8 +#define CONVERT(x)   (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
     2.9  /*
    2.10   * Creates the DIEFFECT from a SDL_HapticEffect.
    2.11   */