Skip to content

Commit

Permalink
Clang: Fixed bunch of questionable/faulty code
Browse files Browse the repository at this point in the history
Clang's warnings are quite superior to gcc in informativeness.
Some of these are real bugs (e.g., materialvariant.c).
  • Loading branch information
skyjake committed Jul 12, 2012
1 parent 22ad794 commit c36b2bf
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
4 changes: 4 additions & 0 deletions doomsday/config_unix_any.pri
Expand Up @@ -11,6 +11,10 @@ QMAKE_CFLAGS_WARN_ON -= -Wall
QMAKE_CFLAGS_WARN_ON -= -W
QMAKE_CFLAGS_WARN_ON += -Werror-implicit-function-declaration -fdiagnostics-show-option

*-clang* {
QMAKE_CFLAGS_WARN_ON += -Wno-tautological-compare
}

# Print include directories and other info.
#QMAKE_CFLAGS += -Wp,-v

Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/gl_texmanager.c
Expand Up @@ -3107,8 +3107,8 @@ static void performImageAnalyses(Texture* tex, const image_t* image,

// Average alpha?
if(spec->type == TST_GENERAL &&
(TS_GENERAL(spec)->context == TC_SPRITE_DIFFUSE) ||
(TS_GENERAL(spec)->context == TC_UI))
(TS_GENERAL(spec)->context == TC_SPRITE_DIFFUSE ||
TS_GENERAL(spec)->context == TC_UI))
{
averagealpha_analysis_t* aa = (averagealpha_analysis_t*) Texture_Analysis(tex, TA_ALPHA);
boolean firstInit = (!aa);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/materialvariant.c
Expand Up @@ -240,7 +240,7 @@ int MaterialVariant_SnapshotPrepareFrame(const materialvariant_t* mat)
void MaterialVariant_SetSnapshotPrepareFrame(materialvariant_t* mat, int frame)
{
assert(mat);
mat->_snapshotPrepareFrame;
mat->_snapshotPrepareFrame = frame;
}

materialvariant_t* MaterialVariant_TranslationNext(materialvariant_t* mat)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/p_maputil.c
Expand Up @@ -480,7 +480,7 @@ int GameMap_LineMobjsIterator(GameMap* map, LineDef* lineDef,
int result = false;
assert(map);

root = map->lineLinks[GameMap_LineDefIndex(map, lineDef)], nix;
root = map->lineLinks[GameMap_LineDefIndex(map, lineDef)];
ln = map->lineNodes.nodes;

for(nix = ln[root].next; nix != root; nix = ln[nix].next)
Expand Down
12 changes: 8 additions & 4 deletions doomsday/engine/portable/src/point.c
Expand Up @@ -149,7 +149,7 @@ void Point2_Sum(Point2* p, const Point2* other)
boolean Point2_Equality(const Point2* p, const Point2* other)
{
assert(p && other);
return p == other || p->raw.x == Point2_X(other) && p->raw.y == Point2_Y(other);
return p == other || (p->raw.x == Point2_X(other) && p->raw.y == Point2_Y(other));
}

Point2f* Point2f_New(void)
Expand Down Expand Up @@ -265,7 +265,7 @@ void Point2f_Sum(Point2f* p, const Point2f* other)
boolean Point2f_Equality(const Point2f* p, const Point2f* other)
{
assert(p && other);
return p == other || p->raw.x == Point2f_X(other) && p->raw.y == Point2f_Y(other);
return p == other || (p->raw.x == Point2f_X(other) && p->raw.y == Point2f_Y(other));
}

struct point3_s {
Expand Down Expand Up @@ -404,7 +404,9 @@ void Point3_Sum(Point3* p, const Point3* other)
boolean Point3_Equality(const Point3* p, const Point3* other)
{
assert(p && other);
return p == other || p->raw.x == Point3_X(other) && p->raw.y == Point3_Y(other) && p->raw.z == Point3_Z(other);
return p == other || (p->raw.x == Point3_X(other) &&
p->raw.y == Point3_Y(other) &&
p->raw.z == Point3_Z(other));
}

Point3f* Point3f_New(void)
Expand Down Expand Up @@ -533,5 +535,7 @@ void Point3f_Sum(Point3f* p, const Point3f* other)
boolean Point3f_Equality(const Point3f* p, const Point3f* other)
{
assert(p && other);
return p == other || p->raw.x == Point3f_X(other) && p->raw.y == Point3f_Y(other) && p->raw.z == Point3f_Z(other);
return p == other || (p->raw.x == Point3f_X(other) &&
p->raw.y == Point3f_Y(other) &&
p->raw.z == Point3f_Z(other));
}
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/r_lgrid.c
Expand Up @@ -599,7 +599,7 @@ static void LG_ApplySector(gridblock_t *block, const float *color, float level,
void LG_SectorChanged(Sector* sector)
{
if(!lgInited) return;
if(!sector || 0 == sector->changedBlockCount && 0 == sector->blockCount) return;
if(!sector || (!sector->changedBlockCount && !sector->blockCount)) return;

// Mark changed blocks and contributors.
{ uint i;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/sys_reslocator.c
Expand Up @@ -338,7 +338,7 @@ static boolean findResourceInNamespace(resourcenamespaceinfo_t* rnInfo, const dd
p.foundNode = NULL;

// Perform the search.
if(found = ResourceNamespace_Iterate2(rnInfo->rnamespace, name, findResourceInNamespaceWorker, (void*)&p))
if((found = ResourceNamespace_Iterate2(rnInfo->rnamespace, name, findResourceInNamespaceWorker, (void*)&p)))
{
// Does the caller want to know the matched path?
if(foundPath)
Expand Down

0 comments on commit c36b2bf

Please sign in to comment.