From 229837b14c8c31ec5d7c920e3c4dc7cba58e2419 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Thu, 29 Nov 2012 20:20:40 +0100 Subject: [PATCH] Fix some compiler warnings. size_t/int/unsigned conversions and extra ';' --- simgear/props/props.cxx | 20 +++++------ simgear/scene/model/particles.cxx | 6 ++-- simgear/scene/tsync/terrasync.cxx | 4 +-- simgear/screen/colors.hxx | 8 ++--- simgear/structure/SGExpression.hxx | 56 +++++++++++++++--------------- 5 files changed, 47 insertions(+), 47 deletions(-) diff --git a/simgear/props/props.cxx b/simgear/props/props.cxx index a05547ca..f5484568 100644 --- a/simgear/props/props.cxx +++ b/simgear/props/props.cxx @@ -158,7 +158,7 @@ inline bool validateName(const string& name) static char * copy_string (const char * s) { - unsigned long int slen = strlen(s); + size_t slen = strlen(s); char * copy = new char[slen + 1]; // the source string length is known so no need to check for '\0' @@ -181,15 +181,15 @@ template static int find_child (Itr begin, Itr end, int index, const PropertyList& nodes) { - int nNodes = nodes.size(); + size_t nNodes = nodes.size(); boost::iterator_range name(begin, end); - for (int i = 0; i < nNodes; i++) { + for (size_t i = 0; i < nNodes; i++) { SGPropertyNode * node = nodes[i]; // searching for a matching index is a lot less time consuming than // comparing two strings so do that first. if (node->getIndex() == index && boost::equals(node->getName(), name)) - return i; + return static_cast(i); } return -1; } @@ -200,10 +200,10 @@ find_child (Itr begin, Itr end, int index, const PropertyList& nodes) static int find_last_child (const char * name, const PropertyList& nodes) { - int nNodes = nodes.size(); + size_t nNodes = nodes.size(); int index = -1; - for (int i = 0; i < nNodes; i++) { + for (size_t i = 0; i < nNodes; i++) { SGPropertyNode * node = nodes[i]; if (compare_strings(node->getName(), name)) { @@ -1008,9 +1008,9 @@ PropertyList SGPropertyNode::getChildren (const char * name) const { PropertyList children; - int max = _children.size(); + size_t max = _children.size(); - for (int i = 0; i < max; i++) + for (size_t i = 0; i < max; i++) if (compare_strings(_children[i]->getName(), name)) children.push_back(_children[i]); @@ -1066,7 +1066,7 @@ SGPropertyNode::removeChildren (const char * name, bool keep) { PropertyList children; - for (int pos = _children.size() - 1; pos >= 0; pos--) + for (int pos = static_cast(_children.size() - 1); pos >= 0; pos--) if (compare_strings(_children[pos]->getName(), name)) children.push_back(removeChild(pos, keep)); @@ -2214,7 +2214,7 @@ SGPropertyNode::fireChildRemoved (SGPropertyNode * parent, SGPropertyChangeListener::~SGPropertyChangeListener () { - for (int i = _properties.size() - 1; i >= 0; i--) + for (int i = static_cast(_properties.size() - 1); i >= 0; i--) _properties[i]->removeChangeListener(this); } diff --git a/simgear/scene/model/particles.cxx b/simgear/scene/model/particles.cxx index 5401e8ec..c7308e7e 100644 --- a/simgear/scene/model/particles.cxx +++ b/simgear/scene/model/particles.cxx @@ -1,6 +1,6 @@ // particles.cxx - classes to manage particles -// started in 2008 by Tiago Gusmão, using animation.hxx as reference -// Copyright (C) 2008 Tiago Gusmão +// started in 2008 by Tiago Gusm�o, using animation.hxx as reference +// Copyright (C) 2008 Tiago Gusm�o // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -79,7 +79,7 @@ SGConstPropertyNode_ptr GlobalParticleCallback::enabledNode = 0; osg::ref_ptr Particles::commonRoot; osg::ref_ptr Particles::psu = new osgParticle::ParticleSystemUpdater; -osg::ref_ptr Particles::commonGeode = new osg::Geode;; +osg::ref_ptr Particles::commonGeode = new osg::Geode; osg::Vec3 Particles::_wind; bool Particles::_frozen = false; diff --git a/simgear/scene/tsync/terrasync.cxx b/simgear/scene/tsync/terrasync.cxx index e4ae8ff8..f0e8a3b7 100644 --- a/simgear/scene/tsync/terrasync.cxx +++ b/simgear/scene/tsync/terrasync.cxx @@ -99,7 +99,7 @@ namespace UpdateInterval static const double SuccessfulAttempt = 24*60*60; // interval in seconds to allow another update after a failed attempt (10 minutes) static const double FailedAttempt = 10*60; -}; +} typedef map CompletedTiles; @@ -110,7 +110,7 @@ string stripPath(string path) { // svn doesn't like trailing white-spaces or path separators - strip them! path = simgear::strutils::strip(path); - int slen = path.length(); + size_t slen = path.length(); while ((slen>0)&& ((path[slen-1]=='/')||(path[slen-1]=='\\'))) { diff --git a/simgear/screen/colors.hxx b/simgear/screen/colors.hxx index c3ea8e7e..eb78faef 100644 --- a/simgear/screen/colors.hxx +++ b/simgear/screen/colors.hxx @@ -44,7 +44,7 @@ inline void gamma_correct_rgb(float *color, color[0] = pow(color[0], tmp); color[1] = pow(color[1], tmp); color[2] = pow(color[2], tmp); -}; +} inline void gamma_correct_c(float *color, float reff = 2.5, float system = system_gamma) @@ -53,7 +53,7 @@ inline void gamma_correct_c(float *color, return; *color = pow(*color, reff/system); -}; +} inline void gamma_restore_rgb(float *color, float reff = 2.5, float system = system_gamma) @@ -65,7 +65,7 @@ inline void gamma_restore_rgb(float *color, color[0] = pow(color[0], tmp); color[1] = pow(color[1], tmp); color[2] = pow(color[2], tmp); -}; +} inline void gamma_restore_c(float *color, float reff = 2.5, float system = system_gamma) @@ -74,7 +74,7 @@ inline void gamma_restore_c(float *color, return; *color = pow(*color, system/reff); -}; +} #endif // _SG_COLORS_HXX diff --git a/simgear/structure/SGExpression.hxx b/simgear/structure/SGExpression.hxx index a6012a0d..440f41a2 100644 --- a/simgear/structure/SGExpression.hxx +++ b/simgear/structure/SGExpression.hxx @@ -196,11 +196,11 @@ private: template class SGBinaryExpression : public SGExpression { public: - const SGExpression* getOperand(unsigned i) const + const SGExpression* getOperand(size_t i) const { return _expressions[i]; } - SGExpression* getOperand(unsigned i) + SGExpression* getOperand(size_t i) { return _expressions[i]; } - void setOperand(unsigned i, SGExpression* expression) + void setOperand(size_t i, SGExpression* expression) { if (!expression) expression = new SGConstExpression(T()); @@ -229,16 +229,16 @@ private: template class SGNaryExpression : public SGExpression { public: - unsigned getNumOperands() const + size_t getNumOperands() const { return _expressions.size(); } - const SGExpression* getOperand(unsigned i) const + const SGExpression* getOperand(size_t i) const { return _expressions[i]; } - SGExpression* getOperand(unsigned i) + SGExpression* getOperand(size_t i) { return _expressions[i]; } - unsigned addOperand(SGExpression* expression) + size_t addOperand(SGExpression* expression) { if (!expression) - return ~unsigned(0); + return ~size_t(0); _expressions.push_back(expression); return _expressions.size() - 1; } @@ -254,14 +254,14 @@ public: virtual bool isConst() const { - for (unsigned i = 0; i < _expressions.size(); ++i) + for (size_t i = 0; i < _expressions.size(); ++i) if (!_expressions[i]->isConst()) return false; return true; } virtual SGExpression* simplify() { - for (unsigned i = 0; i < _expressions.size(); ++i) + for (size_t i = 0; i < _expressions.size(); ++i) _expressions[i] = _expressions[i]->simplify(); return SGExpression::simplify(); } @@ -782,8 +782,8 @@ public: virtual void eval(T& value, const simgear::expression::Binding* b) const { value = T(0); - unsigned sz = SGNaryExpression::getNumOperands(); - for (unsigned i = 0; i < sz; ++i) + size_t sz = SGNaryExpression::getNumOperands(); + for (size_t i = 0; i < sz; ++i) value += getOperand(i)->getValue(b); } using SGNaryExpression::getValue; @@ -801,8 +801,8 @@ public: virtual void eval(T& value, const simgear::expression::Binding* b) const { value = getOperand(0)->getValue(b); - unsigned sz = SGNaryExpression::getNumOperands(); - for (unsigned i = 1; i < sz; ++i) + size_t sz = SGNaryExpression::getNumOperands(); + for (size_t i = 1; i < sz; ++i) value -= getOperand(i)->getValue(b); } using SGNaryExpression::getValue; @@ -820,8 +820,8 @@ public: virtual void eval(T& value, const simgear::expression::Binding* b) const { value = T(1); - unsigned sz = SGNaryExpression::getNumOperands(); - for (unsigned i = 0; i < sz; ++i) + size_t sz = SGNaryExpression::getNumOperands(); + for (size_t i = 0; i < sz; ++i) value *= getOperand(i)->getValue(b); } using SGNaryExpression::getValue; @@ -838,12 +838,12 @@ public: { } virtual void eval(T& value, const simgear::expression::Binding* b) const { - unsigned sz = SGNaryExpression::getNumOperands(); + size_t sz = SGNaryExpression::getNumOperands(); if (sz < 1) return; value = getOperand(0)->getValue(b); - for (unsigned i = 1; i < sz; ++i) + for (size_t i = 1; i < sz; ++i) value = SGMisc::min(value, getOperand(i)->getValue(b)); } using SGNaryExpression::getOperand; @@ -859,12 +859,12 @@ public: { } virtual void eval(T& value, const simgear::expression::Binding* b) const { - unsigned sz = SGNaryExpression::getNumOperands(); + size_t sz = SGNaryExpression::getNumOperands(); if (sz < 1) return; value = getOperand(0)->getValue(b); - for (unsigned i = 1; i < sz; ++i) + for (size_t i = 1; i < sz; ++i) value = SGMisc::max(value, getOperand(i)->getValue(b)); } using SGNaryExpression::getOperand; @@ -1076,16 +1076,16 @@ namespace simgear class GeneralNaryExpression : public ::SGExpression { public: typedef OpType operand_type; - unsigned getNumOperands() const + size_t getNumOperands() const { return _expressions.size(); } - const ::SGExpression* getOperand(unsigned i) const + const ::SGExpression* getOperand(size_t i) const { return _expressions[i]; } - ::SGExpression* getOperand(unsigned i) + ::SGExpression* getOperand(size_t i) { return _expressions[i]; } - unsigned addOperand(::SGExpression* expression) + size_t addOperand(::SGExpression* expression) { if (!expression) - return ~unsigned(0); + return ~size_t(0); _expressions.push_back(expression); return _expressions.size() - 1; } @@ -1101,14 +1101,14 @@ namespace simgear virtual bool isConst() const { - for (unsigned i = 0; i < _expressions.size(); ++i) + for (size_t i = 0; i < _expressions.size(); ++i) if (!_expressions[i]->isConst()) return false; return true; } virtual ::SGExpression* simplify() { - for (unsigned i = 0; i < _expressions.size(); ++i) + for (size_t i = 0; i < _expressions.size(); ++i) _expressions[i] = _expressions[i]->simplify(); return SGExpression::simplify(); } @@ -1145,7 +1145,7 @@ namespace simgear } virtual void eval(bool& value, const simgear::expression::Binding* b) const { - unsigned sz = this->getNumOperands(); + size_t sz = this->getNumOperands(); if (sz != 2) return; value = _pred(this->getOperand(0)->getValue(b), -- 2.39.5