From: <av...@us...> - 2011-09-06 22:14:26
|
Revision: 3688 http://sc2.svn.sourceforge.net/sc2/?rev=3688&view=rev Author: avolkov Date: 2011-09-06 22:14:20 +0000 (Tue, 06 Sep 2011) Log Message: ----------- Various strict warnings cleanup, bug #50; from Scott A. Colcord Modified Paths: -------------- trunk/sc2/src/libs/graphics/sdl/opengl.c trunk/sc2/src/libs/graphics/sdl/rotozoom.c trunk/sc2/src/libs/input/sdl/input.c trunk/sc2/src/libs/input/sdl/keynames.c trunk/sc2/src/libs/input/sdl/keynames.h trunk/sc2/src/libs/input/sdl/vcontrol.c trunk/sc2/src/libs/sound/decoders/dukaud.c trunk/sc2/src/libs/sound/decoders/modaud.c trunk/sc2/src/libs/sound/sndintrn.h trunk/sc2/src/libs/sound/sound.h trunk/sc2/src/libs/sound/stream.c trunk/sc2/src/libs/video/vidplayer.c trunk/sc2/src/uqm/weapon.c trunk/sc2/src/uqm.c Modified: trunk/sc2/src/libs/graphics/sdl/opengl.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/opengl.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/graphics/sdl/opengl.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -307,7 +307,7 @@ GL_Screens[TFB_SCREEN_TRANSITION].dirty = TRUE; } -void +static void TFB_GL_ScanLines (void) { int y; Modified: trunk/sc2/src/libs/graphics/sdl/rotozoom.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/rotozoom.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/graphics/sdl/rotozoom.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -222,6 +222,7 @@ */ +static int zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst) { Uint32 sx, sy, *sax, *say, *csax, *csay, csx, csy; @@ -342,6 +343,7 @@ */ +static void transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int smooth) { int x, y, t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh; @@ -497,6 +499,7 @@ */ +static void transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos) { int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay, sw, sh; @@ -557,6 +560,7 @@ /* Local rotozoom-size function with trig result return */ +static void rotozoomSurfaceSizeTrig(int width, int height, double angle, double zoom, int *dstwidth, int *dstheight, double *canglezoom, double *sanglezoom) { @@ -578,8 +582,8 @@ cy = *canglezoom * y; sx = *sanglezoom * x; sy = *sanglezoom * y; - dstwidthhalf = MAX((int) ceil(fabs(cx) + fabs(sy)), 1); - dstheighthalf = MAX((int) ceil(fabs(sx) + fabs(cy)), 1); + dstwidthhalf = MAX(ceil(fabs(cx) + fabs(sy)), 1); + dstheighthalf = MAX(ceil(fabs(sx) + fabs(cy)), 1); *dstwidth = 2 * dstwidthhalf; *dstheight = 2 * dstheighthalf; } Modified: trunk/sc2/src/libs/input/sdl/input.c =================================================================== --- trunk/sc2/src/libs/input/sdl/input.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/input/sdl/input.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -322,7 +322,7 @@ volatile int MouseButtonDown = 0; -void +static void ProcessMouseEvent (const SDL_Event *e) { switch (e->type) Modified: trunk/sc2/src/libs/input/sdl/keynames.c =================================================================== --- trunk/sc2/src/libs/input/sdl/keynames.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/input/sdl/keynames.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -33,7 +33,7 @@ * tragedy. */ typedef struct vcontrol_keyname { - /* const */ char *name; + const char *name; int code; } keyname; @@ -182,7 +182,7 @@ {"Unknown", 0}}; /* Last element must have code zero */ -char * +const char * VControl_code2name (int code) { int i = 0; @@ -198,12 +198,12 @@ } int -VControl_name2code (char *name) +VControl_name2code (const char *name) { int i = 0; while (1) { - char *test = keynames[i].name; + const char *test = keynames[i].name; int code = keynames[i].code; if (!strcasecmp(test, name) || !code) { Modified: trunk/sc2/src/libs/input/sdl/keynames.h =================================================================== --- trunk/sc2/src/libs/input/sdl/keynames.h 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/input/sdl/keynames.h 2011-09-06 22:14:20 UTC (rev 3688) @@ -17,6 +17,6 @@ #ifndef _KEYNAMES_H_ #define _KEYNAMES_H_ -char *VControl_code2name (int code); -int VControl_name2code (char *code); +const char *VControl_code2name (int code); +int VControl_name2code (const char *code); #endif Modified: trunk/sc2/src/libs/input/sdl/vcontrol.c =================================================================== --- trunk/sc2/src/libs/input/sdl/vcontrol.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/input/sdl/vcontrol.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -184,8 +184,10 @@ key_init (void) { unsigned int i; + int num_keys; // Temp to match type of param for SDL_GetKeyState(). pool = allocate_key_chunk (); - (void)SDL_GetKeyState (&num_sdl_keys); + (void)SDL_GetKeyState (&num_keys); + num_sdl_keys = num_keys; bindings = (keybinding **) HMalloc (sizeof (keybinding *) * num_sdl_keys); for (i = 0; i < num_sdl_keys; i++) bindings[i] = NULL; Modified: trunk/sc2/src/libs/sound/decoders/dukaud.c =================================================================== --- trunk/sc2/src/libs/sound/decoders/dukaud.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/sound/decoders/dukaud.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -105,7 +105,7 @@ static const TFB_DecoderFormats* duka_formats = NULL; -sint32 +static sint32 duka_readAudFrameHeader (TFB_DuckSoundDecoder* duka, uint32 iframe, DukAud_AudSubframe* aud) { @@ -246,7 +246,7 @@ } // *** END part copied from MPlayer *** -sint32 +static sint32 duka_decodeFrame (TFB_DuckSoundDecoder* duka, DukAud_AudSubframe* header, uint8* input) { @@ -273,7 +273,7 @@ } -sint32 +static sint32 duka_readNextFrame (TFB_DuckSoundDecoder* duka) { DukAud_FrameHeader hdr; Modified: trunk/sc2/src/libs/sound/decoders/modaud.c =================================================================== --- trunk/sc2/src/libs/sound/decoders/modaud.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/sound/decoders/modaud.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -88,7 +88,7 @@ static ULONG bufsize; static ULONG written; -ULONG* +static ULONG* moda_mmout_SetOutputBuffer (void* buf, ULONG size) { buffer = buf; @@ -132,12 +132,18 @@ return 0; } +static char MDRIVER_name[] = "Mem Buffer"; +static char MDRIVER_version[] = "Mem Buffer driver v1.1"; +static char MDRIVER_alias[] = "membuf"; + static MDRIVER moda_mmout_drv = -{ NULL, - "Mem Buffer", // Name - "Mem Buffer driver v1.1", // Version - 0, 255, // Voice limits - "membuf", // Alias +{ + NULL, + //xxx libmikmod does not declare these fields const; it probably should. + MDRIVER_name, // Name + MDRIVER_version, // Version + 0, 255, // Voice limits + MDRIVER_alias, // Alias // The minimum mikmod version we support is 3.1.8 #if (LIBMIKMOD_VERSION_MAJOR > 3) || \ @@ -215,7 +221,7 @@ return uio_ftell (((MUIOREADER*)reader)->file); } -MREADER* +static MREADER* moda_new_uioReader (uio_Stream* fp) { MUIOREADER* reader = (MUIOREADER*) HMalloc (sizeof(MUIOREADER)); @@ -231,7 +237,7 @@ return (MREADER*)reader; } -void +static void moda_delete_uioReader (MREADER* reader) { if (reader) Modified: trunk/sc2/src/libs/sound/sndintrn.h =================================================================== --- trunk/sc2/src/libs/sound/sndintrn.h 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/sound/sndintrn.h 2011-09-06 22:14:20 UTC (rev 3688) @@ -46,7 +46,7 @@ uint32 num_buffers; TFB_SoundTag *buffer_tag; sint32 offset; // initial offset - intptr_t data; // user-defined data + void* data; // user-defined data TFB_SoundCallbacks callbacks; // user-defined callbacks }; Modified: trunk/sc2/src/libs/sound/sound.h =================================================================== --- trunk/sc2/src/libs/sound/sound.h 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/sound/sound.h 2011-09-06 22:14:20 UTC (rev 3688) @@ -66,8 +66,8 @@ TFB_SoundSample *TFB_CreateSoundSample (TFB_SoundDecoder*, uint32 num_buffers, const TFB_SoundCallbacks* /* can be NULL */); void TFB_DestroySoundSample (TFB_SoundSample*); -void TFB_SetSoundSampleData (TFB_SoundSample*, intptr_t data); -intptr_t TFB_GetSoundSampleData (TFB_SoundSample*); +void TFB_SetSoundSampleData (TFB_SoundSample*, void* data); +void* TFB_GetSoundSampleData (TFB_SoundSample*); void TFB_SetSoundSampleCallbacks (TFB_SoundSample*, const TFB_SoundCallbacks* /* can be NULL */); TFB_SoundDecoder* TFB_GetSoundSampleDecoder (TFB_SoundSample*); Modified: trunk/sc2/src/libs/sound/stream.c =================================================================== --- trunk/sc2/src/libs/sound/stream.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/sound/stream.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -225,12 +225,12 @@ } void -TFB_SetSoundSampleData (TFB_SoundSample *sample, intptr_t data) +TFB_SetSoundSampleData (TFB_SoundSample *sample, void* data) { sample->data = data; } -intptr_t +void* TFB_GetSoundSampleData (TFB_SoundSample *sample) { return sample->data; Modified: trunk/sc2/src/libs/video/vidplayer.c =================================================================== --- trunk/sc2/src/libs/video/vidplayer.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/video/vidplayer.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -273,7 +273,7 @@ } TFB_SetSoundSampleCallbacks (*vid->hAudio, &vp_AudioCBs); - TFB_SetSoundSampleData (*vid->hAudio, (intptr_t)vid); + TFB_SetSoundSampleData (*vid->hAudio, vid); } // get the first frame @@ -432,7 +432,7 @@ static bool vp_AudioStart (TFB_SoundSample* sample) { - TFB_VideoClip* vid = (TFB_VideoClip*) TFB_GetSoundSampleData (sample); + TFB_VideoClip* vid = TFB_GetSoundSampleData (sample); TFB_SoundDecoder *decoder; assert (sizeof (intptr_t) >= sizeof (vid)); @@ -450,7 +450,7 @@ static void vp_AudioEnd (TFB_SoundSample* sample) { - TFB_VideoClip* vid = (TFB_VideoClip*) TFB_GetSoundSampleData (sample); + TFB_VideoClip* vid = TFB_GetSoundSampleData (sample); assert (vid != NULL); @@ -462,7 +462,7 @@ static void vp_BufferTag (TFB_SoundSample* sample, TFB_SoundTag* tag) { - TFB_VideoClip* vid = (TFB_VideoClip*) TFB_GetSoundSampleData (sample); + TFB_VideoClip* vid = TFB_GetSoundSampleData (sample); uint32 frame = (uint32) tag->data; assert (sizeof (tag->data) >= sizeof (frame)); Modified: trunk/sc2/src/uqm/weapon.c =================================================================== --- trunk/sc2/src/uqm/weapon.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/uqm/weapon.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -31,7 +31,16 @@ #include <stdio.h> +// A wrapper function for weapon_collision that discards the return value. +// This makes its signature match ElementCollisionFunc. +static void +weapon_collision_cb (ELEMENT *WeaponElementPtr, POINT *pWPt, + ELEMENT *HitElementPtr, POINT *pHPt) +{ + weapon_collision (WeaponElementPtr, pWPt, HitElementPtr, pHPt); +} + HELEMENT initialize_laser (LASER_BLOCK *pLaserBlock) { @@ -50,7 +59,7 @@ LaserElementPtr->state_flags = APPEARING | FINITE_LIFE | pLaserBlock->flags; LaserElementPtr->life_span = LASER_LIFE; - LaserElementPtr->collision_func = weapon_collision; + LaserElementPtr->collision_func = weapon_collision_cb; LaserElementPtr->blast_offset = 1; LaserElementPtr->current.location.x = pLaserBlock->cx @@ -100,7 +109,7 @@ SetAbsFrameIndex (pMissileBlock->farray[0], pMissileBlock->index); MissileElementPtr->preprocess_func = pMissileBlock->preprocess_func; - MissileElementPtr->collision_func = weapon_collision; + MissileElementPtr->collision_func = weapon_collision_cb; MissileElementPtr->blast_offset = (BYTE)pMissileBlock->blast_offs; angle = FACING_TO_ANGLE (pMissileBlock->face); Modified: trunk/sc2/src/uqm.c =================================================================== --- trunk/sc2/src/uqm.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/uqm.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -27,6 +27,7 @@ #endif #include <stdarg.h> +#include <errno.h> #include "libs/graphics/gfx_common.h" #include "libs/graphics/cmap.h" #include "libs/sound/sound.h" @@ -279,7 +280,11 @@ if (options.logFile != NULL) { int i; - freopen (options.logFile, "w", stderr); + if (!freopen (options.logFile, "w", stderr)) + { + printf ("Error %d calling freopen() on stderr\n", errno); + return EXIT_FAILURE; + } #ifdef UNBUFFERED_LOGFILE setbuf (stderr, NULL); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |