Skip to content

Commit

Permalink
Static analyzer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Dec 31, 2018
1 parent a8e789c commit 99f2980
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
6 changes: 3 additions & 3 deletions CIO/CFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include <iostream>
#include <stdexcept>

//-V:fseek:303
//-V:ftell:303

FILE* CFile::fp = NULL;
bobBMP* CFile::bmpArray = NULL;
bobSHADOW* CFile::shadowArray = NULL;
Expand Down Expand Up @@ -536,9 +539,6 @@ bobMAP* CFile::open_wld()
{
bobMAP* myMap = new bobMAP();

if(myMap == NULL)
return myMap;

// initialize myMap->name and myMap->author (both 20 chars) to prevent filling with random memory content
for(int i = 0; i < 20; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion CIO/CSelectBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void CSelectBox::setMouseData(SDL_MouseButtonEvent button)
break;
}
j--;
if(Entries[j] != NULL && Entries[j]->getY() > h_ - 10)
if(j >= 0 && Entries[j] != NULL && Entries[j]->getY() > h_ - 10)
{
for(int i = 0; i < MAXSELECTBOXENTRIES; i++)
{
Expand Down
6 changes: 2 additions & 4 deletions CMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,6 @@ void CMap::destructMap()
bobMAP* CMap::generateMap(int width, int height, int type, int texture, int border, int border_texture)
{
bobMAP* myMap = new bobMAP();
if(!myMap)
return NULL;

strcpy(myMap->name, "Ohne Namen");
myMap->width = width;
Expand Down Expand Up @@ -1376,7 +1374,7 @@ void CMap::drawMinimap(SDL_Surface* Window)
if(y % num_y != 0)
continue;

row = (Uint32*)Window->pixels + (y + 20) * Window->pitch / 4;
row = (Uint32*)Window->pixels + (y + 20) * Window->pitch / 4; //-V206
for(int x = 0; x < map->width; x++)
{
if(x % num_x != 0)
Expand Down Expand Up @@ -1471,7 +1469,7 @@ void CMap::drawMinimap(SDL_Surface* Window)
break;
}

row = (Uint32*)Window->pixels + (y / num_y + 20) * Window->pitch / 4;
row = (Uint32*)Window->pixels + (y / num_y + 20) * Window->pitch / 4; //-V206
//+6 because of the left window frame
pixel = row + x / num_x + 6;

Expand Down
14 changes: 7 additions & 7 deletions CSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void CSurface::DrawPixel_Color(SDL_Surface* screen, int x, int y, Uint32 color)
{
Uint32* bufp;

bufp = (Uint32*)screen->pixels + y * screen->pitch / 4 + x;
bufp = (Uint32*)screen->pixels + y * screen->pitch / 4 + x; //-V206
*bufp = color;
}
break;
Expand Down Expand Up @@ -221,7 +221,7 @@ void CSurface::DrawPixel_RGB(SDL_Surface* screen, int x, int y, Uint8 R, Uint8 G
{
Uint32* bufp;

bufp = (Uint32*)screen->pixels + y * screen->pitch / 4 + x;
bufp = (Uint32*)screen->pixels + y * screen->pitch / 4 + x; //-V206
*bufp = color;
}
break;
Expand Down Expand Up @@ -281,7 +281,7 @@ void CSurface::DrawPixel_RGBA(SDL_Surface* screen, int x, int y, Uint8 R, Uint8
{
Uint32* bufp;

bufp = (Uint32*)screen->pixels + y * screen->pitch / 4 + x;
bufp = (Uint32*)screen->pixels + y * screen->pitch / 4 + x; //-V206
*bufp = color;
}
break;
Expand All @@ -308,7 +308,8 @@ Uint32 CSurface::GetPixel(SDL_Surface* surface, int x, int y)
else
return p[0] | p[1] << 8 | p[2] << 16;

case 4: return *(Uint32*)p;
case 4:
return *(Uint32*)p; //-V206

default:
return 0; /* shouldn't happen, but avoids warnings */
Expand Down Expand Up @@ -431,9 +432,8 @@ void CSurface::DrawTriangleField(SDL_Surface* display, const DisplayRectangle& d
DrawTriangle(display, displayRect, myMap, type, myMap.getVertex(x, y), myMap.getVertex(x - 1, y + 1),
myMap.getVertex(x, y + 1));
// UpSideDown
if(x < width)
DrawTriangle(display, displayRect, myMap, type, myMap.getVertex(x - 1, y + 1), myMap.getVertex(x - 1, y),
myMap.getVertex(x, y));
DrawTriangle(display, displayRect, myMap, type, myMap.getVertex(x - 1, y + 1), myMap.getVertex(x - 1, y),
myMap.getVertex(x, y));
}
// last UpSideDown
tempP3 = myMap.getVertex(0, y);
Expand Down

0 comments on commit 99f2980

Please sign in to comment.