Skip to content

Commit

Permalink
Fixed a bunch of compilation warnings output by gcc.
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jan 26, 2011
1 parent e0618c4 commit 0d2e986
Show file tree
Hide file tree
Showing 18 changed files with 128 additions and 74 deletions.
6 changes: 3 additions & 3 deletions doomsday/engine/portable/include/filedirectory.h
Expand Up @@ -102,11 +102,11 @@ ddstring_t* FileDirectory_AllPaths(filedirectory_t* pd, filedirectory_pathtype_t
* @param callback Callback function ptr.
* @param paramaters Passed to the callback.
*/
void FileDirectory_AddPaths3(filedirectory_t* pd, const dduri_t** paths, uint pathsCount,
void FileDirectory_AddPaths3(filedirectory_t* pd, const dduri_t* const* paths, uint pathsCount,
int (*callback) (const struct filedirectory_node_s* node, void* paramaters), void* paramaters);
void FileDirectory_AddPaths2(filedirectory_t* pd, const dduri_t** paths, uint pathsCount,
void FileDirectory_AddPaths2(filedirectory_t* pd, const dduri_t* const* paths, uint pathsCount,
int (*callback) (const struct filedirectory_node_s* node, void* paramaters));
void FileDirectory_AddPaths(filedirectory_t* pd, const dduri_t** paths, uint pathsCount);
void FileDirectory_AddPaths(filedirectory_t* pd, const dduri_t* const* paths, uint pathsCount);

/**
* Add a new set of paths from a path list. Duplicates are automatically pruned.
Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/portable/include/m_args.h
@@ -1,10 +1,10 @@
/**\file
/**\file m_args.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2010 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2009-2010 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2009-2011 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/include/resourcenamespace.h
Expand Up @@ -92,19 +92,19 @@ resourcenamespace_t* ResourceNamespace_Construct(const char* name,
resourcenamespace_t* ResourceNamespace_Construct2(const char* name,
ddstring_t* (*composeHashNameFunc) (const ddstring_t* path),
resourcenamespace_namehash_key_t (*hashNameFunc) (const ddstring_t* name),
const dduri_t** searchPaths, uint searchPathsCount);
const dduri_t* const* searchPaths, uint searchPathsCount);
resourcenamespace_t* ResourceNamespace_Construct3(const char* name,
ddstring_t* (*composeHashNameFunc) (const ddstring_t* path),
resourcenamespace_namehash_key_t (*hashNameFunc) (const ddstring_t* name),
const dduri_t** searchPaths, uint searchPathsCount, byte flags);
const dduri_t* const* searchPaths, uint searchPathsCount, byte flags);
resourcenamespace_t* ResourceNamespace_Construct4(const char* name,
ddstring_t* (*composeHashNameFunc) (const ddstring_t* path),
resourcenamespace_namehash_key_t (*hashNameFunc) (const ddstring_t* name),
const dduri_t** searchPaths, uint searchPathsCount, byte flags, const char* overrideName);
const dduri_t* const* searchPaths, uint searchPathsCount, byte flags, const char* overrideName);
resourcenamespace_t* ResourceNamespace_Construct5(const char* name,
ddstring_t* (*composeHashNameFunc) (const ddstring_t* path),
resourcenamespace_namehash_key_t (*hashNameFunc) (const ddstring_t* name),
const dduri_t** searchPaths, uint searchPathsCount, byte flags, const char* overrideName,
const dduri_t* const* searchPaths, uint searchPathsCount, byte flags, const char* overrideName,
const char* overrideName2);

void ResourceNamespace_Destruct(resourcenamespace_t* rn);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/include/resourcerecord.h
Expand Up @@ -96,8 +96,8 @@ resourceclass_t ResourceRecord_ResourceClass(resourcerecord_t* rec);
int ResourceRecord_ResourceFlags(resourcerecord_t* rec);

/// @return Array of IdentityKey(s) associated with subrecords of this resource.
const ddstring_t** ResourceRecord_IdentityKeys(resourcerecord_t* rec);
const ddstring_t* const* ResourceRecord_IdentityKeys(resourcerecord_t* rec);

const dduri_t** ResourceRecord_SearchPaths(resourcerecord_t* rec);
const dduri_t* const* ResourceRecord_SearchPaths(resourcerecord_t* rec);

#endif /* LIBDENG_RESOURCERECORD_H */
14 changes: 8 additions & 6 deletions doomsday/engine/portable/include/sys_file.h
@@ -1,10 +1,10 @@
/**\file
/**\file sys_file.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2010 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2009-2010 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2009-2011 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -94,8 +94,10 @@ void F_ShutdownDirec(void);
* matching the filespec. Absolute path names are given to the callback.
* Zip directory, DD_DIREC and the real files are scanned.
*/
typedef int (*f_allresourcepaths_callback_t) (const ddstring_t* path, filedirectory_pathtype_t type, void* paramaters);
int F_AllResourcePaths2(const ddstring_t* searchPath, f_allresourcepaths_callback_t callback, void* paramaters);
int F_AllResourcePaths(const ddstring_t* searchPath, f_allresourcepaths_callback_t callback);
int F_AllResourcePaths2(const ddstring_t* searchPath,
int (*callback) (const ddstring_t* path, filedirectory_pathtype_t type, void* paramaters),
void* paramaters);
int F_AllResourcePaths(const ddstring_t* searchPath,
int (*callback) (const ddstring_t* path, filedirectory_pathtype_t type, void* paramaters));

#endif /* LIBDENG_FILESYS_FILE_IO_H */
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/con_data.c
Expand Up @@ -462,7 +462,7 @@ void Con_SetFloat2(const char* name, float value, int svflags)
break;
default:
Con_Message("Warning:Con_SetFloat: Attempt to set incompatible cvar "
"%s to %i, ignoring.\n", name, value);
"%s to %g, ignoring.\n", name, value);
return;
}

Expand Down
49 changes: 35 additions & 14 deletions doomsday/engine/portable/src/filedirectory.c
Expand Up @@ -218,14 +218,35 @@ static int iteratePaths(filedirectory_t* fd, filedirectory_pathtype_t type,
}
}

static filedirectory_t* addPaths(filedirectory_t* fd, const ddstring_t** paths,
static int const_iteratePaths(filedirectory_t* fd, filedirectory_pathtype_t type,
filedirectory_node_t* parent, int (*callback) (const filedirectory_node_t* node, void* paramaters),
void* paramaters)
{
assert(fd && callback);
{
int result = 0;
filedirectory_node_t* node;
for(node = fd->_head; node; node = node->next)
{
if(parent && node->parent != parent)
continue;
if(VALID_FILEDIRECTORY_PATHTYPE(type) && node->type != type)
continue;
if((result = callback(node, paramaters)) != 0)
break;
}
return result;
}
}

static filedirectory_t* addPaths(filedirectory_t* fd, const ddstring_t* const* paths,
size_t pathsCount, int (*callback) (const filedirectory_node_t* node, void* paramaters),
void* paramaters)
{
assert(fd && paths && pathsCount != 0);
{
// uint startTime = verbose >= 2? Sys_GetRealTime(): 0;
const ddstring_t** ptr = paths;
const ddstring_t* const* ptr = paths;
{ size_t i;
for(i = 0; i < pathsCount && *ptr; ++i, ptr++)
{
Expand All @@ -244,7 +265,7 @@ static filedirectory_t* addPaths(filedirectory_t* fd, const ddstring_t** paths,
{
if(leaf->type == FDT_DIRECTORY)
{
iteratePaths(fd, FDT_FILE, leaf, callback, paramaters);
const_iteratePaths(fd, FDT_FILE, leaf, callback, paramaters);
}
else
{
Expand Down Expand Up @@ -308,7 +329,7 @@ static void addPathToSearchPaths(filedirectory_t* fd, const dduri_t* path)
fd->_searchPaths[fd->_searchPathsCount-1] = Uri_ConstructCopy(path);
}

static void addPathsToSearchPaths(filedirectory_t* fd, const dduri_t** paths, uint pathsCount)
static void addPathsToSearchPaths(filedirectory_t* fd, const dduri_t* const* paths, uint pathsCount)
{
assert(fd && paths && pathsCount != 0);
{ uint i;
Expand Down Expand Up @@ -343,11 +364,11 @@ static void resolveAndAddSearchPathsToDirectory(filedirectory_t* fd,
fd->_builtRecordSet = true;
}

static void printPaths(const dduri_t** paths, size_t pathsCount)
static void printPaths(const dduri_t* const* paths, size_t pathsCount)
{
assert(paths);
{
const dduri_t** ptr = paths;
const dduri_t* const* ptr = paths;
size_t i;
for(i = 0; i < pathsCount && *ptr; ++i, ptr++)
{
Expand Down Expand Up @@ -377,9 +398,9 @@ filedirectory_t* FileDirectory_ConstructStr2(const ddstring_t* pathList, char de
fd->_builtRecordSet = false;
if(pathList)
{
uint count;
size_t count;
dduri_t** uris = F_CreateUriListStr2(RC_NULL, pathList, &count);
addPathsToSearchPaths(fd, uris, count);
addPathsToSearchPaths(fd, uris, (uint)count);
resolveAndAddSearchPathsToDirectory(fd, 0, 0);
F_DestroyUriList(uris);
}
Expand Down Expand Up @@ -454,7 +475,7 @@ void FileDirectory_Clear(filedirectory_t* fd)
fd->_builtRecordSet = false;
}

void FileDirectory_AddPaths3(filedirectory_t* fd, const dduri_t** paths, uint pathsCount,
void FileDirectory_AddPaths3(filedirectory_t* fd, const dduri_t* const* paths, uint pathsCount,
int (*callback) (const filedirectory_node_t* node, void* paramaters), void* paramaters)
{
assert(fd);
Expand All @@ -472,13 +493,13 @@ void FileDirectory_AddPaths3(filedirectory_t* fd, const dduri_t** paths, uint pa
resolveAndAddSearchPathsToDirectory(fd, callback, paramaters);
}

void FileDirectory_AddPaths2(filedirectory_t* fd, const dduri_t** paths, uint pathsCount,
void FileDirectory_AddPaths2(filedirectory_t* fd, const dduri_t* const* paths, uint pathsCount,
int (*callback) (const filedirectory_node_t* node, void* paramaters))
{
FileDirectory_AddPaths3(fd, paths, pathsCount, callback, 0);
}

void FileDirectory_AddPaths(filedirectory_t* fd, const dduri_t** paths, uint pathsCount)
void FileDirectory_AddPaths(filedirectory_t* fd, const dduri_t* const* paths, uint pathsCount)
{
FileDirectory_AddPaths2(fd, paths, pathsCount, 0);
}
Expand All @@ -489,10 +510,10 @@ void FileDirectory_AddPathList3(filedirectory_t* fd, const char* pathList,
assert(fd);
{
dduri_t** paths = 0;
uint pathsCount = 0;
size_t pathsCount = 0;
if(pathList && pathList[0])
paths = F_CreateUriList2(RC_UNKNOWN, pathList, &pathsCount);
FileDirectory_AddPaths3(fd, paths, pathsCount, callback, paramaters);
FileDirectory_AddPaths3(fd, paths, (uint)pathsCount, callback, paramaters);
if(paths)
F_DestroyUriList(paths);
}
Expand All @@ -519,7 +540,7 @@ int FileDirectory_Iterate2(filedirectory_t* fd, filedirectory_pathtype_t type,
{
resolveAndAddSearchPathsToDirectory(fd, 0, 0);
}
return iteratePaths(fd, type, parent, callback, paramaters);
return const_iteratePaths(fd, type, parent, callback, paramaters);
}

int FileDirectory_Iterate(filedirectory_t* fd, filedirectory_pathtype_t type,
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/src/finaleinterpreter.c
@@ -1,10 +1,10 @@
/**\file
/**\file finaleinterpreter.c
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2010 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2010 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2011 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1998,7 +1998,7 @@ DEFFC(PlayDemo)

DEFFC(Command)
{
Con_Executef(CMDS_SCRIPT, false, OP_CSTRING(0));
Con_Executef(CMDS_SCRIPT, false, "%s", OP_CSTRING(0));
}

DEFFC(ShowMenu)
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/src/m_args.c
@@ -1,10 +1,10 @@
/**\file
/**\file m_args.c
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2010 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2010 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2011 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -289,7 +289,7 @@ const char* Argv(int i)
/**
* @return Pointer to the i'th argument's pointer.
*/
const char* const * ArgvPtr(int i)
const char* const* ArgvPtr(int i)
{
if(i < 0 || i >= numArgs)
Con_Error("ArgvPtr: There is no arg %i.\n", i);
Expand Down
7 changes: 4 additions & 3 deletions doomsday/engine/portable/src/m_string.c
Expand Up @@ -135,7 +135,7 @@ void Str_Set(ddstring_t* str, const char* text)
{
#if _DEBUG
Con_Message("Warning: Resultant string would be longer than String::MAX_LENGTH "
"(%ul), truncating.\n", (unsigned long) DDSTRING_MAX_LENGTH);
"(%lu), truncating.\n", (unsigned long) DDSTRING_MAX_LENGTH);
#endif
incoming = DDSTRING_MAX_LENGTH;
}
Expand All @@ -161,7 +161,7 @@ void Str_Append(ddstring_t* str, const char* append)
{
#if _DEBUG
Con_Message("Warning: Resultant string would be longer than String::MAX_LENGTH "
"(%ul), truncating.\n", (unsigned long) DDSTRING_MAX_LENGTH);
"(%lu), truncating.\n", (unsigned long) DDSTRING_MAX_LENGTH);
#endif
incoming = DDSTRING_MAX_LENGTH - str->length;
if(incoming == 0)
Expand Down Expand Up @@ -243,7 +243,8 @@ void Str_Prepend(ddstring_t* str, const char* prepend)
if((unsigned)str->length + incoming > DDSTRING_MAX_LENGTH)
{
#if _DEBUG
Con_Message("Resultant string would be longer than String::MAX_LENGTH (%ul).\n", (unsigned long) DDSTRING_MAX_LENGTH);
Con_Message("Resultant string would be longer than String::MAX_LENGTH (%lu).\n",
(unsigned long) DDSTRING_MAX_LENGTH);
#endif
return;
}
Expand Down
10 changes: 7 additions & 3 deletions doomsday/engine/portable/src/p_materialmanager.c
Expand Up @@ -706,8 +706,12 @@ material_t* Materials_NewFromDef(ded_material_t* def)
if(l->stages[0].type != -1) // Not unused.
{
if(!(tex = GL_GetGLTextureByName(l->stages[0].name, l->stages[0].type)))
{
ddstring_t* path = Uri_ComposePath(def->id);
VERBOSE( Con_Message("Warning: Unknown %s '%s' in Material '%s' (layer %i stage %i).\n",
GLTEXTURE_TYPE_STRING(l->stages[0].type), l->stages[0].name, def->id, 0, 0) );
GLTEXTURE_TYPE_STRING(l->stages[0].type), l->stages[0].name, Str_Text(path), 0, 0) );
Str_Delete(path);
}
}
}

Expand Down Expand Up @@ -874,7 +878,7 @@ static materialnum_t Materials_NumForPath2(const dduri_t* path)
if(verbose && result == 0 && !ddMapSetup) // Don't announce during map setup.
{
ddstring_t* nicePath = Uri_ToString(path);
Con_Message("Materials_NumForName: \"%s\" in namespace %i not found!\n", Str_Text(nicePath));
Con_Message("Materials::NumForName: \"%s\" not found!\n", Str_Text(nicePath));
Str_Delete(nicePath);
}
return result;
Expand Down Expand Up @@ -1407,7 +1411,7 @@ static size_t printMaterials2(materialnamespaceid_t mnamespace, const char* like
{ const materialbind_t** ptr;
for(ptr = foundMaterials; *ptr; ++ptr)
{
printMaterialInfo(*ptr, mnamespace == MN_ANY);
printMaterialInfo(*ptr, (mnamespace == MN_ANY));
}}

free(foundMaterials);
Expand Down
25 changes: 23 additions & 2 deletions doomsday/engine/portable/src/pathdirectory.c
@@ -1,4 +1,4 @@
/**\file
/**\file pathdirectory.c
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
Expand Down Expand Up @@ -192,6 +192,27 @@ static int iteratePaths(pathdirectory_t* pd, pathdirectory_pathtype_t type,
}
}

static int const_iteratePaths(pathdirectory_t* pd, pathdirectory_pathtype_t type,
pathdirectory_node_t* parent, int (*callback) (const pathdirectory_node_t* node, void* paramaters),
void* paramaters)
{
assert(pd && callback);
{
int result = 0;
pathdirectory_node_t* node;
for(node = pd->_head; node; node = node->next)
{
if(parent && node->parent != parent)
continue;
if(VALID_PATHDIRECTORY_PATHTYPE(type) && node->type != type)
continue;
if((result = callback(node, paramaters)) != 0)
break;
}
return result;
}
}

pathdirectory_t* PathDirectory_ConstructDefault(void)
{
pathdirectory_t* pd;
Expand Down Expand Up @@ -266,7 +287,7 @@ int PathDirectory_Iterate2(pathdirectory_t* pd, pathdirectory_pathtype_t type,
void* paramaters)
{
assert(pd && (type == PT_ANY || VALID_PATHDIRECTORY_PATHTYPE(type)));
return iteratePaths(pd, type, parent, callback, paramaters);
return const_iteratePaths(pd, type, parent, callback, paramaters);
}

int PathDirectory_Iterate(pathdirectory_t* pd, pathdirectory_pathtype_t type,
Expand Down

0 comments on commit 0d2e986

Please sign in to comment.