Fixed some ultra-pedantic gcc warnings
authorSam Lantinga <slouken@libsdl.org>
Fri, 24 Mar 2006 06:10:24 +0000
changeset 161297d0966f4bf7
parent 1611 ec3466b08f17
child 1613 2095da6364c9
Fixed some ultra-pedantic gcc warnings
src/SDL_error.c
src/audio/SDL_mixer_MMX.c
src/audio/SDL_wave.c
src/audio/dsp/SDL_dspaudio.c
src/events/SDL_events_c.h
src/events/SDL_keyboard.c
src/joystick/SDL_joystick.c
src/thread/SDL_thread.c
src/video/SDL_gamma.c
     1.1 --- a/src/SDL_error.c	Fri Mar 24 05:11:51 2006 +0000
     1.2 +++ b/src/SDL_error.c	Fri Mar 24 06:10:24 2006 +0000
     1.3 @@ -90,11 +90,11 @@
     1.4  				break;
     1.5  			    case 's':
     1.6  				{
     1.7 -				  int index = error->argc;
     1.8 -				  char *str = va_arg(ap, char *);
     1.9 +				  int i = error->argc;
    1.10 +				  const char *str = va_arg(ap, const char *);
    1.11  				  if (str == NULL)
    1.12  				      str = "(null)";
    1.13 -				  SDL_strlcpy((char *)error->args[index].buf, str, ERR_MAX_STRLEN);
    1.14 +				  SDL_strlcpy((char *)error->args[i].buf, str, ERR_MAX_STRLEN);
    1.15  				  error->argc++;
    1.16  				}
    1.17  				break;
     2.1 --- a/src/audio/SDL_mixer_MMX.c	Fri Mar 24 05:11:51 2006 +0000
     2.2 +++ b/src/audio/SDL_mixer_MMX.c	Fri Mar 24 06:10:24 2006 +0000
     2.3 @@ -40,11 +40,11 @@
     2.4  {
     2.5      __asm__ __volatile__ (
     2.6  
     2.7 -"	movl %3,%%eax\n"	// eax = volume
     2.8 +"	movl %3,%%eax\n"	/* eax = volume */
     2.9  
    2.10 -"	movl %2,%%edx\n"	// edx = size
    2.11 +"	movl %2,%%edx\n"	/* edx = size */
    2.12  
    2.13 -"	shrl $4,%%edx\n"	// process 16 bytes per iteration = 8 samples
    2.14 +"	shrl $4,%%edx\n"	/* process 16 bytes per iteration = 8 samples */
    2.15  
    2.16  "	jz .endS16\n"
    2.17  
    2.18 @@ -57,62 +57,62 @@
    2.19  "	psllq $16,%%mm0\n"
    2.20  "	por %%mm1,%%mm0\n"
    2.21  "	psllq $16,%%mm0\n"
    2.22 -"	por %%mm1,%%mm0\n"		// mm0 = vol|vol|vol|vol
    2.23 +"	por %%mm1,%%mm0\n"		/* mm0 = vol|vol|vol|vol */
    2.24  
    2.25  ".align 8\n"
    2.26  "	.mixloopS16:\n"
    2.27  
    2.28 -"	movq (%1),%%mm1\n" // mm1 = a|b|c|d
    2.29 +"	movq (%1),%%mm1\n" /* mm1 = a|b|c|d */
    2.30  
    2.31 -"	movq %%mm1,%%mm2\n" // mm2 = a|b|c|d
    2.32 +"	movq %%mm1,%%mm2\n" /* mm2 = a|b|c|d */
    2.33  
    2.34 -"	movq 8(%1),%%mm4\n" // mm4 = e|f|g|h
    2.35 +"	movq 8(%1),%%mm4\n" /* mm4 = e|f|g|h */
    2.36  
    2.37 -	// pré charger le buffer dst dans mm7
    2.38 -"	movq (%0),%%mm7\n" // mm7 = dst[0]"
    2.39 +	/* pré charger le buffer dst dans mm7 */
    2.40 +"	movq (%0),%%mm7\n" /* mm7 = dst[0] */
    2.41  
    2.42 -	// multiplier par le volume
    2.43 -"	pmullw %%mm0,%%mm1\n" // mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v)
    2.44 +	/* multiplier par le volume */
    2.45 +"	pmullw %%mm0,%%mm1\n" /* mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */
    2.46  
    2.47 -"	pmulhw %%mm0,%%mm2\n" // mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v)
    2.48 -"	movq %%mm4,%%mm5\n" // mm5 = e|f|g|h
    2.49 +"	pmulhw %%mm0,%%mm2\n" /* mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v) */
    2.50 +"	movq %%mm4,%%mm5\n" /* mm5 = e|f|g|h */
    2.51  
    2.52 -"	pmullw %%mm0,%%mm4\n" // mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v)
    2.53 +"	pmullw %%mm0,%%mm4\n" /* mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */
    2.54  
    2.55 -"	pmulhw %%mm0,%%mm5\n" // mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v)
    2.56 -"	movq %%mm1,%%mm3\n" // mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v)
    2.57 +"	pmulhw %%mm0,%%mm5\n" /* mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v) */
    2.58 +"	movq %%mm1,%%mm3\n" /* mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */
    2.59  
    2.60 -"	punpckhwd %%mm2,%%mm1\n" // mm1 = a*v|b*v
    2.61 +"	punpckhwd %%mm2,%%mm1\n" /* mm1 = a*v|b*v */
    2.62  
    2.63 -"	movq %%mm4,%%mm6\n" // mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v)
    2.64 -"	punpcklwd %%mm2,%%mm3\n" // mm3 = c*v|d*v
    2.65 +"	movq %%mm4,%%mm6\n" /* mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */
    2.66 +"	punpcklwd %%mm2,%%mm3\n" /* mm3 = c*v|d*v */
    2.67  
    2.68 -"	punpckhwd %%mm5,%%mm4\n" // mm4 = e*f|f*v
    2.69 +"	punpckhwd %%mm5,%%mm4\n" /* mm4 = e*f|f*v */
    2.70  
    2.71 -"	punpcklwd %%mm5,%%mm6\n" // mm6 = g*v|h*v
    2.72 +"	punpcklwd %%mm5,%%mm6\n" /* mm6 = g*v|h*v */
    2.73  
    2.74 -	// pré charger le buffer dst dans mm5
    2.75 -"	movq 8(%0),%%mm5\n" // mm5 = dst[1]
    2.76 +	/* pré charger le buffer dst dans mm5 */
    2.77 +"	movq 8(%0),%%mm5\n" /* mm5 = dst[1] */
    2.78  
    2.79 -	// diviser par 128
    2.80 -"	psrad $7,%%mm1\n" // mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME
    2.81 +	/* diviser par 128 */
    2.82 +"	psrad $7,%%mm1\n" /* mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME */
    2.83  "	add $16,%1\n"
    2.84  
    2.85 -"	psrad $7,%%mm3\n" // mm3 = c*v/128|d*v/128
    2.86 +"	psrad $7,%%mm3\n" /* mm3 = c*v/128|d*v/128 */
    2.87  
    2.88 -"	psrad $7,%%mm4\n" // mm4 = e*v/128|f*v/128
    2.89 +"	psrad $7,%%mm4\n" /* mm4 = e*v/128|f*v/128 */
    2.90  
    2.91 -	// mm1 = le sample avec le volume modifié
    2.92 -"	packssdw %%mm1,%%mm3\n" // mm3 = s(a*v|b*v|c*v|d*v)
    2.93 +	/* mm1 = le sample avec le volume modifié */
    2.94 +"	packssdw %%mm1,%%mm3\n" /* mm3 = s(a*v|b*v|c*v|d*v) */
    2.95  
    2.96 -"	psrad $7,%%mm6\n" // mm6= g*v/128|h*v/128
    2.97 -"	paddsw %%mm7,%%mm3\n" // mm3 = adjust_volume(src)+dst
    2.98 +"	psrad $7,%%mm6\n" /* mm6= g*v/128|h*v/128 */
    2.99 +"	paddsw %%mm7,%%mm3\n" /* mm3 = adjust_volume(src)+dst */
   2.100  
   2.101 -	// mm4 = le sample avec le volume modifié
   2.102 -"	packssdw %%mm4,%%mm6\n" // mm6 = s(e*v|f*v|g*v|h*v)
   2.103 +	/* mm4 = le sample avec le volume modifié */
   2.104 +"	packssdw %%mm4,%%mm6\n" /* mm6 = s(e*v|f*v|g*v|h*v) */
   2.105  "	movq %%mm3,(%0)\n"
   2.106  
   2.107 -"	paddsw %%mm5,%%mm6\n" // mm6 = adjust_volume(src)+dst
   2.108 +"	paddsw %%mm5,%%mm6\n" /* mm6 = adjust_volume(src)+dst */
   2.109  
   2.110  "	movq %%mm6,8(%0)\n"
   2.111  
   2.112 @@ -134,15 +134,15 @@
   2.113  
   2.114  
   2.115  
   2.116 -////////////////////////////////////////////////
   2.117 -// Mixing for 8 bit signed buffers
   2.118 -////////////////////////////////////////////////
   2.119 +/*////////////////////////////////////////////// */
   2.120 +/* Mixing for 8 bit signed buffers */
   2.121 +/*////////////////////////////////////////////// */
   2.122  
   2.123  void SDL_MixAudio_MMX_S8(char* dst,char* src,unsigned int size,int volume)
   2.124  {
   2.125      __asm__ __volatile__ (
   2.126  
   2.127 -"	movl %3,%%eax\n"	// eax = volume
   2.128 +"	movl %3,%%eax\n"	/* eax = volume */
   2.129  
   2.130  "	movd %%eax,%%mm0\n"
   2.131  "	movq %%mm0,%%mm1\n"
   2.132 @@ -153,8 +153,8 @@
   2.133  "	psllq $16,%%mm0\n"
   2.134  "	por %%mm1,%%mm0\n"
   2.135  
   2.136 -"	movl %2,%%edx\n"	// edx = size
   2.137 -"	shr $3,%%edx\n"	// process 8 bytes per iteration = 8 samples
   2.138 +"	movl %2,%%edx\n"	/* edx = size */
   2.139 +"	shr $3,%%edx\n"	/* process 8 bytes per iteration = 8 samples */
   2.140  
   2.141  "	cmp $0,%%edx\n"
   2.142  "	je .endS8\n"
   2.143 @@ -162,32 +162,32 @@
   2.144  ".align 8\n"
   2.145  "	.mixloopS8:\n"
   2.146  
   2.147 -"	pxor %%mm2,%%mm2\n"		// mm2 = 0
   2.148 -"	movq (%1),%%mm1\n"	// mm1 = a|b|c|d|e|f|g|h
   2.149 +"	pxor %%mm2,%%mm2\n"		/* mm2 = 0 */
   2.150 +"	movq (%1),%%mm1\n"	/* mm1 = a|b|c|d|e|f|g|h */
   2.151  
   2.152 -"	movq %%mm1,%%mm3\n" 	// mm3 = a|b|c|d|e|f|g|h
   2.153 +"	movq %%mm1,%%mm3\n" 	/* mm3 = a|b|c|d|e|f|g|h */
   2.154  
   2.155 -	// on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0
   2.156 -"	pcmpgtb %%mm1,%%mm2\n"	// mm2 = 11111111|00000000|00000000....
   2.157 +	/* on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0 */
   2.158 +"	pcmpgtb %%mm1,%%mm2\n"	/* mm2 = 11111111|00000000|00000000.... */
   2.159  
   2.160 -"	punpckhbw %%mm2,%%mm1\n"	// mm1 = 0|a|0|b|0|c|0|d
   2.161 +"	punpckhbw %%mm2,%%mm1\n"	/* mm1 = 0|a|0|b|0|c|0|d */
   2.162  
   2.163 -"	punpcklbw %%mm2,%%mm3\n"	// mm3 = 0|e|0|f|0|g|0|h
   2.164 -"	movq (%0),%%mm2\n"	// mm2 = destination
   2.165 +"	punpcklbw %%mm2,%%mm3\n"	/* mm3 = 0|e|0|f|0|g|0|h */
   2.166 +"	movq (%0),%%mm2\n"	/* mm2 = destination */
   2.167  
   2.168 -"	pmullw %%mm0,%%mm1\n"	// mm1 = v*a|v*b|v*c|v*d
   2.169 +"	pmullw %%mm0,%%mm1\n"	/* mm1 = v*a|v*b|v*c|v*d */
   2.170  "	add $8,%1\n"
   2.171  
   2.172 -"	pmullw %%mm0,%%mm3\n"	// mm3 = v*e|v*f|v*g|v*h
   2.173 -"	psraw $7,%%mm1\n"		// mm1 = v*a/128|v*b/128|v*c/128|v*d/128 
   2.174 +"	pmullw %%mm0,%%mm3\n"	/* mm3 = v*e|v*f|v*g|v*h */
   2.175 +"	psraw $7,%%mm1\n"		/* mm1 = v*a/128|v*b/128|v*c/128|v*d/128  */
   2.176  
   2.177 -"	psraw $7,%%mm3\n"		// mm3 = v*e/128|v*f/128|v*g/128|v*h/128
   2.178 +"	psraw $7,%%mm3\n"		/* mm3 = v*e/128|v*f/128|v*g/128|v*h/128 */
   2.179  
   2.180 -"	packsswb %%mm1,%%mm3\n"	// mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128
   2.181 +"	packsswb %%mm1,%%mm3\n"	/* mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128 */
   2.182  
   2.183 -"	paddsb %%mm2,%%mm3\n"	// add to destination buffer
   2.184 +"	paddsb %%mm2,%%mm3\n"	/* add to destination buffer */
   2.185  
   2.186 -"	movq %%mm3,(%0)\n"	// store back to ram
   2.187 +"	movq %%mm3,(%0)\n"	/* store back to ram */
   2.188  "	add $8,%0\n"
   2.189  
   2.190  "	dec %%edx\n"
     3.1 --- a/src/audio/SDL_wave.c	Fri Mar 24 05:11:51 2006 +0000
     3.2 +++ b/src/audio/SDL_wave.c	Fri Mar 24 06:10:24 2006 +0000
     3.3 @@ -329,7 +329,7 @@
     3.4  	struct IMA_ADPCM_decodestate *state;
     3.5  	Uint8 *freeable, *encoded, *decoded;
     3.6  	Sint32 encoded_len, samplesleft;
     3.7 -	int c, channels;
     3.8 +	unsigned int c, channels;
     3.9  
    3.10  	/* Check to make sure we have enough variables in the state array */
    3.11  	channels = IMA_ADPCM_state.wavefmt.channels;
     4.1 --- a/src/audio/dsp/SDL_dspaudio.c	Fri Mar 24 05:11:51 2006 +0000
     4.2 +++ b/src/audio/dsp/SDL_dspaudio.c	Fri Mar 24 06:10:24 2006 +0000
     4.3 @@ -288,8 +288,8 @@
     4.4  	SDL_CalculateAudioSpec(spec);
     4.5  
     4.6  	/* Determine the power of two of the fragment size */
     4.7 -	for ( frag_spec = 0; (0x01<<frag_spec) < spec->size; ++frag_spec );
     4.8 -	if ( (0x01<<frag_spec) != spec->size ) {
     4.9 +	for ( frag_spec = 0; (0x01U<<frag_spec) < spec->size; ++frag_spec );
    4.10 +	if ( (0x01U<<frag_spec) != spec->size ) {
    4.11  		SDL_SetError("Fragment size must be a power of two");
    4.12  		DSP_CloseAudio(this);
    4.13  		return(-1);
     5.1 --- a/src/events/SDL_events_c.h	Fri Mar 24 05:11:51 2006 +0000
     5.2 +++ b/src/events/SDL_events_c.h	Fri Mar 24 06:10:24 2006 +0000
     5.3 @@ -29,8 +29,8 @@
     5.4  extern void SDL_StopEventLoop(void);
     5.5  extern void SDL_QuitInterrupt(void);
     5.6  
     5.7 -extern void SDL_Lock_EventThread();
     5.8 -extern void SDL_Unlock_EventThread();
     5.9 +extern void SDL_Lock_EventThread(void);
    5.10 +extern void SDL_Unlock_EventThread(void);
    5.11  extern Uint32 SDL_EventThreadID(void);
    5.12  
    5.13  /* Event handler init routines */
     6.1 --- a/src/events/SDL_keyboard.c	Fri Mar 24 05:11:51 2006 +0000
     6.2 +++ b/src/events/SDL_keyboard.c	Fri Mar 24 06:10:24 2006 +0000
     6.3 @@ -34,7 +34,7 @@
     6.4  static SDLMod SDL_ModState;
     6.5  int SDL_TranslateUNICODE = 0;
     6.6  
     6.7 -static char *keynames[SDLK_LAST];	/* Array of keycode names */
     6.8 +static const char *keynames[SDLK_LAST];	/* Array of keycode names */
     6.9  
    6.10  /*
    6.11   * jk 991215 - added
    6.12 @@ -356,7 +356,7 @@
    6.13  
    6.14  char *SDL_GetKeyName(SDLKey key)
    6.15  {
    6.16 -	char *keyname;
    6.17 +	const char *keyname;
    6.18  
    6.19  	keyname = NULL;
    6.20  	if ( key < SDLK_LAST ) {
    6.21 @@ -365,7 +365,8 @@
    6.22  	if ( keyname == NULL ) {
    6.23  		keyname = "unknown key";
    6.24  	}
    6.25 -	return(keyname);
    6.26 +	/* FIXME: make this function const in 1.3 */
    6.27 +	return (char *)(keyname);
    6.28  }
    6.29  
    6.30  /* These are global for SDL_eventloop.c */
     7.1 --- a/src/joystick/SDL_joystick.c	Fri Mar 24 05:11:51 2006 +0000
     7.2 +++ b/src/joystick/SDL_joystick.c	Fri Mar 24 06:10:24 2006 +0000
     7.3 @@ -550,7 +550,7 @@
     7.4  		SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYHATMOTION,
     7.5  		SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP,
     7.6  	};
     7.7 -	int i;
     7.8 +	unsigned int i;
     7.9  
    7.10  	switch (state) {
    7.11  		case SDL_QUERY:
     8.1 --- a/src/thread/SDL_thread.c	Fri Mar 24 05:11:51 2006 +0000
     8.2 +++ b/src/thread/SDL_thread.c	Fri Mar 24 06:10:24 2006 +0000
     8.3 @@ -55,7 +55,7 @@
     8.4     clean up threads here.  If any threads are still running after this call,
     8.5     they will no longer have access to any per-thread data.
     8.6   */
     8.7 -void SDL_ThreadsQuit()
     8.8 +void SDL_ThreadsQuit(void)
     8.9  {
    8.10  	SDL_mutex *mutex;
    8.11  
     9.1 --- a/src/video/SDL_gamma.c	Fri Mar 24 05:11:51 2006 +0000
     9.2 +++ b/src/video/SDL_gamma.c	Fri Mar 24 06:10:24 2006 +0000
     9.3 @@ -43,14 +43,14 @@
     9.4  	int i;
     9.5  
     9.6  	/* 0.0 gamma is all black */
     9.7 -	if ( gamma <= 0.0 ) {
     9.8 +	if ( gamma <= 0.0f ) {
     9.9  		for ( i=0; i<256; ++i ) {
    9.10  			ramp[i] = 0;
    9.11  		}
    9.12  		return;
    9.13  	} else
    9.14  	/* 1.0 gamma is identity */
    9.15 -	if ( gamma == 1.0 ) {
    9.16 +	if ( gamma >= 1.0f ) {
    9.17  		for ( i=0; i<256; ++i ) {
    9.18  			ramp[i] = (i << 8) | i;
    9.19  		}
    9.20 @@ -73,7 +73,7 @@
    9.21  	/* The following is adapted from a post by Garrett Bass on OpenGL
    9.22  	   Gamedev list, March 4, 2000.
    9.23  	 */
    9.24 -	float sum = 0.0;
    9.25 +	float sum = 0.0f;
    9.26  	int i, count = 0;
    9.27  
    9.28  	*gamma = 1.0;
    9.29 @@ -85,7 +85,7 @@
    9.30  	        count++;
    9.31  	    }
    9.32  	}
    9.33 -	if ( count && sum ) {
    9.34 +	if ( count && sum > 0.0f ) {
    9.35  		*gamma = 1.0f / (sum / count);
    9.36  	}
    9.37  }