From e3e0d513b5ce9d8efa9a16765e1471c6cbba4ddc Mon Sep 17 00:00:00 2001 From: janwas Date: Sun, 17 Dec 2006 00:49:09 +0000 Subject: [PATCH] # minor fixes exposed by ICC 9.0 warnings This was SVN commit r4701. --- source/lib/debug.cpp | 4 +- source/lib/lf_alloc.cpp | 2 +- source/lib/lib.h | 5 ++- source/lib/lib_errors.h | 58 +++++++++++++------------- source/lib/res/file/trace.cpp | 6 +-- source/lib/res/file/vfs_mount.cpp | 6 +-- source/lib/res/graphics/ogl_shader.cpp | 4 +- source/lib/res/graphics/unifont.cpp | 4 +- source/lib/res/sound/snd_mgr.cpp | 10 +++-- source/lib/self_test.cpp | 4 +- source/lib/sysdep/ia32.cpp | 2 - source/lib/sysdep/win/win.cpp | 2 +- source/scripting/ScriptGlue.cpp | 2 +- source/simulation/FormationManager.cpp | 2 +- 14 files changed, 57 insertions(+), 54 deletions(-) diff --git a/source/lib/debug.cpp b/source/lib/debug.cpp index 9b98270b72..33e03fa020 100644 --- a/source/lib/debug.cpp +++ b/source/lib/debug.cpp @@ -738,12 +738,12 @@ static const LibError assert_err = INFO::OK; void debug_skip_next_assert() { - debug_skip_next_err(INFO::OK); + debug_skip_next_err(assert_err); } static bool should_skip_this_assert() { - return should_skip_this_error(INFO::OK); + return should_skip_this_error(assert_err); } diff --git a/source/lib/lf_alloc.cpp b/source/lib/lf_alloc.cpp index aa93caf9ba..d70131f736 100644 --- a/source/lib/lf_alloc.cpp +++ b/source/lib/lf_alloc.cpp @@ -61,7 +61,7 @@ enum State }; -/*/**/typedef void* DescList; +/*typedef void* DescList; struct SizeClass { diff --git a/source/lib/lib.h b/source/lib/lib.h index 4899c3f004..3bf8a5b33a 100644 --- a/source/lib/lib.h +++ b/source/lib/lib.h @@ -510,8 +510,11 @@ extern u16 fp_to_u16(double in); /** * this is strcpy, but indicates that the programmer checked usage and * promises it is safe. + * + * (this macro prevents actually-safe instances of the function from + * showing up in searches) **/ -#define SAFE_STRCPY strcpy +#define SAFE_STRCPY str##cpy /** diff --git a/source/lib/lib_errors.h b/source/lib/lib_errors.h index 50ef4b9f92..f366267e29 100644 --- a/source/lib/lib_errors.h +++ b/source/lib/lib_errors.h @@ -255,23 +255,23 @@ extern void LibError_set_errno(LibError err); #if OS_WIN #define CHECK_ERR(expression)\ STMT(\ - i64 err64 = (i64)(expression);\ - if(err64 < 0)\ + i64 err64__ = (i64)(expression);\ + if(err64__ < 0)\ {\ - LibError err = (LibError)(err64 & UINT_MAX);\ - DEBUG_WARN_ERR(err);\ - return err;\ + LibError err__ = (LibError)(err64__ & UINT_MAX);\ + DEBUG_WARN_ERR(err__);\ + return err__;\ }\ ) #else #define CHECK_ERR(expression)\ STMT(\ - i64 err64 = (i64)(expression);\ - if(err64 < 0)\ + i64 err64__ = (i64)(expression);\ + if(err64__ < 0)\ {\ - LibError err = (LibError)(err64 & UINT_MAX);\ - DEBUG_WARN_ERR(err);\ - return (LibError)(err & UINT_MAX);\ + LibError err__ = (LibError)(err64__ & UINT_MAX);\ + DEBUG_WARN_ERR(err__);\ + return (LibError)(err__ & UINT_MAX);\ }\ ) #endif @@ -280,11 +280,11 @@ STMT(\ // (useful for functions that can legitimately fail, e.g. vfs_exists). #define RETURN_ERR(expression)\ STMT(\ - i64 err64 = (i64)(expression);\ - if(err64 < 0)\ + i64 err64__ = (i64)(expression);\ + if(err64__ < 0)\ {\ - LibError err = (LibError)(err64 & UINT_MAX);\ - return err;\ + LibError err__ = (LibError)(err64__ & UINT_MAX);\ + return err__;\ }\ ) @@ -299,12 +299,12 @@ STMT(\ // throw that number. #define THROW_ERR(expression)\ STMT(\ - i64 err64 = (i64)(expression);\ - if(err64 < 0)\ + i64 err64__ = (i64)(expression);\ + if(err64__ < 0)\ {\ - LibError err = (LibError)(err64 & UINT_MAX);\ - DEBUG_WARN_ERR(err);\ - throw err;\ + LibError err__ = (LibError)(err64__ & UINT_MAX);\ + DEBUG_WARN_ERR(err__);\ + throw err__;\ }\ ) @@ -312,11 +312,11 @@ STMT(\ // (useful for void functions that must bail and complain) #define WARN_ERR_RETURN(expression)\ STMT(\ - i64 err64 = (i64)(expression);\ - if(err64 < 0)\ + i64 err64__ = (i64)(expression);\ + if(err64__ < 0)\ {\ - LibError err = (LibError)(err64 & UINT_MAX);\ - DEBUG_WARN_ERR(err);\ + LibError err__ = (LibError)(err64__ & UINT_MAX);\ + DEBUG_WARN_ERR(err__);\ return;\ }\ ) @@ -325,11 +325,11 @@ STMT(\ // (this is similar to debug_assert but also works in release mode) #define WARN_ERR(expression)\ STMT(\ - i64 err64 = (i64)(expression);\ - if(err64 < 0)\ + i64 err64__ = (i64)(expression);\ + if(err64__ < 0)\ {\ - LibError err = (LibError)(err64 & UINT_MAX);\ - DEBUG_WARN_ERR(err);\ + LibError err__ = (LibError)(err64__ & UINT_MAX);\ + DEBUG_WARN_ERR(err__);\ }\ ) @@ -337,8 +337,8 @@ STMT(\ // if expression evaluates to a negative error code, return 0. #define RETURN0_IF_ERR(expression)\ STMT(\ - i64 err64 = (i64)(expression);\ - if(err64 < 0)\ + i64 err64__ = (i64)(expression);\ + if(err64__ < 0)\ return 0;\ ) diff --git a/source/lib/res/file/trace.cpp b/source/lib/res/file/trace.cpp index aa2dd14a44..940c4ba50d 100644 --- a/source/lib/res/file/trace.cpp +++ b/source/lib/res/file/trace.cpp @@ -293,10 +293,10 @@ LibError trace_read_from_file(const char* trace_filename, Trace* t) for(size_t i = 0; ; i++) { double timestamp; char opcode; char P_path[PATH_MAX]; size_t size; uint flags; - int ret = fscanf(f, fmt, ×tamp, &opcode, P_path, &size, &flags); - if(ret == EOF) + int chars_read = fscanf(f, fmt, ×tamp, &opcode, P_path, &size, &flags); + if(chars_read == EOF) break; - debug_assert(ret == 5); + debug_assert(chars_read == 5); TraceOp op = TO_IO; // default in case file is garbled switch(opcode) diff --git a/source/lib/res/file/vfs_mount.cpp b/source/lib/res/file/vfs_mount.cpp index 965d65b397..a5fbecfa6d 100644 --- a/source/lib/res/file/vfs_mount.cpp +++ b/source/lib/res/file/vfs_mount.cpp @@ -493,7 +493,7 @@ static LibError populate_dir(TDir* td, const char* P_path, const Mount* m, // note: we are only able to add archives found in the root directory, // due to dirent_cb implementation. that's ok - we don't want to check // every single file to see if it's an archive (slow!). -static LibError mount_dir_tree(TDir* td, const Mount& m) +static LibError mount_dir_tree(TDir* td_start, const Mount& m) { LibError err = INFO::OK; @@ -510,7 +510,7 @@ static LibError mount_dir_tree(TDir* td, const Mount& m) // kickoff (less efficient than goto, but c_str reference requires // pop to come at end of loop => this is easiest) - dir_queue.push_back(TDirAndPath(td, m.P_name.c_str())); + dir_queue.push_back(TDirAndPath(td_start, m.P_name.c_str())); do { @@ -531,7 +531,7 @@ static LibError mount_dir_tree(TDir* td, const Mount& m) while(!dir_queue.empty()); // do not pass parchives because that has been set to 0! - mount_archives(td, &archives, &m); + mount_archives(td_start, &archives, &m); return INFO::OK; } diff --git a/source/lib/res/graphics/ogl_shader.cpp b/source/lib/res/graphics/ogl_shader.cpp index 7d8b96d5ee..6fc3ef04b4 100644 --- a/source/lib/res/graphics/ogl_shader.cpp +++ b/source/lib/res/graphics/ogl_shader.cpp @@ -187,7 +187,7 @@ static LibError Ogl_Shader_validate(const Ogl_Shader* UNUSED(shdr)) static LibError Ogl_Shader_to_string(const Ogl_Shader* UNUSED(shdr), char* buf) { - snprintf(buf, H_STRING_LEN, ""); + snprintf(buf, H_STRING_LEN, "-"); return INFO::OK; } @@ -408,7 +408,7 @@ static LibError Ogl_Program_validate(const Ogl_Program* UNUSED(p)) static LibError Ogl_Program_to_string(const Ogl_Program* UNUSED(p), char* buf) { - snprintf(buf, H_STRING_LEN, ""); + snprintf(buf, H_STRING_LEN, "-"); return INFO::OK; } diff --git a/source/lib/res/graphics/unifont.cpp b/source/lib/res/graphics/unifont.cpp index 589320b97d..fb1db304e7 100644 --- a/source/lib/res/graphics/unifont.cpp +++ b/source/lib/res/graphics/unifont.cpp @@ -184,9 +184,9 @@ static LibError UniFont_validate(const UniFont* f) return INFO::OK; } -static LibError UniFont_to_string(const UniFont* UNUSED(f), char* buf) +static LibError UniFont_to_string(const UniFont* f, char* buf) { - snprintf(buf, H_STRING_LEN, ""); + snprintf(buf, H_STRING_LEN, "Font %s", h_filename(f->ht)); return INFO::OK; } diff --git a/source/lib/res/sound/snd_mgr.cpp b/source/lib/res/sound/snd_mgr.cpp index 06c0ad75fe..eb00cdc711 100644 --- a/source/lib/res/sound/snd_mgr.cpp +++ b/source/lib/res/sound/snd_mgr.cpp @@ -64,6 +64,8 @@ // hopefully, OpenAL doesn't rely on them actually being unloaded. #if OS_WIN # define WIN_LOADLIBRARY_HACK 0 +#else +# define WIN_LOADLIBRARY_HACK 0 #endif @@ -1890,15 +1892,15 @@ static LibError vsrc_update(VSrc * vs) if(!vs->al_src) return INFO::OK; - FadeRet ret = fade(vs->fade, snd_update_time, vs->gain); + FadeRet fade_ret = fade(vs->fade, snd_update_time, vs->gain); // auto-free after fadeout. - if(ret == FADE_TO_0_FINISHED) + if(fade_ret == FADE_TO_0_FINISHED) { vsrc_free(vs); return INFO::OK; // don't continue - has been freed. } // fade in progress; latch current gain value. - else if(ret == FADE_CHANGED) + else if(fade_ret == FADE_CHANGED) vsrc_latch(vs); int num_queued; @@ -2390,7 +2392,7 @@ static bool snd_disabled = false; * * @return LibError from al_init, or ERR::AGAIN if sound disabled */ -static inline LibError snd_init() +static LibError snd_init() { // (note: each VSrc_reload and therefore snd_open will fail) if(snd_disabled) diff --git a/source/lib/self_test.cpp b/source/lib/self_test.cpp index c1150fb430..ad88a92d6d 100644 --- a/source/lib/self_test.cpp +++ b/source/lib/self_test.cpp @@ -24,7 +24,7 @@ #include "timer.h" -/*/* +#if 0 // checked by debug_assert_failed; disables asserts if true (see above). // set/cleared by self_test_run. @@ -71,4 +71,4 @@ void self_test_run_all() debug_printf("-- done (elapsed time %.0f ms)\n", dt*1e3); } -*/ +#endif diff --git a/source/lib/sysdep/ia32.cpp b/source/lib/sysdep/ia32.cpp index 1ae0288790..2b6087693d 100644 --- a/source/lib/sysdep/ia32.cpp +++ b/source/lib/sysdep/ia32.cpp @@ -343,8 +343,6 @@ static void get_cpu_type() // note: cpu_type is guaranteed to hold 48+1 chars, since that's the // length of the CPU brand string => we can safely copy short literals. - // (this macro hides us from 'unsafe string code' searches) -#define SAFE_STRCPY str##cpy // fall back to manual detect of CPU type because either: // - CPU doesn't support brand string (we use a flag to indicate this diff --git a/source/lib/sysdep/win/win.cpp b/source/lib/sysdep/win/win.cpp index 23a5972cbe..75fd3584c0 100644 --- a/source/lib/sysdep/win/win.cpp +++ b/source/lib/sysdep/win/win.cpp @@ -52,7 +52,7 @@ static LibError LibError_from_GLE(bool warn_if_failed = true) case ERROR_INSUFFICIENT_BUFFER: err = ERR::BUF_SIZE; break; -/*/* +/* case ERROR_ACCESS_DENIED: err = ERR::FILE_ACCESS; break; case ERROR_FILE_NOT_FOUND: diff --git a/source/scripting/ScriptGlue.cpp b/source/scripting/ScriptGlue.cpp index caa156b69d..5c2310d448 100644 --- a/source/scripting/ScriptGlue.cpp +++ b/source/scripting/ScriptGlue.cpp @@ -1311,7 +1311,7 @@ JSBool revealMap( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsva { newValue = 2; } - else if(!ToPrimitive( g_ScriptingHost.GetContext(), argv[0], newValue ) || newValue > 2 || newValue < 0) + else if(!ToPrimitive( g_ScriptingHost.GetContext(), argv[0], newValue ) || newValue > 2) { JS_ReportError( cx, "Invalid argument (should be 0, 1 or 2)" ); *rval = JSVAL_VOID; diff --git a/source/simulation/FormationManager.cpp b/source/simulation/FormationManager.cpp index 43e0087d51..017b8efbe0 100644 --- a/source/simulation/FormationManager.cpp +++ b/source/simulation/FormationManager.cpp @@ -46,7 +46,7 @@ void CFormationManager::CreateFormation( CEntityList& entities, CStrW& name ) } void CFormationManager::DestroyFormation( size_t form ) { - if ( form < 0 || form >= m_formations.size()) + if ( form >= m_formations.size()) { debug_warn("CFormationManager::DestroyFormation--invalid entity"); return;