From b80548a46e89b28f7d5f3352b6ae45607dd0ccda Mon Sep 17 00:00:00 2001 From: KroArtem Date: Thu, 30 Jan 2014 03:19:41 +0400 Subject: [PATCH] fix some coverity issues --- src/guiengine/widgets/ribbon_widget.cpp | 1 - src/karts/controller/skidding_ai.cpp | 2 +- src/karts/kart_model.hpp | 14 +++++++------- src/network/protocols/get_public_address.cpp | 2 +- src/network/protocols/start_game_protocol.cpp | 2 +- src/tracks/quad_set.cpp | 5 +++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/guiengine/widgets/ribbon_widget.cpp b/src/guiengine/widgets/ribbon_widget.cpp index 8f6c25861..a3dbb0d24 100644 --- a/src/guiengine/widgets/ribbon_widget.cpp +++ b/src/guiengine/widgets/ribbon_widget.cpp @@ -730,7 +730,6 @@ void RibbonWidget::setLabel(const unsigned int id, irr::core::stringw new_name) // ignore this call for ribbons without labels if (m_labels.size() == 0) return; - assert(id >= 0); assert(id < m_labels.size()); m_labels[id].setText( new_name.c_str() ); m_text = new_name; diff --git a/src/karts/controller/skidding_ai.cpp b/src/karts/controller/skidding_ai.cpp index 68cca8ff6..fcb1521ad 100644 --- a/src/karts/controller/skidding_ai.cpp +++ b/src/karts/controller/skidding_ai.cpp @@ -1060,7 +1060,7 @@ void SkiddingAI::evaluateItems(const Item *item, float kart_aim_angle, // fall through: if we have enough space to store a big // container, we can also store a small container, and // finally fall through to the bonus box code. - case Item::ITEM_NITRO_SMALL: avoid = false; break; + case Item::ITEM_NITRO_SMALL: avoid = false; // Only collect nitro, if it can actually be stored. if (m_kart->getEnergy() + m_kart->getKartProperties()->getNitroSmallContainer() diff --git a/src/karts/kart_model.hpp b/src/karts/kart_model.hpp index bc01dafc2..01898d138 100644 --- a/src/karts/kart_model.hpp +++ b/src/karts/kart_model.hpp @@ -255,8 +255,8 @@ public: /** Returns the position of a wheel relative to the kart. * \param i Index of the wheel: 0=front right, 1 = front left, 2 = rear * right, 3 = rear left. */ - const Vec3& getWheelGraphicsPosition(int i) const - {assert(i>=0 && i<4); return m_wheel_graphics_position[i];} + const Vec3& getWheelGraphicsPosition(unsigned int i) const + {assert(i<4); return m_wheel_graphics_position[i];} // ------------------------------------------------------------------------ /** Returns the position of wheels relative to the kart. */ @@ -268,20 +268,20 @@ public: * karts more stable. * \param i Index of the wheel: 0=front right, 1 = front left, 2 = rear * right, 3 = rear left. */ - const Vec3& getWheelPhysicsPosition(int i) const - {assert(i>=0 && i<4); return m_wheel_physics_position[i];} + const Vec3& getWheelPhysicsPosition(unsigned int i) const + {assert(i<4); return m_wheel_physics_position[i];} // ------------------------------------------------------------------------ /** Returns the radius of the graphical wheels. * \param i Index of the wheel: 0=front right, 1 = front left, 2 = rear * right, 3 = rear left. */ - float getWheelGraphicsRadius(int i) const - {assert(i>=0 && i<4); return m_wheel_graphics_radius[i]; } + float getWheelGraphicsRadius(unsigned int i) const + {assert(i<4); return m_wheel_graphics_radius[i]; } // ------------------------------------------------------------------------ /** Returns the position of nitro emitter relative to the kart. * \param i Index of the emitter: 0 = right, 1 = left */ const Vec3& getNitroEmittersPositon(unsigned int i) const - { assert(i>=0 && i<2); return m_nitro_emitter_position[i]; } + { assert(i<2); return m_nitro_emitter_position[i]; } // ------------------------------------------------------------------------ /** Returns true if kart has nitro emitters */ const bool hasNitroEmitters() const diff --git a/src/network/protocols/get_public_address.cpp b/src/network/protocols/get_public_address.cpp index 6a3ed5d01..87c8f84ad 100644 --- a/src/network/protocols/get_public_address.cpp +++ b/src/network/protocols/get_public_address.cpp @@ -196,7 +196,7 @@ void GetPublicAddress::asynchronousUpdate() case 0: case 1: assert(size == 8); - assert(attributes[5] = 0x01); // IPv4 only + assert(attributes[5] == 0x01); // IPv4 only port = attributes[6]*256+attributes[7]; address = (attributes[8]<<24 & 0xFF000000)+(attributes[9]<<16 & 0x00FF0000)+(attributes[10]<<8 & 0x0000FF00)+(attributes[11] & 0x000000FF); finish = true; diff --git a/src/network/protocols/start_game_protocol.cpp b/src/network/protocols/start_game_protocol.cpp index a29e15d89..bbf478cd5 100644 --- a/src/network/protocols/start_game_protocol.cpp +++ b/src/network/protocols/start_game_protocol.cpp @@ -117,7 +117,7 @@ void StartGameProtocol::update() assert(profileToUse); InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice(); int new_player_id = 0; - if (StateManager::get()->getActivePlayers().size() >= 0) // more than one player, we're the first + if (StateManager::get()->getActivePlayers().size() >= 1) // more than one player, we're the first new_player_id = 0; else new_player_id = StateManager::get()->createActivePlayer( profileToUse, device , players[i]->user_profile); diff --git a/src/tracks/quad_set.cpp b/src/tracks/quad_set.cpp index 84c9cf92e..1b1985c4a 100644 --- a/src/tracks/quad_set.cpp +++ b/src/tracks/quad_set.cpp @@ -85,7 +85,8 @@ void QuadSet::init(const std::string &filename) XMLNode *xml = file_manager->createXMLTree(filename); if(!xml || xml->getName()!="quads") { - fprintf(stderr, "[QuadSet::load] ERROR : QuadSet '%s' not found.\n", filename.c_str()); + Log::error("[QuadSet::load] ERROR : QuadSet '%s' not found.\n", filename.c_str()); + delete xml; return; } for(unsigned int i=0; igetNumNodes(); i++) @@ -93,7 +94,7 @@ void QuadSet::init(const std::string &filename) const XMLNode *xml_node = xml->getNode(i); if(xml_node->getName()!="quad") { - printf("[QuadSet::load] WARNING: Unsupported node type '%s' found in '%s' - ignored.\n", + Log::warn("[QuadSet::load] WARNING: Unsupported node type '%s' found in '%s' - ignored.\n", xml_node->getName().c_str(), filename.c_str()); continue; }