Skip to content

Commit ce054bf

Browse files
committed
fix misc. errors reported by clang static analyzer
1 parent 9b954c7 commit ce054bf

File tree

10 files changed

+17
-42
lines changed

10 files changed

+17
-42
lines changed

src/client/DownloadManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void DownloadManager::Start()
5959

6060
void DownloadManager::Update()
6161
{
62-
unsigned int numActiveDownloads;
62+
unsigned int numActiveDownloads = 0;
6363
while (!managerShutdown)
6464
{
6565
pthread_mutex_lock(&downloadAddLock);

src/graphics/Graphics.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -734,33 +734,6 @@ int Graphics::CharIndexAtPosition(char *s, int positionX, int positionY)
734734
}
735735

736736

737-
int Graphics::textposxy(char *s, int width, int w, int h)
738-
{
739-
int x=0,y=0,n=0,cw, wordlen, charspace;
740-
while (*s)
741-
{
742-
wordlen = strcspn(s," .,!?\n");
743-
charspace = textwidthx(s, width-x);
744-
if (charspace<wordlen && wordlen && width-x<width/3)
745-
{
746-
x = 0;
747-
y += FONT_H+2;
748-
}
749-
for (; *s && --wordlen>=-1; s++)
750-
{
751-
cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
752-
if ((x+(cw/2) >= w && y+6 >= h)||(y+6 >= h+FONT_H+2))
753-
return n++;
754-
x += cw;
755-
if (x>=width) {
756-
x = 0;
757-
y += FONT_H+2;
758-
}
759-
n++;
760-
}
761-
}
762-
return n;
763-
}
764737
int Graphics::textwrapheight(char *s, int width)
765738
{
766739
int x=0, height=FONT_H+2, cw;

src/graphics/Graphics.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ class Graphics
211211
static int textnwidth(char *s, int n);
212212
static void textnpos(char *s, int n, int w, int *cx, int *cy);
213213
static int textwidthx(char *s, int w);
214-
static int textposxy(char *s, int width, int w, int h);
215214
static int textwrapheight(char *s, int width);
216215
static int textwidth(const char *s);
217216
static void textsize(const char * s, int & width, int & height);

src/graphics/Renderer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void Renderer::RenderBegin()
9595
{
9696
std::copy(persistentVid, persistentVid+(VIDXRES*YRES), vid);
9797
}
98-
pixel * oldVid;
98+
pixel * oldVid = NULL;
9999
if(display_mode & DISPLAY_WARP)
100100
{
101101
oldVid = vid;
@@ -1028,6 +1028,8 @@ void Renderer::render_gravlensing(pixel * source)
10281028
pixel t;
10291029
pixel *src = source;
10301030
pixel *dst = vid;
1031+
if (!dst)
1032+
return;
10311033
for(nx = 0; nx < XRES; nx++)
10321034
{
10331035
for(ny = 0; ny < YRES; ny++)
@@ -2361,7 +2363,7 @@ void Renderer::draw_air()
23612363
float (*hv)[XRES/CELL] = sim->air->hv;
23622364
float (*vx)[XRES/CELL] = sim->air->vx;
23632365
float (*vy)[XRES/CELL] = sim->air->vy;
2364-
pixel c;
2366+
pixel c = 0;
23652367
for (y=0; y<YRES/CELL; y++)
23662368
for (x=0; x<XRES/CELL; x++)
23672369
{

src/gui/colourpicker/ColourPickerActivity.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void ColourPickerActivity::OnMouseMove(int x, int y, int dx, int dy)
140140
if(valueMouseDown)
141141
{
142142
x -= Position.X+5;
143-
y -= Position.Y+5;
143+
//y -= Position.Y+5;
144144

145145
currentValue = x;
146146

@@ -230,7 +230,7 @@ void ColourPickerActivity::OnMouseUp(int x, int y, unsigned button)
230230
valueMouseDown = false;
231231

232232
x -= Position.X+5;
233-
y -= Position.Y+5;
233+
//y -= Position.Y+5;
234234

235235
currentValue = x;
236236

src/gui/game/GameView.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ GameView::GameView():
332332
tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(227, 15), "[no tags set]", "Add simulation tags");
333333
tagSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
334334
tagSimulationButton->SetIcon(IconTag);
335-
currentX+=252;
335+
//currentX+=252;
336336
tagSimulationButton->SetActionCallback(new TagSimulationAction(this));
337337
AddComponent(tagSimulationButton);
338338

@@ -2433,9 +2433,9 @@ void GameView::OnDraw()
24332433
fpsInfo << " [REPLACE MODE]";
24342434
if (c->GetReplaceModeFlags()&SPECIFIC_DELETE)
24352435
fpsInfo << " [SPECIFIC DELETE]";
2436-
if (ren->GetGridSize())
2436+
if (ren && ren->GetGridSize())
24372437
fpsInfo << " [GRID: " << ren->GetGridSize() << "]";
2438-
if (ren->findingElement)
2438+
if (ren && ren->findingElement)
24392439
fpsInfo << " [FIND]";
24402440

24412441
int textWidth = Graphics::textwidth((char*)fpsInfo.str().c_str());

src/gui/search/SearchView.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ void SearchView::NotifyTagListChanged(SearchModel * sender)
466466
int savesY = 4, buttonPadding = 1;
467467
int buttonAreaHeight, buttonYOffset;
468468

469-
int tagWidth, tagHeight, tagX = 0, tagY = 0, tagsX = 6, tagsY = 4, tagPadding = 1;
470-
int tagAreaWidth, tagAreaHeight, tagXOffset, tagYOffset;
469+
int tagWidth = 0, tagHeight = 0, tagX = 0, tagY = 0, tagsX = 6, tagsY = 4, tagPadding = 1;
470+
int tagAreaWidth, tagAreaHeight, tagXOffset = 0, tagYOffset = 0;
471471

472472
vector<pair<string, int> > tags = sender->GetTagList();
473473

src/lua/TPTScriptInterface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words)
272272
throw GeneralException("Invalid property");
273273

274274
//Selector
275-
int newValue;
276-
float newValuef;
275+
int newValue = 0;
276+
float newValuef = 0.0f;
277277
if (value.GetType() == TypeNumber)
278278
{
279279
newValuef = newValue = ((NumberType)value).Value();

src/simulation/elements/PIPE.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
185185
{
186186
rndstore = rand();
187187
rnd = rndstore&7;
188-
rndstore = rndstore>>3;
188+
//rndstore = rndstore>>3;
189189
rx = pos_1_rx[rnd];
190190
ry = pos_1_ry[rnd];
191191
if (BOUNDS_CHECK)

src/simulation/elements/STKM.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
143143
rby = 1.0f;
144144
tmp = 1.0f;
145145
}
146-
tmp = 1.0f/sqrtf(rbx*rbx+rby*rby);
146+
else
147+
tmp = 1.0f/sqrtf(rbx*rbx+rby*rby);
147148
rbx *= tmp;// scale to a unit vector
148149
rby *= tmp;
149150
if (rbLowGrav)

0 commit comments

Comments
 (0)