From a3b11af15a58c02ed7387d25408e6efc0a58b833 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 28 Jan 2009 05:29:41 +0000 Subject: [PATCH] - More GCC warning removal, the most egregious of which was the potential vulnerability "format not a string literal and no format arguments". - Changed the CMake script to search for fmod libraries by full name instead of assuming a symbolic link has been placed for the latest version. It can also find a non-installed copy of FMOD if it is placed local to the ZDoom source tree. SVN r1373 (trunk) --- docs/rh-log.txt | 8 ++++++ src/CMakeLists.txt | 55 ++++++++++++++++++++++++++++++++++----- src/c_cmds.cpp | 4 +-- src/d_main.cpp | 4 +-- src/d_net.cpp | 2 +- src/dobjtype.cpp | 2 +- src/g_game.cpp | 4 +-- src/p_states.cpp | 2 +- src/thingdef/thingdef.cpp | 2 +- src/thingdef/thingdef.h | 2 +- 10 files changed, 67 insertions(+), 18 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 64962fff7..b2a242e9d 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,11 @@ +January 27, 2009 +- More GCC warning removal, the most egregious of which was the security + vulnerability "format not a string literal and no format arguments". +- Changed the CMake script to search for fmod libraries by full name instead + of assuming a symbolic link has been placed for the latest version. It can + also find a non-installed copy of FMOD if it is placed local to the ZDoom + source tree. + January 26, 2009 - Fixed: Some OPL state needs to be restored before calculating rhythm. Also, since only the rhythm section uses the RNG, it doesn't need to be advanced diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 764089027..9e2bfa66a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,6 +16,34 @@ if( CMAKE_SIZEOF_VOID_P MATCHES "8" ) set( X64 64 ) endif( CMAKE_SIZEOF_VOID_P MATCHES "8" ) +# You can either use "make install" on the FMOD distribution to put it +# in standard system locations, or you can unpack the FMOD distribution +# in the root of the zdoom tree. e.g.: +# zdoom +# docs +# fmodapilinux[64] -or simply- fmod +# jpeg-6b +# ... + +# Construct version numbers for searching for the FMOD library on Linux. +set( MINOR_VERSIONS "50" "49" "48" "47" "46" "45" "44" "43" "42" "41" + "40" "39" "38" "37" "36" "35" "34" "33" "32" "31" "30" "29" "28" + "27" "26" "25" "24" "23" "22" "21" "20" "21" "19" "18" "17" "16" + "15" "14" "13" "12" "11" "10" "09" "08" "07" "06" "05" "04" "03" + "02" "01" "00" ) +set( MAJOR_VERSIONS "22" "20" ) +set( FMOD_DIR_VERSIONS ${FMOD_DIR_VERSIONS} "../fmod" ) +foreach( majver ${MAJOR_VERSIONS} ) + foreach( minver ${MINOR_VERSIONS} ) + set( FMOD_VERSIONS ${FMOD_VERSIONS} "fmodex${X64}-4.${majver}.${minver}" ) + set( FMOD_DIR_VERSIONS ${FMOD_DIR_VERSIONS} "${CMAKE_HOME_DIRECTORY}/fmodapi4${majver}${minver}linux${X64}" ) + endforeach( minver ${MINOR_VERSIONS} ) + foreach( dir ${FMOD_DIR_VERSIONS} ) + set( FMOD_LOCAL_INC_DIRS ${FMOD_LOCAL_INC_DIRS} "${dir}/api/inc" ) + set( FMOD_LOCAL_LIB_DIRS ${FMOD_LOCAL_LIB_DIRS} "${dir}/api/lib" ) + endforeach( dir ${FMOD_DIR_VERSIONS} ) +endforeach( majver ${MAJER_VERSIONS} ) + if( WIN32 ) if( X64 ) set( WIN_TYPE Win64 ) @@ -94,7 +122,7 @@ else( WIN32 ) /opt/include ) set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES fmodex ) set( NASM_NAMES nasm ) - + # Non-Windows version also needs SDL find_package( SDL ) if( NOT SDL_FOUND ) @@ -142,9 +170,16 @@ endif( NOT FMOD_LIB_NAME ) # Search for FMOD include files -find_path( FMOD_INCLUDE_DIR fmod.hpp - PATHS ${FMOD_SEARCH_PATHS} - ${FMOD_INC_PATH_SUFFIXES} ) +if( NOT WIN32 ) + find_path( FMOD_INCLUDE_DIR fmod.hpp + PATHS ${FMOD_LOCAL_INC_DIRS} ) +endif( NOT WIN32 ) + +if( NOT FMOD_INCLUDE_DIR ) + find_path( FMOD_INCLUDE_DIR fmod.hpp + PATHS ${FMOD_SEARCH_PATHS} + ${FMOD_INC_PATH_SUFFIXES} ) +endif( NOT FMOD_INCLUDE_DIR ) if( FMOD_INCLUDE_DIR ) message( STATUS "FMOD include files found at ${FMOD_INCLUDE_DIR}" ) @@ -155,9 +190,15 @@ endif( FMOD_INCLUDE_DIR ) # Search for FMOD library -find_library( FMOD_LIBRARY ${FMOD_LIB_NAME} - PATHS ${FMOD_SEARCH_PATHS} - ${FMOD_LIB_PATH_SUFFIXES} ) +if( WIN32 ) + find_library( FMOD_LIBRARY ${FMOD_LIB_NAME} + PATHS ${FMOD_SEARCH_PATHS} + ${FMOD_LIB_PATH_SUFFIXES} ) +else( WIN32 ) + find_library( FMOD_LIBRARY + NAMES ${FMOD_VERSIONS} + PATHS ${FMOD_LOCAL_LIB_DIRS} ) +endif( WIN32 ) if( FMOD_LIBRARY ) message( STATUS "FMOD library found at ${FMOD_LIBRARY}" ) diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index e4197ce2d..48c86104b 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -482,7 +482,7 @@ CCMD (error) if (argv.argc() > 1) { char *textcopy = copystring (argv[1]); - I_Error (textcopy); + I_Error ("%s", textcopy); } else { @@ -495,7 +495,7 @@ CCMD (error_fatal) if (argv.argc() > 1) { char *textcopy = copystring (argv[1]); - I_FatalError (textcopy); + I_FatalError ("%s", textcopy); } else { diff --git a/src/d_main.cpp b/src/d_main.cpp index cb9db695d..f2b825710 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2447,7 +2447,7 @@ void D_DoomMain (void) } if (devparm) { - Printf (GStrings("D_DEVSTR")); + Printf ("%s", GStrings("D_DEVSTR")); } #ifndef unix @@ -2456,7 +2456,7 @@ void D_DoomMain (void) // the user's home directory. if (Args->CheckParm("-cdrom")) { - Printf (GStrings("D_CDROM")); + Printf ("%s", GStrings("D_CDROM")); mkdir (CDROM_DIR, 0); } #endif diff --git a/src/d_net.cpp b/src/d_net.cpp index d480ab61f..9c4363082 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -1997,7 +1997,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) case DEM_PRINT: s = ReadString (stream); - Printf (s); + Printf ("%s", s); break; case DEM_CENTERPRINT: diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index edb32fbbd..481df5137 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -253,7 +253,7 @@ PClass *PClass::CreateDerivedClass (FName name, unsigned int size) const PClass *existclass = FindClass(name); // This is a placeholder so fill it in - if (existclass != NULL && existclass->Size == -1) + if (existclass != NULL && existclass->Size == (unsigned)-1) { type = const_cast(existclass); if (!IsDescendantOf(type->ParentClass)) diff --git a/src/g_game.cpp b/src/g_game.cpp index 7ca1b2420..754f0d6af 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -2506,11 +2506,11 @@ void G_DoPlayDemo (void) demo_p = demobuffer = NULL; if (singledemo) { - I_Error (eek); + I_Error ("%s", eek); } else { - Printf (PRINT_BOLD, eek); + Printf (PRINT_BOLD, "%s", eek); gameaction = ga_nothing; } } diff --git a/src/p_states.cpp b/src/p_states.cpp index 68045b66b..f3a99798f 100644 --- a/src/p_states.cpp +++ b/src/p_states.cpp @@ -928,7 +928,7 @@ void DumpStateHelper(FStateLabels *StateList, const FString &prefix) else { Printf(PRINT_LOG, "%s%s: %s.%d\n", prefix.GetChars(), StateList->Labels[i].Label.GetChars(), - owner->TypeName.GetChars(), StateList->Labels[i].State - owner->ActorInfo->OwnedStates); + owner->TypeName.GetChars(), int(StateList->Labels[i].State - owner->ActorInfo->OwnedStates)); } } if (StateList->Labels[i].Children != NULL) diff --git a/src/thingdef/thingdef.cpp b/src/thingdef/thingdef.cpp index 811bbc036..5510b1c08 100644 --- a/src/thingdef/thingdef.cpp +++ b/src/thingdef/thingdef.cpp @@ -268,7 +268,7 @@ static void FinishThingdef() // Skip non-actors if (!ti->IsDescendantOf(RUNTIME_CLASS(AActor))) continue; - if (ti->Size == -1) + if (ti->Size == (unsigned)-1) { Printf("Class %s referenced but not defined\n", ti->TypeName.GetChars()); errorcount++; diff --git a/src/thingdef/thingdef.h b/src/thingdef/thingdef.h index 14150d30a..611cedc40 100644 --- a/src/thingdef/thingdef.h +++ b/src/thingdef/thingdef.h @@ -124,7 +124,7 @@ public: void Copy(int dest, int src, int cnt); int ResolveAll(); FxExpression *Get(int no); - int Size() { return expressions.Size(); } + unsigned int Size() { return expressions.Size(); } }; extern FStateExpressions StateParams;