Skip to content

Commit 11a96e4

Browse files
committedMay 17, 2015
Add -Wsign-compare for Clang builds and fix some signed/unsigned compiler warnings
1 parent fb36c47 commit 11a96e4

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed
 

‎src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ else()
590590
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
591591
# clang does not understand __extern_always_inline but libc headers use it
592592
set(OTHER_FLAGS "${OTHER_FLAGS} \"-D__extern_always_inline=extern __always_inline\"")
593+
set(OTHER_FLAGS "${OTHER_FLAGS} -Wsign-compare")
593594
endif()
594595

595596
if(MINGW)

‎src/content_cao.cpp

+20-20
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ class TestCAO : public ClientActiveObject
142142
public:
143143
TestCAO(IGameDef *gamedef, ClientEnvironment *env);
144144
virtual ~TestCAO();
145-
145+
146146
ActiveObjectType getType() const
147147
{
148148
return ACTIVEOBJECT_TYPE_TEST;
149149
}
150-
150+
151151
static ClientActiveObject* create(IGameDef *gamedef, ClientEnvironment *env);
152152

153153
void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
@@ -192,9 +192,9 @@ void TestCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
192192
{
193193
if(m_node != NULL)
194194
return;
195-
195+
196196
//video::IVideoDriver* driver = smgr->getVideoDriver();
197-
197+
198198
scene::SMesh *mesh = new scene::SMesh();
199199
scene::IMeshBuffer *buf = new scene::SMeshBuffer();
200200
video::SColor c(255,255,255,255);
@@ -286,12 +286,12 @@ class ItemCAO : public ClientActiveObject
286286
public:
287287
ItemCAO(IGameDef *gamedef, ClientEnvironment *env);
288288
virtual ~ItemCAO();
289-
289+
290290
ActiveObjectType getType() const
291291
{
292292
return ACTIVEOBJECT_TYPE_ITEM;
293293
}
294-
294+
295295
static ClientActiveObject* create(IGameDef *gamedef, ClientEnvironment *env);
296296

297297
void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
@@ -308,12 +308,12 @@ class ItemCAO : public ClientActiveObject
308308
void processMessage(const std::string &data);
309309

310310
void initialize(const std::string &data);
311-
311+
312312
core::aabbox3d<f32>* getSelectionBox()
313313
{return &m_selection_box;}
314314
v3f getPosition()
315315
{return m_position;}
316-
316+
317317
std::string infoText()
318318
{return m_infotext;}
319319

@@ -357,9 +357,9 @@ void ItemCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
357357
{
358358
if(m_node != NULL)
359359
return;
360-
360+
361361
//video::IVideoDriver* driver = smgr->getVideoDriver();
362-
362+
363363
scene::SMesh *mesh = new scene::SMesh();
364364
scene::IMeshBuffer *buf = new scene::SMeshBuffer();
365365
video::SColor c(255,255,255,255);
@@ -469,7 +469,7 @@ void ItemCAO::updateTexture()
469469
<<": error deSerializing itemstring \""
470470
<<m_itemstring<<std::endl;
471471
}
472-
472+
473473
// Set meshbuffer texture
474474
m_node->getMaterial(0).setTexture(0, texture);
475475
}
@@ -514,7 +514,7 @@ void ItemCAO::processMessage(const std::string &data)
514514
void ItemCAO::initialize(const std::string &data)
515515
{
516516
infostream<<"ItemCAO: Got init data"<<std::endl;
517-
517+
518518
{
519519
std::istringstream is(data, std::ios::binary);
520520
// version
@@ -527,7 +527,7 @@ void ItemCAO::initialize(const std::string &data)
527527
// itemstring
528528
m_itemstring = deSerializeString(is);
529529
}
530-
530+
531531
updateNodePos();
532532
updateInfoText();
533533
}
@@ -748,7 +748,7 @@ ClientActiveObject* GenericCAO::getParent()
748748
void GenericCAO::removeFromScene(bool permanent)
749749
{
750750
// Should be true when removing the object permanently and false when refreshing (eg: updating visuals)
751-
if((m_env != NULL) && (permanent))
751+
if((m_env != NULL) && (permanent))
752752
{
753753
for(std::vector<u16>::iterator ci = m_children.begin();
754754
ci != m_children.end(); ci++)
@@ -759,7 +759,7 @@ void GenericCAO::removeFromScene(bool permanent)
759759
}
760760

761761
m_env->m_attachements[getId()] = 0;
762-
762+
763763
LocalPlayer* player = m_env->getLocalPlayer();
764764
if (this == player->parent) {
765765
player->parent = NULL;
@@ -898,7 +898,7 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
898898
m_meshnode = smgr->addMeshSceneNode(mesh, NULL);
899899
m_meshnode->grab();
900900
mesh->drop();
901-
901+
902902
m_meshnode->setScale(v3f(m_prop.visual_size.X,
903903
m_prop.visual_size.Y,
904904
m_prop.visual_size.X));
@@ -1014,7 +1014,7 @@ void GenericCAO::updateNodePos()
10141014
}
10151015
}
10161016
}
1017-
1017+
10181018
void GenericCAO::step(float dtime, ClientEnvironment *env)
10191019
{
10201020
// Handel model of local player instantly to prevent lags
@@ -1485,7 +1485,7 @@ void GenericCAO::updateBonePosition()
14851485
}
14861486
}
14871487
}
1488-
1488+
14891489
void GenericCAO::updateAttachments()
14901490
{
14911491

@@ -1716,14 +1716,14 @@ void GenericCAO::processMessage(const std::string &data)
17161716
m_armor_groups[name] = rating;
17171717
}
17181718
} else if (cmd == GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES) {
1719-
u8 version = readU8(is); // forward compatibility
1719+
//u8 version = readU8(is); // forward compatibility
17201720
m_nametag_color = readARGB8(is);
17211721
if (m_textnode != NULL) {
17221722
m_textnode->setTextColor(m_nametag_color);
17231723
}
17241724
}
17251725
}
1726-
1726+
17271727
/* \pre punchitem != NULL
17281728
*/
17291729
bool GenericCAO::directReportPunch(v3f dir, const ItemStack *punchitem,

‎src/noise.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,8 @@ void Noise::gradientMap2D(
590590
int seed)
591591
{
592592
float v00, v01, v10, v11, u, v, orig_u;
593-
int index, i, j, x0, y0, noisex, noisey;
594-
int nlx, nly;
593+
u32 index, i, j, x0, y0, noisex, noisey;
594+
u32 nlx, nly;
595595

596596
bool eased = np.flags & (NOISE_FLAG_DEFAULTS | NOISE_FLAG_EASED);
597597
Interp2dFxn interpolate = eased ?
@@ -604,8 +604,8 @@ void Noise::gradientMap2D(
604604
orig_u = u;
605605

606606
//calculate noise point lattice
607-
nlx = (int)(u + sx * step_x) + 2;
608-
nly = (int)(v + sy * step_y) + 2;
607+
nlx = (u32)(u + sx * step_x) + 2;
608+
nly = (u32)(v + sy * step_y) + 2;
609609
index = 0;
610610
for (j = 0; j != nly; j++)
611611
for (i = 0; i != nlx; i++)
@@ -655,8 +655,8 @@ void Noise::gradientMap3D(
655655
float v000, v010, v100, v110;
656656
float v001, v011, v101, v111;
657657
float u, v, w, orig_u, orig_v;
658-
int index, i, j, k, x0, y0, z0, noisex, noisey, noisez;
659-
int nlx, nly, nlz;
658+
u32 index, i, j, k, x0, y0, z0, noisex, noisey, noisez;
659+
u32 nlx, nly, nlz;
660660

661661
Interp3dFxn interpolate = (np.flags & NOISE_FLAG_EASED) ?
662662
triLinearInterpolation : triLinearInterpolationNoEase;
@@ -671,9 +671,9 @@ void Noise::gradientMap3D(
671671
orig_v = v;
672672

673673
//calculate noise point lattice
674-
nlx = (int)(u + sx * step_x) + 2;
675-
nly = (int)(v + sy * step_y) + 2;
676-
nlz = (int)(w + sz * step_z) + 2;
674+
nlx = (u32)(u + sx * step_x) + 2;
675+
nly = (u32)(v + sy * step_y) + 2;
676+
nlz = (u32)(w + sz * step_z) + 2;
677677
index = 0;
678678
for (k = 0; k != nlz; k++)
679679
for (j = 0; j != nly; j++)

‎src/unittest/test_schematic.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void TestSchematic::testMtsSerializeDeserialize(INodeDefManager *ndef)
9999
UASSERT(schem2.size == size);
100100
for (size_t i = 0; i != volume; i++)
101101
UASSERT(schem2.schemdata[i] == schem.schemdata[i]);
102-
for (size_t y = 0; y != size.Y; y++)
102+
for (s16 y = 0; y != size.Y; y++)
103103
UASSERTEQ(u8, schem2.slice_probs[y], schem.slice_probs[y]);
104104
}
105105

0 commit comments

Comments
 (0)
Please sign in to comment.