From eb5499fb1030950558a0a85431627e8792305646 Mon Sep 17 00:00:00 2001 From: Scott Giese Date: Sun, 9 Oct 2022 18:36:37 -0500 Subject: [PATCH] maintenance: eliminated 19 compiler warnings --- simgear/canvas/layout/GridLayout.cxx | 18 +++++++++--------- simgear/emesary/test_emesary.cxx | 10 +++++----- simgear/scene/util/SGProgram.cxx | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/simgear/canvas/layout/GridLayout.cxx b/simgear/canvas/layout/GridLayout.cxx index 28e141a0..a05ff7b6 100644 --- a/simgear/canvas/layout/GridLayout.cxx +++ b/simgear/canvas/layout/GridLayout.cxx @@ -79,13 +79,13 @@ void GridLayout::addItem(const LayoutItemRef& item) if (isValidLocation(item->gridLocation())) { // re-dimension as required const auto itemEnd = item->gridEnd(); - if (itemEnd.x() >= numColumns()) { + if (itemEnd.x() >= static_cast(numColumns())) { // expand columns _dimensions.x() = itemEnd.x() + 1; _columns.resize(_dimensions.x()); } - if (itemEnd.y() >= numRows()) { + if (itemEnd.y() >= static_cast(numRows())) { // expand rows _dimensions.y() = itemEnd.y() + 1; _rows.resize(_dimensions.y()); @@ -149,7 +149,7 @@ SGVec2i GridLayout::innerFindUnusedLocation(const SGVec2i& curLoc) void GridLayout::updateCells() { const auto dim = _dimensions.x() * _dimensions.y(); - if (_cells.size() == dim) { + if (static_cast(_cells.size()) == dim) { return; } @@ -317,7 +317,7 @@ size_t GridLayout::numColumns() const //---------------------------------------------------------------------------- void GridLayout::setRowStretch(size_t index, int stretch) { - if (index >= _dimensions.y()) { + if (static_cast(index) >= _dimensions.y()) { throw sg_range_exception("GridLayout::setRowStretch: invalid row"); } @@ -339,7 +339,7 @@ void GridLayout::setRowStretch(size_t index, int stretch) void GridLayout::setColumnStretch(size_t index, int stretch) { - if (index >= _dimensions.x()) { + if (static_cast(index) >= _dimensions.x()) { throw sg_range_exception("GridLayout::setColumnStretch: invalid column"); } @@ -591,14 +591,14 @@ void GridLayout::doLayout(const SGRecti& geom) SGVec2i totalMinSize = {0, 0}, totalPreferredSize = {0, 0}; - for (auto row = 0; row < _rows.size(); ++row) { + for (auto row = 0; row < static_cast(_rows.size()); ++row) { totalMinSize.y() += _rows.at(row).minSize; totalPreferredSize.y() += _rows.at(row).hintSize; rowStretchTotal += _rows.at(row).calcStretch; availHeight -= _rows.at(row).padding; } - for (auto col = 0; col < _columns.size(); ++col) { + for (auto col = 0; col < static_cast(_columns.size()); ++col) { totalMinSize.x() += _columns.at(col).minSize; totalPreferredSize.x() += _columns.at(col).hintSize; columnStretchTotal += _columns.at(col).calcStretch; @@ -627,7 +627,7 @@ void GridLayout::doLayout(const SGRecti& geom) } // distribute according to stretch factors - for (auto col = 0; col < _columns.size(); ++col) { + for (auto col = 0; col < static_cast(_columns.size()); ++col) { auto& c = _columns[col]; c.calcSize = havePreferredWidth ? c.hintSize : c.minSize; c.calcSize += (toDistribute.x() * c.calcStretch) / columnStretchTotal; @@ -642,7 +642,7 @@ void GridLayout::doLayout(const SGRecti& geom) // re-calcualate row min/preferred now? Or is it not dependant? - for (auto row = 0; row < _rows.size(); ++row) { + for (auto row = 0; row < static_cast(_rows.size()); ++row) { auto& r = _rows[row]; r.calcSize = havePreferredHeight ? r.hintSize : r.minSize; r.calcSize += (toDistribute.y() * r.calcStretch) / rowStretchTotal; diff --git a/simgear/emesary/test_emesary.cxx b/simgear/emesary/test_emesary.cxx index 9bcb81f6..5c2d1680 100644 --- a/simgear/emesary/test_emesary.cxx +++ b/simgear/emesary/test_emesary.cxx @@ -55,7 +55,7 @@ class TestThreadRecipient : public simgear::Emesary::IReceiver simgear::Emesary::ITransmitter* transmitter; public: TestThreadRecipient(simgear::Emesary::ITransmitter* _transmitter, bool addDuringReceive) - : transmitter(_transmitter), addDuringReceive(addDuringReceive), receiveCount(0), ourType("TestThread") + : transmitter(_transmitter), ourType("TestThread"), addDuringReceive(addDuringReceive), receiveCount(0) { r1 = new TestThreadBaseRecipient(); } @@ -89,8 +89,8 @@ public: class EmesaryTestThread : public SGThread { public: - EmesaryTestThread(simgear::Emesary::ITransmitter* transmitter, bool _addDuringReceive) : addDuringReceive(_addDuringReceive), transmitter(transmitter) { - + EmesaryTestThread(simgear::Emesary::ITransmitter* transmitter, bool _addDuringReceive) + : transmitter(transmitter), addDuringReceive(_addDuringReceive) { } protected: simgear::Emesary::ITransmitter* transmitter; @@ -218,7 +218,7 @@ public: virtual simgear::Emesary::ReceiptStatus Receive(simgear::Emesary::INotificationPtr n) { - if (n->GetType() == "Test") + if (std::string{n->GetType()} == std::string{"Test"}) { auto tbn = dynamic_pointer_cast(n); SG_CHECK_EQUAL(receiveCount, tbn->index); @@ -295,7 +295,7 @@ void testEmesaryMultipleRecipients() SG_CHECK_EQUAL(0, r->receiveCount); }); } - SG_CHECK_NE(rcount, globalTransmitter->SentMessageCount()); + SG_CHECK_NE(rcount, static_cast(globalTransmitter->SentMessageCount())); rcount = globalTransmitter->SentMessageCount(); { diff --git a/simgear/scene/util/SGProgram.cxx b/simgear/scene/util/SGProgram.cxx index ddf2fc59..fb5a7eb3 100644 --- a/simgear/scene/util/SGProgram.cxx +++ b/simgear/scene/util/SGProgram.cxx @@ -55,7 +55,7 @@ void SGProgram::apply(osg::State& state) const if (!infoLog.empty()) { // log all the shader source file names, to help in debugging link errors std::ostringstream os; - for (int i = 0; i < getNumShaders(); ++i) { + for (uint i = 0; i < getNumShaders(); ++i) { const auto shader = getShader(i); os << "\t" << shader->getFileName() << "\n"; } @@ -66,7 +66,7 @@ void SGProgram::apply(osg::State& state) const _effectFilePath); } - for (int i = 0; i < getNumShaders(); ++i) { + for (uint i = 0; i < getNumShaders(); ++i) { const auto shader = getShader(i); auto pcs = shader->getPCS(state);