From f54e82e4880767f6e71c83840bff1ae8e0feda3d Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 2 Oct 2009 14:42:24 +0000 Subject: Fix more cppcheck warnings/errors; some code formatting; and fixes to our tools svn-id: r44539 --- backends/platform/dc/selector.cpp | 2 +- tools/create_kyradat/create_kyradat.cpp | 2 -- tools/create_kyradat/games.cpp | 2 +- tools/create_kyradat/search.h | 2 -- tools/create_kyradat/util.h | 7 ++++--- tools/create_lure/create_lure_dat.cpp | 4 ++-- tools/create_lure/process_actions.cpp | 28 ++++++++++------------------ tools/md5table.c | 3 ++- 8 files changed, 20 insertions(+), 30 deletions(-) diff --git a/backends/platform/dc/selector.cpp b/backends/platform/dc/selector.cpp index e2998234c3..0d8e0a0188 100644 --- a/backends/platform/dc/selector.cpp +++ b/backends/platform/dc/selector.cpp @@ -451,7 +451,7 @@ bool selectGame(char *&ret, char *&dir_ret, Common::Language &lang_ret, Common:: if (selected >= 0) the_game = games[selected]; - delete games; + delete[] games; if (selected>=0) { #if 0 diff --git a/tools/create_kyradat/create_kyradat.cpp b/tools/create_kyradat/create_kyradat.cpp index 5bcdaa4228..1dff394d43 100644 --- a/tools/create_kyradat/create_kyradat.cpp +++ b/tools/create_kyradat/create_kyradat.cpp @@ -1063,8 +1063,6 @@ bool process(PAKFile &out, const Game *g, const byte *data, const uint32 size) { bool setupSearch(const int *needList, Search &search, DataIdList &dataIdList) { for (const int *entry = needList; *entry != -1; ++entry) { - bool found = false; - ExtractEntryList providers = getProvidersForId(*entry); if (providers.empty()) { diff --git a/tools/create_kyradat/games.cpp b/tools/create_kyradat/games.cpp index ebea422557..a3413abd55 100644 --- a/tools/create_kyradat/games.cpp +++ b/tools/create_kyradat/games.cpp @@ -880,7 +880,7 @@ const GameNeed gameNeedTable[] = { { kLol, kPlatformPC, kTalkieFile1, lolCDFile1Need }, { kLol, kPlatformPC, kTalkieFile2, lolCDFile2Need }, - { -1, -1, 0 } + { -1, -1, -1, 0 } }; } // end of anonymous namespace diff --git a/tools/create_kyradat/search.h b/tools/create_kyradat/search.h index 8ec8c7017e..e5cd65b297 100644 --- a/tools/create_kyradat/search.h +++ b/tools/create_kyradat/search.h @@ -65,8 +65,6 @@ private: typedef std::map SumMap; SumMap _sums; - typedef std::map SumCount; - SumCount _sumCount; }; class Search { diff --git a/tools/create_kyradat/util.h b/tools/create_kyradat/util.h index 0b5e729a05..7c044ae04f 100644 --- a/tools/create_kyradat/util.h +++ b/tools/create_kyradat/util.h @@ -53,9 +53,10 @@ typedef signed short int16; typedef signed int int32; #if !defined(__cplusplus) -typedef uint8 bool; -#define false 0 -#define true 1 +enum bool { + false = 0, + true = 1 +}; /* If your C compiler doesn't support 'inline', please add a check for it. */ #if defined(_MSC_VER) diff --git a/tools/create_lure/create_lure_dat.cpp b/tools/create_lure/create_lure_dat.cpp index 9377506c9b..f1d4e39011 100644 --- a/tools/create_lure/create_lure_dat.cpp +++ b/tools/create_lure/create_lure_dat.cpp @@ -778,7 +778,7 @@ void read_anim_data(byte *&data, uint16 &totalSize) { uint16 startOffset; int ctr, dirCtr; int movementSize = 0; - bool *includeAnim = (bool *) malloc(animIndex); + bool *includeAnim = (bool *)malloc(animIndex); // Loop to figure out the total number of movement records there are for (ctr = 0; ctr < animIndex; ++ctr) { @@ -886,7 +886,7 @@ void read_anim_data(byte *&data, uint16 &totalSize) { } rec->animRecordId = TO_LE_16(0xffff); - delete includeAnim; + free(includeAnim); } void read_script_data(byte *&data, uint16 &totalSize) { diff --git a/tools/create_lure/process_actions.cpp b/tools/create_lure/process_actions.cpp index 7ea45d8681..9779315ddd 100644 --- a/tools/create_lure/process_actions.cpp +++ b/tools/create_lure/process_actions.cpp @@ -344,8 +344,7 @@ struct RoomRandomActionSet { RoomRandomActionEntry *entries; }; -void read_action_sequence(byte *&data, uint16 &totalSize) -{ +void read_action_sequence(byte *&data, uint16 &totalSize) { uint16 hotspotIndex; HotspotHeaderEntry entryHeader; CurrentActionInput action; @@ -381,8 +380,7 @@ void read_action_sequence(byte *&data, uint16 &totalSize) } // Next get the set of offsetes for the start of each sequence - for (roomIndex = 0; roomIndex < RANDOM_ROOM_NUM_ENTRIES; ++roomIndex) - { + for (roomIndex = 0; roomIndex < RANDOM_ROOM_NUM_ENTRIES; ++roomIndex) { if (randomActions[roomIndex].offset == 0) continue; @@ -393,8 +391,7 @@ void read_action_sequence(byte *&data, uint16 &totalSize) // Loop through the entries uint16 offset = randomActions[roomIndex].offset + 1; - for (uint8 entryCtr = 0; entryCtr < randomActions[roomIndex].numEntries; ++entryCtr) - { + for (uint8 entryCtr = 0; entryCtr < randomActions[roomIndex].numEntries; ++entryCtr) { randomActions[roomIndex].entries[entryCtr].repeatable = lureExe.readWord() == 1; offset += 2; @@ -485,12 +482,9 @@ void read_action_sequence(byte *&data, uint16 &totalSize) // Finally process each of the random room actions - for (roomIndex = 0; roomIndex < RANDOM_ROOM_NUM_ENTRIES; ++roomIndex) - { - for (index = 0; index < randomActions[roomIndex].numEntries; ++index) - { - if (randomActions[roomIndex].entries[index].offset != 0xfffe) - { + for (roomIndex = 0; roomIndex < RANDOM_ROOM_NUM_ENTRIES; ++roomIndex) { + for (index = 0; index < randomActions[roomIndex].numEntries; ++index) { + if (randomActions[roomIndex].entries[index].offset != 0xfffe) { //printf("room=%d entry=%xh\n", roomIndex+1, randomActions[roomIndex].entries[index].offset); process_entry(randomActions[roomIndex].entries[index].offset, data, totalSize); } @@ -509,8 +503,7 @@ void read_action_sequence(byte *&data, uint16 &totalSize) // Output the data for the random room actions - for (roomIndex = 0; roomIndex < RANDOM_ROOM_NUM_ENTRIES; ++roomIndex) - { + for (roomIndex = 0; roomIndex < RANDOM_ROOM_NUM_ENTRIES; ++roomIndex) { if (randomActions[roomIndex].numEntries == 0) continue; @@ -540,10 +533,9 @@ void read_action_sequence(byte *&data, uint16 &totalSize) *pHeader++ = TO_LE_16(0xffff); // Free up the random room action array - for (roomIndex = 0; roomIndex < 1; ++roomIndex) - { + for (roomIndex = 0; roomIndex < 1; ++roomIndex) { if (randomActions[roomIndex].entries != NULL) - delete randomActions[roomIndex].entries; + delete[] randomActions[roomIndex].entries; } - delete randomActions; + delete[] randomActions; } diff --git a/tools/md5table.c b/tools/md5table.c index f4aacb8e31..37510ebf89 100644 --- a/tools/md5table.c +++ b/tools/md5table.c @@ -214,7 +214,7 @@ int main(int argc, char *argv[]) int err; int i; time_t theTime; - const char *generationDate; + char *generationDate; const int entrySize = 256; int numEntries = 0, maxEntries = 1; @@ -368,6 +368,7 @@ int main(int argc, char *argv[]) } free(entriesBuffer); + free(generationDate); return 0; } -- cgit v1.2.3