From 2fed23c6ec8f32aef7e5c55ad6d56e5632e78afd Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 9 Dec 2012 16:53:21 +0100 Subject: [PATCH] Fix warnings from GCC, Clang and cppcheck. --- code/graphics.cpp | 2 +- code/messages.cpp | 6 +++--- code/missions.cpp | 4 ++-- code/resources.cpp | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/code/graphics.cpp b/code/graphics.cpp index 8e79677..9872d1b 100644 --- a/code/graphics.cpp +++ b/code/graphics.cpp @@ -498,7 +498,7 @@ void circle(int xc, int yc, int R, SDL_Surface *PIX, int col) void blevelRect(SDL_Surface *dest, int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue) { - SDL_Rect r = {x, y, w, h}; + SDL_Rect r = {(int16_t)x, (int16_t)y, (uint16_t)w, (uint16_t)h}; SDL_FillRect(dest, &r, SDL_MapRGB(screen->format, red, green, blue)); drawLine(dest, x, y, x + w, y, SDL_MapRGB(screen->format, 255, 255, 255)); diff --git a/code/messages.cpp b/code/messages.cpp index 725ad81..96d1b2a 100644 --- a/code/messages.cpp +++ b/code/messages.cpp @@ -98,7 +98,7 @@ void getKillMessage(object *ally) case 3: case 4: case 5: - sprintf(in, killMessage[rand() % 6]); + strcpy(in, killMessage[rand() % 6]); break; case 6: @@ -120,11 +120,11 @@ void getKillMessage(object *ally) case 9: if (firstPlace) { - sprintf(in, killMessage[9]); + strcpy(in, killMessage[9]); } else { - sprintf(in, killMessage[rand() % 6]); + strcpy(in, killMessage[rand() % 6]); } break; } diff --git a/code/missions.cpp b/code/missions.cpp index b0ef198..cea9dc1 100644 --- a/code/missions.cpp +++ b/code/missions.cpp @@ -672,7 +672,7 @@ bool missionFailed() static void drawBriefScreen() { - SDL_Rect r = {0, 0, screen->w, 2}; + SDL_Rect r = {0, 0, (uint16_t)screen->w, 2}; for (int i = 0 ; i < (int)(screen->h / 4) - 30 ; i++) { @@ -845,7 +845,7 @@ void missionFinishedScreen() { if (currentMission.secondaryType[i] != NONE) { - sprintf(temp, currentMission.secondaryObjective[i]); + strcpy(temp, currentMission.secondaryObjective[i]); if (currentMission.completed2[i] >= 1) { drawString("COMPLETED", 550, 274 + (i * 30), FONT_GREEN); diff --git a/code/resources.cpp b/code/resources.cpp index 63578ac..d1aa7ef 100644 --- a/code/resources.cpp +++ b/code/resources.cpp @@ -62,7 +62,8 @@ void loadGameGraphics() #if USEPACK int dataLocation = locateDataInPak(string, 1); fp = fopen(PACKLOCATION, "rb"); - fseek(fp, dataLocation, SEEK_SET); + if(fp) + fseek(fp, dataLocation, SEEK_SET); #else fp = fopen(string, "rb"); #endif