Skip to content

Commit

Permalink
Fix a couple of g++ compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 26, 2020
1 parent 0394d41 commit 4c5aa8e
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 16 deletions.
4 changes: 3 additions & 1 deletion libs/render/Colour4b.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ struct Colour4b
{
unsigned char r, g, b, a;

Colour4b() {}
Colour4b() :
r(0), g(0), b(0), a(0)
{}

Colour4b(unsigned char _r, unsigned char _g,
unsigned char _b, unsigned char _a) :
Expand Down
6 changes: 4 additions & 2 deletions libs/scene/Traverse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class IncludeSelectedWalker :
else
return Node_isSelected(node);
}

bool hasSelectedParent() const {
return m_selected != 0;
}

bool hasSelectedChildren(const scene::INodePtr& node) const {
bool selected = false;
node->foreachNode([&] (const scene::INodePtr& child) -> bool {
Expand All @@ -38,9 +40,9 @@ class IncludeSelectedWalker :
public:
IncludeSelectedWalker(scene::NodeVisitor& walker) :
m_walker(walker),
m_subsetOverride(nullptr),
m_selected(0),
m_skip(false),
m_subsetOverride(nullptr)
m_skip(false)
{}

//stgatilov: override subset of selected nodes
Expand Down
2 changes: 1 addition & 1 deletion libs/wxutil/FileChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void FileChooser::construct()

_dialog->SetWildcard(wildcard);

for (int i = 0; i < _fileFilters.size(); ++i)
for (std::size_t i = 0; i < _fileFilters.size(); ++i)
{
if (_fileFilters[i].isDefaultFilter)
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/dm.conversation/ConversationEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void ConversationEntity::deleteConversation(int index)

int ConversationEntity::moveConversation(int index, bool moveUp)
{
if (moveUp && index <= 1 || !moveUp && index >= getHighestIndex())
if ((moveUp && index <= 1) || (!moveUp && index >= getHighestIndex()))
{
return index; // no change
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/dm.gameconnection/GameConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void GameConnection::think() {
int responseSeqno, lineLen;
int ret = sscanf(_response.data(), "response %d\n%n", &responseSeqno, &lineLen);
assert(ret == 1);
assert(responseSeqno == _seqnoInProgress);
assert(static_cast<std::size_t>(responseSeqno) == _seqnoInProgress);
_response.erase(_response.begin(), _response.begin() + lineLen);
//mark request as "no longer in progress"
//note: response can be used in outer function
Expand Down
2 changes: 1 addition & 1 deletion plugins/dm.gameconnection/MessageTcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bool MessageTcp::readMessage(std::vector<char> &message) {
if (strcmp(magic, "] ") != 0)
goto zomg;

if (remains < len + 12)
if (remains < static_cast<std::size_t>(len) + 12)
return false;

message.reserve(len + 1);
Expand Down
5 changes: 4 additions & 1 deletion radiant/ui/brush/QuerySidesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ void QuerySidesDialog::Show(const cmd::ArgumentList& args)
minSides = static_cast<int>(brush::SPHERE_MIN_SIDES);
maxSides = static_cast<int>(brush::SPHERE_MAX_SIDES);
break;

default:
throw cmd::ExecutionFailure(fmt::format(_("Unknown brush type ID: {0}"), type));
};

auto* dialog = new QuerySidesDialog(minSides, maxSides);
Expand All @@ -116,7 +119,7 @@ void QuerySidesDialog::Show(const cmd::ArgumentList& args)
}
else
{
throw cmd::ExecutionFailure(fmt::format(_("Unknown brush type ID: "), input));
throw cmd::ExecutionFailure(fmt::format(_("Unknown brush type ID: {0}"), input));
}
}

Expand Down
5 changes: 2 additions & 3 deletions radiantcore/imagefile/JPEGLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,9 @@ static void j_putRGBAScanline(unsigned char* jpegline, int widthPix, unsigned ch

//!\todo fix jpeglib, it leaves alpha channel uninitialised
#if 1
* oAlp = 255;
#else
* oAlp = iAlp;
iAlp = 255;
#endif
*oAlp = iAlp;
}
}

Expand Down
2 changes: 2 additions & 0 deletions radiantcore/map/MapPositionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ void MapPositionManager::onMapEvent(IMap::MapEvent ev)
case IMap::MapUnloaded:
clearPositions();
break;
default:
return;
};
}

Expand Down
4 changes: 2 additions & 2 deletions radiantcore/map/mru/MRU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ void MRU::loadMRUMap(const cmd::ArgumentList& args)

int index = args[0].getInt();

if (index < 1 || index > _numMaxFiles)
if (index < 1 || static_cast<std::size_t>(index) > _numMaxFiles)
{
throw cmd::ExecutionFailure(fmt::format(_("Index out of range: {0:d}"), index));
}

// Look up the item with the given index and execute it
foreachItem([=](std::size_t n, const std::string& filename)
{
if (index == n)
if (static_cast<std::size_t>(index) == n)
{
GlobalCommandSystem().executeCommand("OpenMap", filename);
}
Expand Down
6 changes: 3 additions & 3 deletions radiantcore/patch/Patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@ void Patch::constructBevel(const AABB& aabb, EViewType viewType)
aabb.origin + aabb.extents
};

std::size_t dim1, dim2, constDim;
std::size_t dim1 = 0, dim2 = 0, constDim = 0;
assignDimsForViewType(viewType, dim1, dim2, constDim);

std::size_t lowlowhigh[3] = { 0, 0, 2 };
Expand Down Expand Up @@ -2028,7 +2028,7 @@ void Patch::constructEndcap(const AABB& aabb, EViewType viewType)
};

// Define the "row" dimension, e.g. z for an XY-oriented patch
std::size_t dim1, dim2, constDim;
std::size_t dim1 = 0, dim2 = 0, constDim = 0;
assignDimsForViewType(viewType, dim1, dim2, constDim);

setDims(5, 3);
Expand Down Expand Up @@ -2107,7 +2107,7 @@ void Patch::ConstructPrefab(const AABB& aabb, EPatchPrefab eType, EViewType view
// greebo: Determine which dimensions are assigned, depending on the view type

// Define the "row" dimension, e.g. z for an XY-oriented cylinder
std::size_t colDim1, colDim2, rowDim;
std::size_t colDim1 = 0, colDim2 = 0, rowDim = 0;
assignDimsForViewType(viewType, colDim1, colDim2, rowDim);

// As first measure, assign a closed, axis-aligned loop of vertices for each patch row
Expand Down
3 changes: 3 additions & 0 deletions radiantcore/selection/shaderclipboard/ShaderClipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ void ShaderClipboard::onMapEvent(IMap::MapEvent ev)
}
clear();
break;

default:
return;
};
}

Expand Down

0 comments on commit 4c5aa8e

Please sign in to comment.