]> git.mxchange.org Git - quix0rs-blobwars.git/commitdiff
Get rid of false positive warnings from cppcheck.
authorGuus Sliepen <guus@debian.org>
Sat, 21 Nov 2015 14:45:57 +0000 (15:45 +0100)
committerGuus Sliepen <guus@debian.org>
Sat, 21 Nov 2015 14:45:57 +0000 (15:45 +0100)
src/CEngine.cpp
src/CPak.cpp
src/loadSave.cpp

index ac9bb8ce37cfbef6aa6badf6f3600818b7723640..d99bb0aaf67190e4a51cf9a108d6f4014ba02925 100644 (file)
@@ -393,14 +393,12 @@ bool Engine::unpack(const char *filename, int fileType)
                        snprintf(tempPath, sizeof tempPath, "%smusic.mod", userHomeDirectory);
                        fp = fopen(tempPath, "wb");
                }
-
-               if (fileType == PAK_TAGS)
+               else if (fileType == PAK_TAGS)
                {
                        snprintf(tempPath, sizeof tempPath, "%smusic.tags", userHomeDirectory);
                        fp = fopen(tempPath, "wb");
                }
-
-               if (fileType == PAK_FONT)
+               else if (fileType == PAK_FONT)
                {
                        snprintf(tempPath, sizeof tempPath, "%sfont.ttf", userHomeDirectory);
                        fp = fopen(tempPath, "wb");
index 7427df3ccc0e664aacdb32fa1299f54c2c6a10a2..6eba5ce90945a05d3bc7407091829f697bc35405 100644 (file)
@@ -63,19 +63,19 @@ void Pak::setPakFile(const char *pakFilename)
 
        if (!pak)
        {
-               showPakErrorAndExit();
+               return showPakErrorAndExit();
        }
 
        fseek(pak, (-sizeof(Uint32)) * 2, SEEK_END);
        if (fread(&listPos, sizeof(Uint32), 1, pak) != 1)
        {
                fclose(pak);
-               showPakErrorAndExit();
+               return showPakErrorAndExit();
        }
        if (fread(&numberOfFiles, sizeof(Uint32), 1, pak) != 1)
        {
                fclose(pak);
-               showPakErrorAndExit();
+               return showPakErrorAndExit();
        }
        
        debug(("Pak : File list resides at %d\n", (int)listPos));
@@ -94,7 +94,7 @@ void Pak::setPakFile(const char *pakFilename)
                if (!result)
                {
                        fclose(pak);
-                       showPakErrorAndExit();
+                       return showPakErrorAndExit();
                }
                
                debug(("Read FileData #%d / %d : %s\n", (i + 1), numberOfFiles, fd[i].filename));
@@ -144,7 +144,7 @@ bool Pak::unpack(const char *filename, unsigned char **buffer)
        if (fread(input, 1, currentFile->cSize, pak) != currentFile->cSize)
        {
                fclose(pak);
-               showPakErrorAndExit();
+               return showPakErrorAndExit(), false;
        }
        
        uLongf fSize = (uLongf)currentFile->fSize;
index a9eb85cd8918d9ac6622b03e5e66f87bea12bf1d..3dfc2e18e8b8426d1dd31ea02bf377d67c87722d 100644 (file)
@@ -107,7 +107,7 @@ bool loadGame(int slot)
        if (fread(&game, sizeof(Game), 1, fp) != 1)
        {
                fclose(fp);
-               graphics.showErrorAndExit("The save data loaded was not in the format expected", "");
+               return graphics.showErrorAndExit("The save data loaded was not in the format expected", ""), false;
        }
        
        fclose(fp);
@@ -125,7 +125,7 @@ bool loadGame(int slot)
        {
                if (!fgets(line, 1024, fp)) {
                        fclose(fp);
-                       graphics.showErrorAndExit("Unexpected end of file reading save data", "");
+                       return graphics.showErrorAndExit("Unexpected end of file reading save data", ""), false;
                }
 
                sscanf(line, "%*c %[^\"] %*c %*c %[^\"] %*c %d %d", string[0], string[1], &param[0], &param[1]);
@@ -356,13 +356,13 @@ void saveGame()
        
        if (!fp)
        {
-               graphics.showErrorAndExit("File write error whilst saving game", "");
+               return graphics.showErrorAndExit("File write error whilst saving game", "");
        }
 
        if (fwrite(&game, sizeof(Game), 1, fp) != 1)
        {
                fclose(fp);
-               graphics.showErrorAndExit("File write error whilst saving game", strerror(errno));
+               return graphics.showErrorAndExit("File write error whilst saving game", strerror(errno));
        }
        
        fclose(fp);
@@ -373,7 +373,7 @@ void saveGame()
        
        if (!fp)
        {
-               graphics.showErrorAndExit("File write error whilst saving game", "");
+               return graphics.showErrorAndExit("File write error whilst saving game", "");
        }
        
        createPersistantMapData();