From 64910221e7ae84347f54b1daedecbe9a4cbfbac1 Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Thu, 16 Oct 2008 14:22:29 +0000 Subject: [PATCH] Fix several warnings that occur on NDEBUG builds: * Missing returns from function * Functions that are defined in both DEBUG and NDEBUG builds but only used in DEBUG builds git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6179 4a71c877-e1ca-e34f-864e-861f7616d084 --- lib/framework/utf.c | 13 ++++++++----- lib/script/event.c | 36 ++++++++++++++++++------------------ lib/sound/audio.c | 3 +++ src/fpath.c | 3 +++ src/structure.c | 3 +++ 5 files changed, 35 insertions(+), 23 deletions(-) diff --git a/lib/framework/utf.c b/lib/framework/utf.c index ac5249d38..9d664ac95 100644 --- a/lib/framework/utf.c +++ b/lib/framework/utf.c @@ -151,11 +151,14 @@ static size_t unicode_utf8_char_length(const utf_32_char unicode_char) */ else if (unicode_char < 0x00110000) return 4; // stores 21 bits - else - /* Apparently this character lies outside the 0x0 - 0x10FFFF - * Unicode range, so don't accept it. - */ - ASSERT(!"out-of-range Unicode codepoint", "This Unicode codepoint is too large (%u > 0x10FFFF) to be a valid Unicode codepoint", (unsigned int)unicode_char); + + /* Apparently this character lies outside the 0x0 - 0x10FFFF + * Unicode range, so don't accept it. + */ + ASSERT(!"out-of-range Unicode codepoint", "This Unicode codepoint is too large (%u > 0x10FFFF) to be a valid Unicode codepoint", (unsigned int)unicode_char); + + // Dummy value to prevent warnings about missing return from function + return 0; } char *UTF8CharacterAtOffset(const char *utf8_string, size_t index) diff --git a/lib/script/event.c b/lib/script/event.c index f2873d383..e5b2ebb22 100644 --- a/lib/script/event.c +++ b/lib/script/event.c @@ -57,6 +57,24 @@ static SDWORD eventTraceLevel=3; #define DB_TRIGINF(psTrigger, level)\ if (eventTraceLevel >= (level)) \ eventPrintTriggerInfo(psTrigger) + +// Print out all the info available about a trigger +static void eventPrintTriggerInfo(ACTIVE_TRIGGER *psTrigger) +{ + SCRIPT_CODE *psCode = psTrigger->psContext->psCode; + const char *pTrigLab, *pEventLab; + + // find the debug info for the trigger + pTrigLab = eventGetTriggerID(psCode, psTrigger->trigger); + // find the debug info for the event + pEventLab = eventGetEventID(psCode, psTrigger->event); + + debug(LOG_WARNING, "trigger %s at %d -> %s", pTrigLab, psTrigger->testTime, pEventLab); + if (psTrigger->offset != 0) + { + debug(LOG_WARNING, " %d", psTrigger->offset); + } +} #else #define DB_TRIGINF(psTrigger, level) #endif @@ -266,24 +284,6 @@ const char *eventGetEventID(SCRIPT_CODE *psCode, SDWORD event) return pID; } -// Print out all the info available about a trigger -static void eventPrintTriggerInfo(ACTIVE_TRIGGER *psTrigger) -{ - SCRIPT_CODE *psCode = psTrigger->psContext->psCode; - const char *pTrigLab, *pEventLab; - - // find the debug info for the trigger - pTrigLab = eventGetTriggerID(psCode, psTrigger->trigger); - // find the debug info for the event - pEventLab = eventGetEventID(psCode, psTrigger->event); - - debug(LOG_WARNING, "trigger %s at %d -> %s", pTrigLab, psTrigger->testTime, pEventLab); - if (psTrigger->offset != 0) - { - debug(LOG_WARNING, " %d", psTrigger->offset); - } -} - // Initialise the create/release function array - specify the maximum value type BOOL eventInitValueFuncs(SDWORD maxType) { diff --git a/lib/sound/audio.c b/lib/sound/audio.c index f871b940d..83ddbf676 100644 --- a/lib/sound/audio.c +++ b/lib/sound/audio.c @@ -1128,6 +1128,9 @@ void audioTest() for (i = 0; i < 50; i++) { + // On non-debug builds prevent warnings about defining but not using dummyCB + (void)dummyCB; + assert(audio_Shutdown()); assert(audio_Init(dummyCB)); assert(!audio_Disabled()); diff --git a/src/fpath.c b/src/fpath.c index 0937f9e46..50186cbe5 100644 --- a/src/fpath.c +++ b/src/fpath.c @@ -607,6 +607,9 @@ void fpathTest(int x, int y, int x2, int y2) FPATH_RETVAL r; int i; + // On non-debug builds prevent warnings about defining but not using fpathJobQueueLength + (void)fpathJobQueueLength; + /* Check initial state */ assert(fpathThread != NULL); assert(fpathSemaphore != NULL); diff --git a/src/structure.c b/src/structure.c index 031c90f37..3db561673 100644 --- a/src/structure.c +++ b/src/structure.c @@ -386,6 +386,9 @@ static STRUCTURE_TYPE structureType(const char* typeName) } ASSERT(!"unknown structure type", "Unknown Structure Type (%s)", typeName); + + // Dummy value to prevent warnings about missing return from function + return 0; }