Some warnings to fix

I’m not sure how to fix these, so here they are:

  • in CDefHandler::getSprite, RowAdd is used undefined (twice).

  • switch is missing a case, so nr may be uninitialized.

map.cpp:349: warning: enumeration value ‘winStandard’ not handled in switch
map.cpp:348: warning: ‘nr’ may be used uninitialized in this function

  • map.cpp:427: warning: enumeration value ‘lossStandard’ not handled in switch

  • hch/CArtHandler.cpp:119: warning: enumeration value ‘ART_SPECIAL’ not handled in switch

Actually it can’t:

	if (victoryCondition.condition != winStandard) //specific victory conditions
	{
		int nr;
		switch (victoryCondition.condition) //read victory conditions

That cases have been intentionally omitted, since we do not need to do anything specific for them or they can’t appear.
However, if you care about that warnings, you may just add empty cases for missing enumerations (eg. case winStandard:break;).

I’ve fixed it, I hope it won’t spoil anything :).

Another one:

CAdvmapInterface.cpp:1635: warning: statement has no effect

indeed:

        {
            terrain.currentPath;
        }   

Removed in r986.

A few more:

Fixed in r1721.

some more :slight_smile:

if (n = getSlotFor(town->basicCreatures*, ARMY_SIZE));
pyramidConfig.combatValue; //how hard are guards of this level
pyramidConfig.value; //overall value of given things
pyramidConfig.rewardDifficulty; //proportion of reward value to difficulty of guards; how profitable is this creature Bank config
pyramidConfig.easiest; //?!?

if (tile = IObjectInterface::cb->getTile(o->pos + offsets*)) //tile is in the map **

Well, this is from an older code. And most of these warnings are harmless (but numerous), so they’re not worth fixing for now.

clang found a few things. The fix seems obvious for each of these, but there might be some unexpected consequences.

[code]
…/hch/CObjectHandler.cpp:2196:62: warning: if statement has empty body -Wempty-body]
if (n = getSlotFor(town->basicCreatures*, ARMY_SIZE));

CGameState.cpp:4274:52: warning: if statement has empty body -Wempty-body]
if (stack->hasBonusOfType(Bonus::NO_WALL_PENALTY));

HeroBonus.cpp:108:45: warning: field is uninitialized when used here -Wuninitialized]
SourceComp(Bonus::BonusSource _src) : src(src)

./SDL_Extensions.h:43:26: warning: comparison of unsigned expression < 0 is always false -Wtautological-compare]
bool negative = (number < 0);

CGameState.cpp:2033:10: warning: comparison of unsigned expression < 0 is always false -Wtautological-compare]
if(sel<0)

[/code]*

Some of these finds are interesting, good job!

Indeed.

First two - semicolon should be removed.
Third (src) -> (_src)
Fourth - that one is not a mistake - makeNumberShort is a template that is used both with signed and unsigned integers (and the latter generate a warning).
Fifth - sel should be signed.