Skip to content

Commit

Permalink
Fix compiler warnings
Browse files Browse the repository at this point in the history
fixes #12534
  • Loading branch information
gunnarbeutner committed Aug 24, 2016
1 parent ae1ab5f commit 429d11d
Show file tree
Hide file tree
Showing 25 changed files with 42 additions and 43 deletions.
4 changes: 2 additions & 2 deletions icinga-app/icinga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,14 @@ int Main(void)
if (vm.count("arg"))
args = vm["arg"].as<std::vector<std::string> >();

if (args.size() < command->GetMinArguments()) {
if (static_cast<int>(args.size()) < command->GetMinArguments()) {
Log(LogCritical, "cli")
<< "Too few arguments. Command needs at least " << command->GetMinArguments()
<< " argument" << (command->GetMinArguments() != 1 ? "s" : "") << ".";
return EXIT_FAILURE;
}

if (command->GetMaxArguments() >= 0 && args.size() > command->GetMaxArguments()) {
if (command->GetMaxArguments() >= 0 && static_cast<int>(args.size()) > command->GetMaxArguments()) {
Log(LogCritical, "cli")
<< "Too many arguments. At most " << command->GetMaxArguments()
<< " argument" << (command->GetMaxArguments() != 1 ? "s" : "") << " may be specified.";
Expand Down
2 changes: 0 additions & 2 deletions icinga-studio/mainform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,10 @@ wxPGProperty *MainForm::ValueToProperty(const String& name, const Value& value)
wxPGProperty *prop;

if (value.IsNumber()) {
double val = value;
prop = new wxFloatProperty(name.GetData(), wxPG_LABEL, value);
prop->SetAttribute(wxPG_ATTR_UNITS, "Number");
return prop;
} else if (value.IsBoolean()) {
bool val = value;
prop = new wxBoolProperty(name.GetData(), wxPG_LABEL, value);
prop->SetAttribute(wxPG_ATTR_UNITS, "Boolean");
return prop;
Expand Down
9 changes: 7 additions & 2 deletions lib/base/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Value Array::GetFieldByName(const String& field, bool sandboxed, const DebugInfo

ObjectLock olock(this);

if (index < 0 || index >= GetLength())
if (index < 0 || static_cast<size_t>(index) >= GetLength())
BOOST_THROW_EXCEPTION(ScriptError("Array index '" + Convert::ToString(index) + "' is out of bounds.", debugInfo));

return Get(index);
Expand All @@ -240,7 +240,12 @@ void Array::SetFieldByName(const String& field, const Value& value, const DebugI
ObjectLock olock(this);

int index = Convert::ToLong(field);
if (index >= GetLength())

if (index < 0)
BOOST_THROW_EXCEPTION(ScriptError("Array index '" + Convert::ToString(index) + "' is out of bounds.", debugInfo));

if (static_cast<size_t>(index) >= GetLength())
Resize(index + 1);

Set(index, value);
}
4 changes: 2 additions & 2 deletions lib/base/configobject.ti
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public:
m_DebugInfo = di;
}

inline virtual void Start(bool runtimeCreated)
inline virtual void Start(bool /* runtimeCreated */)
{ }

inline virtual void Stop(bool runtimeRemoved)
inline virtual void Stop(bool /* runtimeRemoved */)
{ }

private:
Expand Down
4 changes: 2 additions & 2 deletions lib/base/dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ String Dictionary::ToString(void) const
return msgbuf.str();
}

Value Dictionary::GetFieldByName(const String& field, bool sandboxed, const DebugInfo& debugInfo) const
Value Dictionary::GetFieldByName(const String& field, bool, const DebugInfo& debugInfo) const
{
Value value;

Expand All @@ -208,7 +208,7 @@ Value Dictionary::GetFieldByName(const String& field, bool sandboxed, const Debu
return GetPrototypeField(const_cast<Dictionary *>(this), field, false, debugInfo);
}

void Dictionary::SetFieldByName(const String& field, const Value& value, const DebugInfo& debugInfo)
void Dictionary::SetFieldByName(const String& field, const Value& value, const DebugInfo&)
{
Set(field, value);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/base/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ I2_BASE_API void RethrowUncaughtException(void);

typedef boost::error_info<StackTrace, StackTrace> StackTraceErrorInfo;

inline std::string to_string(const StackTraceErrorInfo& e)
inline std::string to_string(const StackTraceErrorInfo&)
{
return "";
}
Expand Down
2 changes: 1 addition & 1 deletion lib/base/socketevents-poll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void SocketEventEnginePoll::ThreadProc(int tid)
if (m_FDChanged[tid])
continue;

for (int i = 0; i < pfds.size(); i++) {
for (std::vector<pollfd>::size_type i = 0; i < pfds.size(); i++) {
if ((pfds[i].revents & (POLLIN | POLLOUT | POLLHUP | POLLERR)) == 0)
continue;

Expand Down
16 changes: 10 additions & 6 deletions lib/cli/clicommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ bool CLICommand::ParseCommand(int argc, char **argv, po::options_description& vi
BOOST_FOREACH(const CLIKeyValue& kv, GetRegistry()) {
const std::vector<String>& vname = kv.first;

for (int i = 0, k = 1; i < vname.size() && k < argc; i++, k++) {
std::vector<String>::size_type i;
int k;
for (i = 0, k = 1; i < vname.size() && k < argc; i++, k++) {
if (strcmp(argv[k], "--no-stack-rlimit") == 0 || strcmp(argv[k], "--autocomplete") == 0 || strcmp(argv[k], "--scm") == 0) {
i--;
continue;
Expand Down Expand Up @@ -237,14 +239,16 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi

arg_begin = 0;

for (int i = 0, k = 1; i < vname.size() && k < argc; i++, k++) {
std::vector<String>::size_type i;
int k;
for (i = 0, k = 1; i < vname.size() && k < argc; i++, k++) {
if (strcmp(argv[k], "--no-stack-rlimit") == 0 || strcmp(argv[k], "--autocomplete") == 0 || strcmp(argv[k], "--scm") == 0) {
i--;
arg_begin++;
continue;
}

if (autocomplete && i >= autoindex - 1)
if (autocomplete && static_cast<int>(i) >= autoindex - 1)
break;

if (vname[i] != argv[k])
Expand All @@ -267,7 +271,7 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi
if (autoindex < argc)
aword = argv[autoindex];

if (autoindex - 1 > best_match.size() && !command)
if (autoindex - 1 > static_cast<int>(best_match.size()) && !command)
return;
} else
std::cout << "Supported commands: " << std::endl;
Expand All @@ -280,7 +284,7 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi

bool match = true;

for (int i = 0; i < best_match.size(); i++) {
for (std::vector<String>::size_type i = 0; i < best_match.size(); i++) {
if (vname[i] != best_match[i]) {
match = false;
break;
Expand All @@ -293,7 +297,7 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi
if (autocomplete) {
String cname;

if (autoindex - 1 < vname.size()) {
if (autoindex - 1 < static_cast<int>(vname.size())) {
cname = vname[autoindex - 1];

if (cname.Find(aword) == 0)
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/consolecommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ char *ConsoleCommand::ConsoleCompleteHelper(const char *word, int state)
}
}

if (state >= matches.size())
if (state >= static_cast<int>(matches.size()))
return NULL;

return strdup(matches[state].CStr());
Expand Down
1 change: 0 additions & 1 deletion lib/cli/consolecommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class ConsoleCommand : public CLICommand
private:
mutable boost::mutex m_Mutex;
mutable boost::condition_variable m_CV;
mutable bool m_CommandReady;

static void ExecuteScriptCompletionHandler(boost::mutex& mutex, boost::condition_variable& cv,
bool& ready, boost::exception_ptr eptr, const Value& result, Value& resultOut,
Expand Down
6 changes: 3 additions & 3 deletions lib/config/config_parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ Expression *ConfigCompiler::Compile(void)

std::vector<Expression *> dlist;
typedef std::pair<Expression *, EItemInfo> EListItem;
int num = 0;
std::vector<std::pair<Expression *, EItemInfo> >::size_type num = 0;
BOOST_FOREACH(const EListItem& litem, llist) {
if (!litem.second.SideEffect && num != llist.size() - 1) {
yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used.");
Expand Down Expand Up @@ -778,7 +778,7 @@ rterm_scope: '{'
context->m_IgnoreNewlines.pop();
std::vector<Expression *> dlist;
typedef std::pair<Expression *, EItemInfo> EListItem;
int num = 0;
std::vector<std::pair<Expression *, EItemInfo> >::size_type num = 0;
BOOST_FOREACH(const EListItem& litem, *$3) {
if (!litem.second.SideEffect && num != $3->size() - 1)
yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used.");
Expand Down Expand Up @@ -1006,7 +1006,7 @@ rterm_no_side_effect_no_dict: T_STRING

std::vector<Expression *> dlist;
typedef std::pair<Expression *, EItemInfo> EListItem;
int num = 0;
std::vector<std::pair<Expression *, EItemInfo> >::size_type num = 0;
BOOST_FOREACH(const EListItem& litem, *$3) {
if (!litem.second.SideEffect && num != $3->size() - 1)
yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used.");
Expand Down
2 changes: 1 addition & 1 deletion lib/config/expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ class I2_CONFIG_API FunctionExpression : public DebuggableExpression
public:
FunctionExpression(const String& name, const std::vector<String>& args,
std::map<String, Expression *> *closedVars, Expression *expression, const DebugInfo& debugInfo = DebugInfo())
: DebuggableExpression(debugInfo), m_Args(args), m_Name(name), m_ClosedVars(closedVars), m_Expression(expression)
: DebuggableExpression(debugInfo), m_Name(name), m_Args(args), m_ClosedVars(closedVars), m_Expression(expression)
{ }

~FunctionExpression(void)
Expand Down
6 changes: 3 additions & 3 deletions lib/db_ido/dbconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Timer::Ptr DbConnection::m_ProgramStatusTimer;
boost::once_flag DbConnection::m_OnceFlag = BOOST_ONCE_INIT;

DbConnection::DbConnection(void)
: m_QueryStats(15 * 60), m_PendingQueries(0), m_PendingQueriesTimestamp(0),
m_IDCacheValid(false), m_ActiveChangedHandler(false)
: m_IDCacheValid(false), m_QueryStats(15 * 60), m_PendingQueries(0),
m_PendingQueriesTimestamp(0), m_ActiveChangedHandler(false)
{ }

void DbConnection::OnConfigLoaded(void)
Expand Down Expand Up @@ -255,7 +255,7 @@ void DbConnection::CleanUpHandler(void)
{ "downtimehistory", "entry_time" },
{ "eventhandlers", "start_time" },
{ "externalcommands", "entry_time" },
{ "flappinghistory" "event_time" },
{ "flappinghistory", "event_time" },
{ "hostchecks", "start_time" },
{ "logentries", "logentry_time" },
{ "notifications", "start_time" },
Expand Down
2 changes: 0 additions & 2 deletions lib/db_ido/hostdbobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,6 @@ String HostDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) co
if (!parent)
continue;

int state_filter = dep->GetStateFilter();

Array::Ptr depInfo = new Array();
depInfo->Add(parent->GetName());
depInfo->Add(dep->GetStateFilter());
Expand Down
2 changes: 0 additions & 2 deletions lib/db_ido/servicedbobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,6 @@ String ServiceDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields)
if (!parent)
continue;

int state_filter = dep->GetStateFilter();

Array::Ptr depInfo = new Array();
depInfo->Add(parent->GetName());
depInfo->Add(dep->GetStateFilter());
Expand Down
2 changes: 1 addition & 1 deletion lib/db_ido_mysql/idomysqlconnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class IdoMysqlConnection : public ObjectImpl<IdoMysqlConnection>

MYSQL m_Connection;
int m_AffectedRows;
int m_MaxPacketSize;
unsigned int m_MaxPacketSize;

std::vector<IdoAsyncQuery> m_AsyncQueries;

Expand Down
4 changes: 2 additions & 2 deletions lib/icinga/cib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ CheckableCheckStatistics CIB::CalculateServiceCheckStats(void)

ServiceStatistics CIB::CalculateServiceStats(void)
{
ServiceStatistics ss = {0};
ServiceStatistics ss = {};

BOOST_FOREACH(const Service::Ptr& service, ConfigType::GetObjectsByType<Service>()) {
ObjectLock olock(service);
Expand Down Expand Up @@ -232,7 +232,7 @@ ServiceStatistics CIB::CalculateServiceStats(void)

HostStatistics CIB::CalculateHostStats(void)
{
HostStatistics hs = {0};
HostStatistics hs = {};

BOOST_FOREACH(const Host::Ptr& host, ConfigType::GetObjectsByType<Host>()) {
ObjectLock olock(host);
Expand Down
2 changes: 1 addition & 1 deletion lib/livestatus/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ std::vector<LivestatusRowValue> Table::FilterRows(const Filter::Ptr& filter, int

bool Table::FilteredAddRow(std::vector<LivestatusRowValue>& rs, const Filter::Ptr& filter, int limit, const Value& row, LivestatusGroupByType groupByType, const Object::Ptr& groupByObject)
{
if (limit != -1 && rs.size() == limit)
if (limit != -1 && static_cast<int>(rs.size()) == limit)
return false;

if (!filter || filter->Apply(this, row)) {
Expand Down
3 changes: 1 addition & 2 deletions lib/perfdata/influxdbwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ void InfluxdbWriter::CheckResultHandler(const Checkable::Ptr& checkable, const C
Dictionary::Ptr tags = tmpl->Get("tags");
if (tags) {
ObjectLock olock(tags);
retry:
BOOST_FOREACH(const Dictionary::Pair& pair, tags) {
// Prevent missing macros from warning; will return an empty value
// which will be filtered out in SendMetric()
Expand Down Expand Up @@ -318,7 +317,7 @@ void InfluxdbWriter::SendMetric(const Dictionary::Ptr& tmpl, const String& label
m_DataBuffer->Add(String(msgbuf.str()));

// Flush if we've buffered too much to prevent excessive memory use
if (m_DataBuffer->GetLength() >= GetFlushThreshold()) {
if (static_cast<int>(m_DataBuffer->GetLength()) >= GetFlushThreshold()) {
Log(LogDebug, "InfluxdbWriter")
<< "Data buffer overflow writing " << m_DataBuffer->GetLength() << " data points";
Flush();
Expand Down
1 change: 0 additions & 1 deletion lib/remote/createobjecthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ bool CreateObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
Dictionary::Ptr attrs = params->Get("attrs");

Dictionary::Ptr result1 = new Dictionary();
int code;
String status;
Array::Ptr errors = new Array();

Expand Down
1 change: 0 additions & 1 deletion lib/remote/eventqueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class I2_REMOTE_API EventQueue : public Object

std::set<String> m_Types;
Expression *m_Filter;
double m_Ttl;

std::map<void *, std::deque<Dictionary::Ptr> > m_Events;
};
Expand Down
2 changes: 1 addition & 1 deletion lib/remote/httphandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void HttpHandler::ProcessRequest(const ApiUser::Ptr& user, HttpRequest& request,
std::vector<HttpHandler::Ptr> handlers;
const std::vector<String>& path = request.RequestUrl->GetPath();

for (int i = 0; i <= path.size(); i++) {
for (std::vector<String>::size_type i = 0; i <= path.size(); i++) {
Array::Ptr current_handlers = node->Get("handlers");

if (current_handlers) {
Expand Down
2 changes: 1 addition & 1 deletion lib/remote/httpserverconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static boost::once_flag l_HttpServerConnectionOnceFlag = BOOST_ONCE_INIT;
static Timer::Ptr l_HttpServerConnectionTimeoutTimer;

HttpServerConnection::HttpServerConnection(const String& identity, bool authenticated, const TlsStream::Ptr& stream)
: m_Stream(stream), m_CurrentRequest(stream), m_Seen(Utility::GetTime()), m_PendingRequests(0)
: m_Stream(stream), m_Seen(Utility::GetTime()), m_CurrentRequest(stream), m_PendingRequests(0)
{
boost::call_once(l_HttpServerConnectionOnceFlag, &HttpServerConnection::StaticInitialize);

Expand Down
2 changes: 1 addition & 1 deletion lib/remote/jsonrpcconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void JsonRpcConnection::StaticInitialize(void)
l_JsonRpcConnectionWorkQueueCount = Application::GetConcurrency();
l_JsonRpcConnectionWorkQueues = new WorkQueue[l_JsonRpcConnectionWorkQueueCount];

for (int i = 0; i < l_JsonRpcConnectionWorkQueueCount; i++) {
for (size_t i = 0; i < l_JsonRpcConnectionWorkQueueCount; i++) {
l_JsonRpcConnectionWorkQueues[i].SetName("JsonRpcConnection, #" + Convert::ToString(i));
}
}
Expand Down
2 changes: 1 addition & 1 deletion tools/mkclass/classcompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void ClassCompiler::HandleCode(const std::string& code, const ClassDebugInfo&)
m_Header << code << std::endl;
}

void ClassCompiler::HandleLibrary(const std::string& library, const ClassDebugInfo& locp)
void ClassCompiler::HandleLibrary(const std::string& library, const ClassDebugInfo&)
{
m_Library = library;

Expand Down

0 comments on commit 429d11d

Please sign in to comment.