Skip to content

Commit

Permalink
Fixed numerous compilation warnings/errors reported with /W4
Browse files Browse the repository at this point in the history
Fixed an issue with releasing input devices on Win32 which sometimes led to a segfault on shutdown.
  • Loading branch information
danij committed Apr 4, 2007
1 parent 78e983e commit 6746898
Show file tree
Hide file tree
Showing 50 changed files with 384 additions and 258 deletions.
14 changes: 7 additions & 7 deletions doomsday/engine/api/doomsday.h
Expand Up @@ -91,8 +91,8 @@ extern "C" {
int DD_GetKeyCode(const char *name);

// Base: WAD.
int W_CheckNumForName(char *name);
int W_GetNumForName(char *name);
int W_CheckNumForName(const char *name);
int W_GetNumForName(const char *name);
size_t W_LumpLength(int lump);
const char *W_LumpName(int lump);
void W_ReadLump(int lump, void *dest);
Expand Down Expand Up @@ -341,14 +341,14 @@ extern "C" {
void R_GetSpriteInfo(int sprite, int frame,
spriteinfo_t *sprinfo);
void R_GetPatchInfo(int lump, spriteinfo_t *info);
int R_FlatNumForName(char *name);
int R_CheckTextureNumForName(char *name);
int R_TextureNumForName(char *name);
char *R_TextureNameForNum(int num);
int R_FlatNumForName(const char *name);
int R_CheckTextureNumForName(const char *name);
int R_TextureNumForName(const char *name);
const char *R_TextureNameForNum(int num);
int R_SetFlatTranslation(int flat, int translate_to);
int R_SetTextureTranslation(int tex, int translate_to);
int R_CreateAnimGroup(int type, int flags);
void R_AddToAnimGroup(int groupNum, char *name,
void R_AddToAnimGroup(int groupNum, const char *name,
int tics, int randomTics);
angle_t R_PointToAngle2(fixed_t x1, fixed_t y1, fixed_t x2,
fixed_t y2);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/include/dd_wad.h
Expand Up @@ -72,8 +72,8 @@ void DD_RegisterVFS(void);

void W_InitMultipleFiles(char **filenames);
void W_EndStartup(void);
int W_CheckNumForName(char *name);
int W_GetNumForName(char *name);
int W_CheckNumForName(const char *name);
int W_GetNumForName(const char *name);
size_t W_LumpLength(int lump);
const char *W_LumpName(int lump);
void W_ReadLump(int lump, void *dest);
Expand Down
40 changes: 20 additions & 20 deletions doomsday/engine/portable/include/m_string.h
Expand Up @@ -33,28 +33,28 @@

typedef struct ddstring_s {
char *str;
int length; // String length (no terminating nulls).
int size; // Allocated memory (not necessarily string size).
size_t length; // String length (no terminating nulls).
size_t size; // Allocated memory (not necessarily string size).
} ddstring_t;

void Str_Init(ddstring_t * ds);
void Str_Free(ddstring_t * ds);
void Str_Init(ddstring_t *ds);
void Str_Free(ddstring_t *ds);
ddstring_t *Str_New(void);
void Str_Delete(ddstring_t * ds);
void Str_Clear(ddstring_t * ds);
void Str_Reserve(ddstring_t * ds, int length);
void Str_Set(ddstring_t * ds, const char *text);
void Str_Append(ddstring_t * ds, const char *append_text);
void Str_Appendf(ddstring_t * ds, const char *format, ...);
void Str_PartAppend(ddstring_t * dest, const char *src, int start,
int count);
void Str_Prepend(ddstring_t * ds, const char *prepend_text);
int Str_Length(ddstring_t * ds);
char *Str_Text(ddstring_t * ds);
void Str_Copy(ddstring_t * dest, ddstring_t * src);
void Str_StripLeft(ddstring_t * ds);
void Str_StripRight(ddstring_t * ds);
void Str_Strip(ddstring_t * ds);
const char *Str_GetLine(ddstring_t * ds, const char *src);
void Str_Delete(ddstring_t *ds);
void Str_Clear(ddstring_t *ds);
void Str_Reserve(ddstring_t *ds, size_t length);
void Str_Set(ddstring_t *ds, const char *text);
void Str_Append(ddstring_t *ds, const char *append_text);
void Str_Appendf(ddstring_t *ds, const char *format, ...);
void Str_PartAppend(ddstring_t *dest, const char *src, int start,
size_t count);
void Str_Prepend(ddstring_t *ds, const char *prepend_text);
size_t Str_Length(ddstring_t *ds);
char *Str_Text(ddstring_t *ds);
void Str_Copy(ddstring_t *dest, ddstring_t *src);
void Str_StripLeft(ddstring_t *ds);
void Str_StripRight(ddstring_t *ds);
void Str_Strip(ddstring_t *ds);
const char *Str_GetLine(ddstring_t *ds, const char *src);

#endif
2 changes: 1 addition & 1 deletion doomsday/engine/portable/include/net_buf.h
Expand Up @@ -63,7 +63,7 @@ typedef struct {
#pragma pack()

typedef struct netbuffer_s {
uint player; // Recipient or sender.
int player; // Recipient or sender.
int length; // Number of bytes in the data buffer.
int headerLength; // 1 byte at the moment.

Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/include/net_main.h
Expand Up @@ -173,7 +173,7 @@ typedef struct {

// Client-reported time of the last processed ticcmd.
// Older or as old tics than this are discarded.
byte runTime;
int runTime;

// Bandwidth rating for connection. Determines how much information
// can be sent to the client. Determined dynamically.
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/include/r_data.h
Expand Up @@ -337,10 +337,10 @@ int R_GraphicResourceFlags(resourceclass_t rclass, int id);
flat_t *R_FindFlat(int lumpnum); // May return NULL.
flat_t *R_GetFlat(int lumpnum); // Creates new entries.
flat_t **R_CollectFlats(int *count);
int R_FlatNumForName(char *name);
int R_CheckTextureNumForName(char *name);
int R_TextureNumForName(char *name);
char *R_TextureNameForNum(int num);
int R_FlatNumForName(const char *name);
int R_CheckTextureNumForName(const char *name);
int R_TextureNumForName(const char *name);
const char *R_TextureNameForNum(int num);
int R_SetFlatTranslation(int flat, int translateTo);
int R_SetTextureTranslation(int tex, int translateTo);
boolean R_IsCustomTexture(int texture);
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/include/rend_bias.h
Expand Up @@ -92,15 +92,15 @@ void SB_RendPoly(struct rendpoly_s *poly,
uint mapElementIndex);
void SB_EndFrame(void);

int SB_NewSourceAt(float x, float y, float z, float size, float minLight,
uint SB_NewSourceAt(float x, float y, float z, float size, float minLight,
float maxLight, float *rgb);
void SB_UpdateSource(int which, float x, float y, float z, float size,
void SB_UpdateSource(uint which, float x, float y, float z, float size,
float minLight, float maxLight, float *rgb);
void SB_Delete(int which);
void SB_Delete(uint which);
void SB_Clear(void);

source_t* SB_GetSource(int which);
int SB_ToIndex(source_t* source);
uint SB_ToIndex(source_t* source);

void SB_SetColor(float *dest, float *src);
void HSVtoRGB(float *rgb, float h, float s, float v);
Expand Down
34 changes: 17 additions & 17 deletions doomsday/engine/portable/src/con_bind.c
Expand Up @@ -292,7 +292,7 @@ static binding_t *B_BindingForEvent(ddevent_t *event)
found = false;
while(i < (*num) && !found)
{
if(event->controlID == (*list)[i].controlID)
if((int) event->controlID == (*list)[i].controlID)
found = true;
else
i++;
Expand Down Expand Up @@ -512,7 +512,7 @@ static binding_t *B_GetBinding(uint deviceID, uint controlID,
// to see if there already is one for this event.
for(i = 0, bnd = (*list); i < (*num); ++i, bnd++)
{
if(bnd->controlID == controlID)
if(bnd->controlID == (int) controlID)
return bnd;
}

Expand Down Expand Up @@ -625,7 +625,7 @@ binding_t *B_Bind(ddevent_t *ev, char *command, int control, uint bindClass)

if(com->command[k])
{
if(k == ev->data1)
if((int) k == ev->data1)
{
M_Free(com->command[k]);
com->command[k] = NULL;
Expand Down Expand Up @@ -664,7 +664,7 @@ binding_t *B_Bind(ddevent_t *ev, char *command, int control, uint bindClass)
com = &bnd->binds[bindClass].data.command;
for(i = 0; i < NUM_EVENT_STATES; ++i)
{
if(!ev->isAxis && i != ev->data1)
if(!ev->isAxis && (int) i != ev->data1)
continue;

if(com->command[i])
Expand Down Expand Up @@ -905,7 +905,7 @@ static boolean B_EventBuilder(char *buff, ddevent_t *ev)
ev->deviceID = IDEV_JOY1;
ev->isAxis = false;
ev->data1 = (prefix == '+' ? EVS_DOWN : EVS_UP);
ev->controlID = -1;
ev->controlID = 0;

idx = 0;
found = false;
Expand Down Expand Up @@ -935,8 +935,6 @@ static boolean B_EventBuilder(char *buff, ddevent_t *ev)
ev->controlID = begin[0];
return true;
}

return false;
}

/**
Expand Down Expand Up @@ -1010,8 +1008,8 @@ void formEventString(char *buff, uint deviceID, int controlID,
void B_FormEventString(char *buff, evtype_t type, evstate_t state,
int data1)
{
uint deviceID;
boolean isAxis;
uint deviceID = 0;
boolean isAxis = false;

// These are the same translation rules as used in DD_ProcessEvents()
// except inverted as we are translating from event_t to ddevent_t.
Expand Down Expand Up @@ -2015,7 +2013,7 @@ static uint printBindList(char *searchKey, uint deviceID, int bindClass,
noMatch = false;
if(bindClass >= 0)
{
if(j != bindClass)
if(j != (uint) bindClass)
noMatch = true;
}
if(!noMatch)
Expand Down Expand Up @@ -2050,7 +2048,7 @@ static uint printBindList(char *searchKey, uint deviceID, int bindClass,
noMatch = false;
if(bindClass >= 0)
{
if(j != bindClass)
if(j != (uint) bindClass)
noMatch = true;
}
if(!noMatch)
Expand Down Expand Up @@ -2092,13 +2090,14 @@ static uint printBindList(char *searchKey, uint deviceID, int bindClass,
*/
D_CMD(ListBindings)
{
uint i, g, comcount, bindClass = -1;
uint i, g, comcount, bindClass = 0;
char *searchKey;
uint *num;
binding_t **list;
uint totalBinds;
devcontrolbinds_t *devBinds;
inputdev_t *device;
boolean inClassOnly = false;

// Are we showing bindings in a particular class only?
searchKey = NULL;
Expand All @@ -2107,11 +2106,12 @@ D_CMD(ListBindings)
for(i = 0; i < numBindClasses; ++i)
if(!stricmp(argv[1], bindClasses[i].name))
{
// only show bindings in this class
// only show bindings in this class.
bindClass = bindClasses[i].id;
inClassOnly= true;
}

if(bindClass == -1)
if(!inClassOnly)
searchKey = argv[1];
else
{
Expand All @@ -2135,17 +2135,17 @@ D_CMD(ListBindings)
num = &devBinds->numKeyBinds;
totalBinds += *num;
if(*list)
comcount += printBindList(searchKey, g, bindClass, *list, *num);
comcount += printBindList(searchKey, g, (inClassOnly? bindClass:-1), *list, *num);

// Axis bindings.
list = &devBinds->axisBinds;
num = &devBinds->numAxisBinds;
totalBinds += *num;
if(*list)
comcount += printBindList(searchKey, g, bindClass, *list, *num);
comcount += printBindList(searchKey, g, (inClassOnly? bindClass:-1), *list, *num);
}

if(bindClass != -1)
if(inClassOnly)
{
Con_Printf("Showing %i (%s class) commands from %i bindings.\n",
comcount, bindClasses[bindClass].name, totalBinds);
Expand Down
5 changes: 2 additions & 3 deletions doomsday/engine/portable/src/con_busy.c
Expand Up @@ -416,13 +416,13 @@ static void Con_BusyDrawConsoleOutput(void)
};

cbuffer_t *buffer;
static cbline_t *lines[LINE_COUNT + 1];
static cbline_t *lines[LINE_COUNT + 1], **linesp = lines;
int y;
uint i, linecount;

buffer = Con_GetConsoleBuffer();
linecount = Con_BufferGetLines(buffer, LINE_COUNT, -LINE_COUNT,
&lines[0]);
linesp);

if(!linecount)
return;
Expand Down Expand Up @@ -470,7 +470,6 @@ static void Con_BusyDrawConsoleOutput(void)
*/
static void Con_BusyDrawer(void)
{
DGLuint oldBinding = 0;
// char buf[100];

Con_DrawScreenshotBackground();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/con_data.c
Expand Up @@ -566,7 +566,7 @@ ddccmd_t *Con_GetCommand(cmdargs_t *args)
{
uint i;
boolean found;
ddccmd_t *ccmd;
ddccmd_t *ccmd = NULL;

found = false;
i = 0;
Expand Down
7 changes: 4 additions & 3 deletions doomsday/engine/portable/src/con_main.c
Expand Up @@ -1268,7 +1268,8 @@ boolean Con_Responder(ddevent_t *event)
if(!ConsoleActive)
{
// In this case we are only interested in the activation key.
if(event->data1 == EVS_DOWN && event->controlID == consoleActiveKey)
if(event->data1 == EVS_DOWN &&
(int) event->controlID == consoleActiveKey)
{
Con_Open(true);
return true;
Expand All @@ -1292,7 +1293,7 @@ boolean Con_Responder(ddevent_t *event)
// Check the shutdown key.
if(!conInputLock)
{
if(event->controlID == consoleActiveKey)
if((int) event->controlID == consoleActiveKey)
{
if(shiftDown) // Shift-Tilde to fullscreen and halfscreen.
Rend_ConsoleToggleFullscreen();
Expand Down Expand Up @@ -1795,7 +1796,7 @@ void Con_Error(const char *error, ...)
{
// In busy mode, the other thread will handle this.
Con_BusyWorkerError(buff);
while(true)
for(;;)
{
// We'll stop here.
// TODO: Kill this thread?
Expand Down
12 changes: 6 additions & 6 deletions doomsday/engine/portable/src/dam_main.c
Expand Up @@ -686,9 +686,9 @@ uint P_RegisterCustomMapProperty(int type, valuetype_t dataType, char *name)

static void ParseGLBSPInf(mapdatalumpinfo_t* mapLump)
{
int i, n, keylength = -1;
char* ch;
char line[250];
int i, keylength = -1;
uint n;
char *ch, line[250];

glbuildinfo_t *newInfo = M_Malloc(sizeof(glbuildinfo_t));

Expand Down Expand Up @@ -871,7 +871,7 @@ static boolean P_LocateMapData(char *levelID, int *lumpIndices)
else
{
glNodeData = false;
glNodeFormat = -1;
glNodeFormat = 0;
}

return true;
Expand Down Expand Up @@ -1589,7 +1589,7 @@ static boolean readMapData(gamemap_t *map, int doClass, selectprop_t *props,
}
else
{
uint readNumProps;
uint readNumProps = 0;
uint startIndex;

// KLUDGE: firstGLvertex. We should determine the start index for this
Expand Down Expand Up @@ -2004,7 +2004,7 @@ static selectprop_t* collectProps(int type, boolean builtIn, boolean custom,
uint *count)
{
uint i, idx, tid = type - 1;
uint totalNum = 0, num;
uint totalNum = 0, num = 0;
selectprop_t *props = NULL;

#if _DEBUG
Expand Down

0 comments on commit 6746898

Please sign in to comment.