Fix some compiler warnings.

Refs #5823
This commit is contained in:
Gunnar Beutner 2014-05-11 06:00:34 +02:00
parent 7a4fa25a49
commit c7b5e4c31e
19 changed files with 70 additions and 68 deletions

View File

@ -96,7 +96,6 @@ void CompatLogger::CheckResultHandler(const Checkable::Ptr& checkable, const Che
long stateType_after = vars_after->Get("state_type"); long stateType_after = vars_after->Get("state_type");
long attempt_after = vars_after->Get("attempt"); long attempt_after = vars_after->Get("attempt");
bool reachable_after = vars_after->Get("reachable"); bool reachable_after = vars_after->Get("reachable");
bool host_reachable_after = vars_after->Get("host_reachable");
Dictionary::Ptr vars_before = cr->GetVarsBefore(); Dictionary::Ptr vars_before = cr->GetVarsBefore();

View File

@ -42,6 +42,8 @@ public:
*/ */
typedef std::vector<Value>::iterator Iterator; typedef std::vector<Value>::iterator Iterator;
typedef std::vector<Value>::size_type SizeType;
Value Get(unsigned int index) const; Value Get(unsigned int index) const;
void Set(unsigned int index, const Value& value); void Set(unsigned int index, const Value& value);
void Add(const Value& value); void Add(const Value& value);

View File

@ -43,6 +43,8 @@ public:
*/ */
typedef std::map<String, Value>::iterator Iterator; typedef std::map<String, Value>::iterator Iterator;
typedef std::map<String, Value>::size_type SizeType;
typedef std::pair<String, Value> Pair; typedef std::pair<String, Value> Pair;
Value Get(const char *key) const; Value Get(const char *key) const;

View File

@ -96,7 +96,7 @@ private:
friend class boost::iterator_core_access; friend class boost::iterator_core_access;
DynamicType::Ptr m_Type; DynamicType::Ptr m_Type;
int m_Index; DynamicType::ObjectVector::size_type m_Index;
mutable shared_ptr<T> m_Current; mutable shared_ptr<T> m_Current;
void increment(void) void increment(void)

View File

@ -80,7 +80,7 @@ private:
static std::set<Logger::Ptr> m_Loggers; static std::set<Logger::Ptr> m_Loggers;
static bool m_ConsoleLogEnabled; static bool m_ConsoleLogEnabled;
friend void Log(LogSeverity severity, const String& facility, friend I2_BASE_API void Log(LogSeverity severity, const String& facility,
const String& message); const String& message);
}; };

View File

@ -90,7 +90,7 @@ Array::Ptr ScriptUtils::Intersection(const std::vector<Value>& arguments)
Array::Ptr arr1 = static_cast<Array::Ptr>(arguments[0])->ShallowClone(); Array::Ptr arr1 = static_cast<Array::Ptr>(arguments[0])->ShallowClone();
for (int i = 1; i < arguments.size(); i++) { for (std::vector<Value>::size_type i = 1; i < arguments.size(); i++) {
std::sort(arr1->Begin(), arr1->End()); std::sort(arr1->Begin(), arr1->End());
Array::Ptr arr2 = static_cast<Array::Ptr>(arguments[i])->ShallowClone(); Array::Ptr arr2 = static_cast<Array::Ptr>(arguments[i])->ShallowClone();
@ -133,7 +133,7 @@ void ScriptUtils::Log(const std::vector<Value>& arguments)
Array::Ptr ScriptUtils::Range(const std::vector<Value>& arguments) Array::Ptr ScriptUtils::Range(const std::vector<Value>& arguments)
{ {
int start, end, increment; double start, end, increment;
switch (arguments.size()) { switch (arguments.size()) {
case 1: case 1:
@ -159,7 +159,7 @@ Array::Ptr ScriptUtils::Range(const std::vector<Value>& arguments)
(start > end && increment >= 0)) (start > end && increment >= 0))
return result; return result;
for (int i = start; i < end; i += increment) { for (double i = start; i < end; i += increment) {
result->Add(i); result->Add(i);
} }

View File

@ -138,7 +138,7 @@ static Dictionary::Ptr DeserializeDictionary(const Dictionary::Ptr& input, bool
ObjectLock olock(input); ObjectLock olock(input);
BOOST_FOREACH(const Dictionary::Pair& kv, input) { BOOST_FOREACH(const Dictionary::Pair& kv, input) {
result->Set(kv.first, Deserialize(kv.second, attributeTypes)); result->Set(kv.first, Deserialize(kv.second, safe_mode, attributeTypes));
} }
return result; return result;

View File

@ -110,7 +110,7 @@ private:
int m_ID; int m_ID;
static int m_NextID; static int m_NextID;
int m_MaxThreads; unsigned int m_MaxThreads;
boost::thread_group m_ThreadGroup; boost::thread_group m_ThreadGroup;

View File

@ -239,5 +239,5 @@ close_socket:
bool TlsStream::IsEof(void) const bool TlsStream::IsEof(void) const
{ {
return BIO_eof(m_BIO); return (BIO_eof(m_BIO) == 1);
} }

View File

@ -54,12 +54,12 @@ Object::Ptr Type::Instantiate(void) const
bool Type::IsAbstract(void) const bool Type::IsAbstract(void) const
{ {
return GetAttributes() & TAAbstract; return ((GetAttributes() & TAAbstract) != 0);
} }
bool Type::IsSafe(void) const bool Type::IsSafe(void) const
{ {
return GetAttributes() & TASafe; return ((GetAttributes() & TASafe) != 0);
} }
bool Type::IsAssignableFrom(const Type *other) const bool Type::IsAssignableFrom(const Type *other) const

View File

@ -723,7 +723,7 @@ String Utility::NaturalJoin(const std::vector<String>& tokens)
{ {
String result; String result;
for (int i = 0; i < tokens.size(); i++) { for (std::vector<String>::size_type i = 0; i < tokens.size(); i++) {
result += tokens[i]; result += tokens[i];
if (tokens.size() > i + 1) { if (tokens.size() > i + 1) {
@ -960,13 +960,13 @@ int Utility::CompareVersion(const String& v1, const String& v2)
boost::algorithm::split(tokensv1, v1, boost::is_any_of(".")); boost::algorithm::split(tokensv1, v1, boost::is_any_of("."));
boost::algorithm::split(tokensv2, v2, boost::is_any_of(".")); boost::algorithm::split(tokensv2, v2, boost::is_any_of("."));
for (int i = 0; i < tokensv2.size() - tokensv1.size(); i++) for (std::vector<String>::size_type i = 0; i < tokensv2.size() - tokensv1.size(); i++)
tokensv1.push_back("0"); tokensv1.push_back("0");
for (int i = 0; i < tokensv1.size() - tokensv2.size(); i++) for (std::vector<String>::size_type i = 0; i < tokensv1.size() - tokensv2.size(); i++)
tokensv2.push_back("0"); tokensv2.push_back("0");
for (size_t i = 0; i < tokensv1.size(); i++) { for (std::vector<String>::size_type i = 0; i < tokensv1.size(); i++) {
if (Convert::ToLong(tokensv2[i]) > Convert::ToLong(tokensv1[i])) if (Convert::ToLong(tokensv2[i]) > Convert::ToLong(tokensv1[i]))
return 1; return 1;
else if (Convert::ToLong(tokensv2[i]) < Convert::ToLong(tokensv1[i])) else if (Convert::ToLong(tokensv2[i]) < Convert::ToLong(tokensv1[i]))

View File

@ -152,7 +152,7 @@ bool Value::operator==(const Value& rhs) const
if (arr1->GetLength() != arr2->GetLength()) if (arr1->GetLength() != arr2->GetLength())
return false; return false;
for (int i = 0; i < arr1->GetLength(); i++) { for (Array::SizeType i = 0; i < arr1->GetLength(); i++) {
if (arr1->Get(i) != arr2->Get(i)) if (arr1->Get(i) != arr2->Get(i))
return false; return false;
} }
@ -471,7 +471,7 @@ Value icinga::operator>>(int lhs, const Value& rhs)
return Value(lhs) >> rhs; return Value(lhs) >> rhs;
} }
Value icinga::operator<(const Value& lhs, const Value& rhs) bool icinga::operator<(const Value& lhs, const Value& rhs)
{ {
if (lhs.IsString() && rhs.IsString()) if (lhs.IsString() && rhs.IsString())
return static_cast<String>(lhs) < static_cast<String>(rhs); return static_cast<String>(lhs) < static_cast<String>(rhs);
@ -483,27 +483,27 @@ Value icinga::operator<(const Value& lhs, const Value& rhs)
BOOST_THROW_EXCEPTION(std::invalid_argument("Operator < cannot be applied to values of type '" + lhs.GetTypeName() + "' and '" + rhs.GetTypeName() + "'")); BOOST_THROW_EXCEPTION(std::invalid_argument("Operator < cannot be applied to values of type '" + lhs.GetTypeName() + "' and '" + rhs.GetTypeName() + "'"));
} }
Value icinga::operator<(const Value& lhs, double rhs) bool icinga::operator<(const Value& lhs, double rhs)
{ {
return lhs < Value(rhs); return lhs < Value(rhs);
} }
Value icinga::operator<(double lhs, const Value& rhs) bool icinga::operator<(double lhs, const Value& rhs)
{ {
return Value(lhs) < rhs; return Value(lhs) < rhs;
} }
Value icinga::operator<(const Value& lhs, int rhs) bool icinga::operator<(const Value& lhs, int rhs)
{ {
return lhs < Value(rhs); return lhs < Value(rhs);
} }
Value icinga::operator<(int lhs, const Value& rhs) bool icinga::operator<(int lhs, const Value& rhs)
{ {
return Value(lhs) < rhs; return Value(lhs) < rhs;
} }
Value icinga::operator>(const Value& lhs, const Value& rhs) bool icinga::operator>(const Value& lhs, const Value& rhs)
{ {
if (lhs.IsString() && rhs.IsString()) if (lhs.IsString() && rhs.IsString())
return static_cast<String>(lhs) > static_cast<String>(rhs); return static_cast<String>(lhs) > static_cast<String>(rhs);
@ -515,27 +515,27 @@ Value icinga::operator>(const Value& lhs, const Value& rhs)
BOOST_THROW_EXCEPTION(std::invalid_argument("Operator > cannot be applied to values of type '" + lhs.GetTypeName() + "' and '" + rhs.GetTypeName() + "'")); BOOST_THROW_EXCEPTION(std::invalid_argument("Operator > cannot be applied to values of type '" + lhs.GetTypeName() + "' and '" + rhs.GetTypeName() + "'"));
} }
Value icinga::operator>(const Value& lhs, double rhs) bool icinga::operator>(const Value& lhs, double rhs)
{ {
return lhs > Value(rhs); return lhs > Value(rhs);
} }
Value icinga::operator>(double lhs, const Value& rhs) bool icinga::operator>(double lhs, const Value& rhs)
{ {
return Value(lhs) > rhs; return Value(lhs) > rhs;
} }
Value icinga::operator>(const Value& lhs, int rhs) bool icinga::operator>(const Value& lhs, int rhs)
{ {
return lhs > Value(rhs); return lhs > Value(rhs);
} }
Value icinga::operator>(int lhs, const Value& rhs) bool icinga::operator>(int lhs, const Value& rhs)
{ {
return Value(lhs) > rhs; return Value(lhs) > rhs;
} }
Value icinga::operator<=(const Value& lhs, const Value& rhs) bool icinga::operator<=(const Value& lhs, const Value& rhs)
{ {
if (lhs.IsString() && rhs.IsString()) if (lhs.IsString() && rhs.IsString())
return static_cast<String>(lhs) <= static_cast<String>(rhs); return static_cast<String>(lhs) <= static_cast<String>(rhs);
@ -547,27 +547,27 @@ Value icinga::operator<=(const Value& lhs, const Value& rhs)
BOOST_THROW_EXCEPTION(std::invalid_argument("Operator <= cannot be applied to values of type '" + lhs.GetTypeName() + "' and '" + rhs.GetTypeName() + "'")); BOOST_THROW_EXCEPTION(std::invalid_argument("Operator <= cannot be applied to values of type '" + lhs.GetTypeName() + "' and '" + rhs.GetTypeName() + "'"));
} }
Value icinga::operator<=(const Value& lhs, double rhs) bool icinga::operator<=(const Value& lhs, double rhs)
{ {
return lhs <= Value(rhs); return lhs <= Value(rhs);
} }
Value icinga::operator<=(double lhs, const Value& rhs) bool icinga::operator<=(double lhs, const Value& rhs)
{ {
return Value(lhs) <= rhs; return Value(lhs) <= rhs;
} }
Value icinga::operator<=(const Value& lhs, int rhs) bool icinga::operator<=(const Value& lhs, int rhs)
{ {
return lhs <= Value(rhs); return lhs <= Value(rhs);
} }
Value icinga::operator<=(int lhs, const Value& rhs) bool icinga::operator<=(int lhs, const Value& rhs)
{ {
return Value(lhs) <= rhs; return Value(lhs) <= rhs;
} }
Value icinga::operator>=(const Value& lhs, const Value& rhs) bool icinga::operator>=(const Value& lhs, const Value& rhs)
{ {
if (lhs.IsString() && rhs.IsString()) if (lhs.IsString() && rhs.IsString())
return static_cast<String>(lhs) >= static_cast<String>(rhs); return static_cast<String>(lhs) >= static_cast<String>(rhs);
@ -579,22 +579,22 @@ Value icinga::operator>=(const Value& lhs, const Value& rhs)
BOOST_THROW_EXCEPTION(std::invalid_argument("Operator >= cannot be applied to values of type '" + lhs.GetTypeName() + "' and '" + rhs.GetTypeName() + "'")); BOOST_THROW_EXCEPTION(std::invalid_argument("Operator >= cannot be applied to values of type '" + lhs.GetTypeName() + "' and '" + rhs.GetTypeName() + "'"));
} }
Value icinga::operator>=(const Value& lhs, double rhs) bool icinga::operator>=(const Value& lhs, double rhs)
{ {
return lhs >= Value(rhs); return lhs >= Value(rhs);
} }
Value icinga::operator>=(double lhs, const Value& rhs) bool icinga::operator>=(double lhs, const Value& rhs)
{ {
return Value(lhs) >= rhs; return Value(lhs) >= rhs;
} }
Value icinga::operator>=(const Value& lhs, int rhs) bool icinga::operator>=(const Value& lhs, int rhs)
{ {
return lhs >= Value(rhs); return lhs >= Value(rhs);
} }
Value icinga::operator>=(int lhs, const Value& rhs) bool icinga::operator>=(int lhs, const Value& rhs)
{ {
return Value(lhs) >= rhs; return Value(lhs) >= rhs;
} }

View File

@ -17,10 +17,10 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/ ******************************************************************************/
#include "base/application.h" #include "base/value.h"
#include "base/array.h" #include "base/array.h"
#include "base/logger_fwd.h" #include "base/dictionary.h"
#include "base/utility.h" #include "base/type.h"
#include <cJSON.h> #include <cJSON.h>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>

View File

@ -192,29 +192,29 @@ I2_BASE_API Value operator>>(double lhs, const Value& rhs);
I2_BASE_API Value operator>>(const Value& lhs, int rhs); I2_BASE_API Value operator>>(const Value& lhs, int rhs);
I2_BASE_API Value operator>>(int lhs, const Value& rhs); I2_BASE_API Value operator>>(int lhs, const Value& rhs);
I2_BASE_API Value operator<(const Value& lhs, const Value& rhs); I2_BASE_API bool operator<(const Value& lhs, const Value& rhs);
I2_BASE_API Value operator<(const Value& lhs, double rhs); I2_BASE_API bool operator<(const Value& lhs, double rhs);
I2_BASE_API Value operator<(double lhs, const Value& rhs); I2_BASE_API bool operator<(double lhs, const Value& rhs);
I2_BASE_API Value operator<(const Value& lhs, int rhs); I2_BASE_API bool operator<(const Value& lhs, int rhs);
I2_BASE_API Value operator<(int lhs, const Value& rhs); I2_BASE_API bool operator<(int lhs, const Value& rhs);
I2_BASE_API Value operator>(const Value& lhs, const Value& rhs); I2_BASE_API bool operator>(const Value& lhs, const Value& rhs);
I2_BASE_API Value operator>(const Value& lhs, double rhs); I2_BASE_API bool operator>(const Value& lhs, double rhs);
I2_BASE_API Value operator>(double lhs, const Value& rhs); I2_BASE_API bool operator>(double lhs, const Value& rhs);
I2_BASE_API Value operator>(const Value& lhs, int rhs); I2_BASE_API bool operator>(const Value& lhs, int rhs);
I2_BASE_API Value operator>(int lhs, const Value& rhs); I2_BASE_API bool operator>(int lhs, const Value& rhs);
I2_BASE_API Value operator<=(const Value& lhs, const Value& rhs); I2_BASE_API bool operator<=(const Value& lhs, const Value& rhs);
I2_BASE_API Value operator<=(const Value& lhs, double rhs); I2_BASE_API bool operator<=(const Value& lhs, double rhs);
I2_BASE_API Value operator<=(double lhs, const Value& rhs); I2_BASE_API bool operator<=(double lhs, const Value& rhs);
I2_BASE_API Value operator<=(const Value& lhs, int rhs); I2_BASE_API bool operator<=(const Value& lhs, int rhs);
I2_BASE_API Value operator<=(int lhs, const Value& rhs); I2_BASE_API bool operator<=(int lhs, const Value& rhs);
I2_BASE_API Value operator>=(const Value& lhs, const Value& rhs); I2_BASE_API bool operator>=(const Value& lhs, const Value& rhs);
I2_BASE_API Value operator>=(const Value& lhs, double rhs); I2_BASE_API bool operator>=(const Value& lhs, double rhs);
I2_BASE_API Value operator>=(double lhs, const Value& rhs); I2_BASE_API bool operator>=(double lhs, const Value& rhs);
I2_BASE_API Value operator>=(const Value& lhs, int rhs); I2_BASE_API bool operator>=(const Value& lhs, int rhs);
I2_BASE_API Value operator>=(int lhs, const Value& rhs); I2_BASE_API bool operator>=(int lhs, const Value& rhs);
I2_BASE_API std::ostream& operator<<(std::ostream& stream, const Value& value); I2_BASE_API std::ostream& operator<<(std::ostream& stream, const Value& value);
I2_BASE_API std::istream& operator>>(std::istream& stream, Value& value); I2_BASE_API std::istream& operator>>(std::istream& stream, Value& value);

View File

@ -264,7 +264,7 @@ Value AExpression::OpFunctionCall(const AExpression *expr, const Dictionary::Ptr
Array::Ptr arr = expr->EvaluateOperand2(locals); Array::Ptr arr = expr->EvaluateOperand2(locals);
std::vector<Value> arguments; std::vector<Value> arguments;
int index = 0; int index = 0;
for (int index = 0; index < arr->GetLength(); index++) { for (Array::SizeType index = 0; index < arr->GetLength(); index++) {
const AExpression::Ptr& aexpr = arr->Get(index); const AExpression::Ptr& aexpr = arr->Get(index);
arguments.push_back(aexpr->Evaluate(locals)); arguments.push_back(aexpr->Evaluate(locals));
} }
@ -279,7 +279,7 @@ Value AExpression::OpArray(const AExpression *expr, const Dictionary::Ptr& local
if (arr) { if (arr) {
int index = 0; int index = 0;
for (int index = 0; index < arr->GetLength(); index++) { for (Array::SizeType index = 0; index < arr->GetLength(); index++) {
const AExpression::Ptr& aexpr = arr->Get(index); const AExpression::Ptr& aexpr = arr->Get(index);
result->Add(aexpr->Evaluate(locals)); result->Add(aexpr->Evaluate(locals));
} }
@ -298,7 +298,7 @@ Value AExpression::OpDict(const AExpression *expr, const Dictionary::Ptr& locals
if (arr) { if (arr) {
int index = 0; int index = 0;
for (int index = 0; index < arr->GetLength(); index++) { for (Array::SizeType index = 0; index < arr->GetLength(); index++) {
const AExpression::Ptr& aexpr = arr->Get(index); const AExpression::Ptr& aexpr = arr->Get(index);
Dictionary::Ptr alocals = in_place ? locals : result; Dictionary::Ptr alocals = in_place ? locals : result;
aexpr->Evaluate(alocals); aexpr->Evaluate(alocals);
@ -483,7 +483,7 @@ Value AExpression::FunctionWrapper(const std::vector<Value>& arguments, const Ar
Dictionary::Ptr locals = make_shared<Dictionary>(); Dictionary::Ptr locals = make_shared<Dictionary>();
locals->Set("__parent", scope); locals->Set("__parent", scope);
for (int i = 0; i < std::min(arguments.size(), funcargs->GetLength()); i++) for (std::vector<Value>::size_type i = 0; i < std::min(arguments.size(), funcargs->GetLength()); i++)
locals->Set(funcargs->Get(i), arguments[i]); locals->Set(funcargs->Get(i), arguments[i]);
expr->Evaluate(locals); expr->Evaluate(locals);

View File

@ -58,10 +58,10 @@ static void lb_init(lex_buf *lb)
lb->size = 0; lb->size = 0;
} }
static void lb_cleanup(lex_buf *lb) /*static void lb_cleanup(lex_buf *lb)
{ {
free(lb->buf); free(lb->buf);
} }*/
static void lb_append_char(lex_buf *lb, char new_char) static void lb_append_char(lex_buf *lb, char new_char)
{ {

View File

@ -932,7 +932,7 @@ apply:
std::vector<String> types = ApplyRule::GetTargetTypes(type); std::vector<String> types = ApplyRule::GetTargetTypes(type);
String typeNames; String typeNames;
for (int i = 0; i < types.size(); i++) { for (std::vector<String>::size_type i = 0; i < types.size(); i++) {
if (typeNames != "") { if (typeNames != "") {
if (i == types.size() - 1) if (i == types.size() - 1)
typeNames += " or "; typeNames += " or ";

View File

@ -154,7 +154,7 @@ void ExternalCommandProcessor::Execute(double time, const String& command, const
std::copy(arguments.begin(), arguments.begin() + argnum - 1, realArguments.begin()); std::copy(arguments.begin(), arguments.begin() + argnum - 1, realArguments.begin());
String last_argument; String last_argument;
for (int i = argnum - 1; i < arguments.size(); i++) { for (std::vector<String>::size_type i = argnum - 1; i < arguments.size(); i++) {
if (!last_argument.IsEmpty()) if (!last_argument.IsEmpty())
last_argument += ";"; last_argument += ";";

View File

@ -67,7 +67,6 @@ private:
Stream::Ptr m_Stream; Stream::Ptr m_Stream;
ConnectionRole m_Role; ConnectionRole m_Role;
double m_Seen; double m_Seen;
bool m_Syncing;
bool ProcessMessage(void); bool ProcessMessage(void);
void MessageThreadProc(void); void MessageThreadProc(void);