Commit 720e31a5 authored by louiz’'s avatar louiz’

Fix a few issues reported by static analyzers

parent 0ab5ecea
......@@ -480,7 +480,7 @@ void Bridge::send_user_join(const std::string& hostname,
affiliation, role, this->user_jid, self);
}
void Bridge::send_topic(const std::string& hostname, const std::string& chan_name, const std::string topic)
void Bridge::send_topic(const std::string& hostname, const std::string& chan_name, const std::string& topic)
{
this->xmpp->send_topic(chan_name + "%" + hostname, this->make_xmpp_body(topic), this->user_jid);
}
......
......@@ -114,7 +114,7 @@ public:
/**
* Send the topic of the MUC to the user
*/
void send_topic(const std::string& hostname, const std::string& chan_name, const std::string topic);
void send_topic(const std::string& hostname, const std::string& chan_name, const std::string& topic);
/**
* Send a MUC message from some participant
*/
......
......@@ -166,10 +166,8 @@ Xmpp::body irc_format_to_xhtmlim(const std::string& s)
{
current_node->close();
result->add_child(current_node);
current_node = result.get();
}
result->close();
Xmpp::body body_res = std::make_tuple(cleaned, std::move(result));
return body_res;
......
......@@ -28,13 +28,6 @@ int Config::get_int(const std::string& option, const int& def)
return def;
}
void Config::set_int(const std::string& option, const int& value, bool save)
{
std::ostringstream os;
os << value;
Config::set(option, os.str(), save);
}
void Config::set(const std::string& option, const std::string& value, bool save)
{
Config* self = Config::instance().get();
......
......@@ -52,14 +52,6 @@ public:
* @param save if true, save the config file
*/
static void set(const std::string&, const std::string&, bool save = false);
/**
* Set a value for the given option. And write all the config
* in the file from which it was read if boolean is set.
* @param option The option to set
* @param value The value to use
* @param save if true, save the config file
*/
static void set_int(const std::string&, const int&, bool save = false);
/**
* Adds a function to a list. This function will be called whenever a
* configuration change occurs.
......
......@@ -12,7 +12,7 @@ void IrcChannel::set_self(const std::string& name)
}
IrcUser* IrcChannel::add_user(const std::string& name,
const std::map<char, char> prefix_to_mode)
const std::map<char, char>& prefix_to_mode)
{
this->users.emplace_back(std::make_unique<IrcUser>(name, prefix_to_mode));
return this->users.back().get();
......
......@@ -21,7 +21,7 @@ public:
void set_self(const std::string& name);
IrcUser* get_self() const;
IrcUser* add_user(const std::string& name,
const std::map<char, char> prefix_to_mode);
const std::map<char, char>& prefix_to_mode);
IrcUser* find_user(const std::string& name) const;
void remove_user(const IrcUser* user);
void remove_all_users();
......
......@@ -133,7 +133,7 @@ void Poller::stop_watching_send_events(SocketHandler* socket_handler)
int Poller::poll(const std::chrono::milliseconds& timeout)
{
if (this->socket_handlers.size() == 0)
if (this->socket_handlers.empty())
return -1;
#if POLLER == POLL
int nb_events = ::poll(this->fds, this->nfds, timeout.count());
......
......@@ -222,7 +222,7 @@ int main()
IrcUser user2("coucou!~other@host.bla", prefixes);
assert(user2.nick == "coucou");
assert(user2.host == "~other@host.bla");
assert(user2.modes.size() == 0);
assert(user2.modes.empty());
assert(user2.modes.find('a') == user2.modes.end());
/**
......
......@@ -197,6 +197,7 @@ namespace utils
case E2BIG:
// This should never happen
done = true;
break;
default:
// This should happen even neverer
done = true;
......
......@@ -29,7 +29,7 @@ const std::map<const std::string, const AdhocCommand>& AdhocCommandsHandler::get
return this->commands;
}
XmlNode&& AdhocCommandsHandler::handle_request(const std::string& executor_jid, XmlNode command_node)
XmlNode AdhocCommandsHandler::handle_request(const std::string& executor_jid, XmlNode command_node)
{
std::string action = command_node.get_tag("action");
if (action.empty())
......@@ -127,7 +127,7 @@ XmlNode&& AdhocCommandsHandler::handle_request(const std::string& executor_jid,
command_node.add_child(std::move(error));
}
}
return std::move(command_node);
return command_node;
}
void AdhocCommandsHandler::remove_session(const std::string& session_id, const std::string& initiator_jid)
......
......@@ -36,7 +36,7 @@ public:
* Takes a copy of the <command/> node so we can actually edit it and use
* it as our return value.
*/
XmlNode&& handle_request(const std::string& executor_jid, XmlNode command_node);
XmlNode handle_request(const std::string& executor_jid, XmlNode command_node);
/**
* Remove the session from the list. This is done to avoid filling the
* memory with waiting session (for example due to a client that starts
......
......@@ -286,7 +286,6 @@ void XmppComponent::handle_handshake(const Stanza& stanza)
uint64_t usec;
if (sd_watchdog_enabled(0, &usec) > 0)
{
std::chrono::microseconds delay(usec);
TimedEventsManager::instance().add_event(TimedEvent(
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::microseconds(usec / 2)),
[]() { sd_notify(0, "WATCHDOG=1"); }));
......
......@@ -151,7 +151,7 @@ private:
/**
* An XMPP stanza is just an XML node of level 2 in the XMPP document (the
* level 1 ones are the <stream::stream/>, and the ones about 2 are just the
* level 1 ones are the <stream::stream/>, and the ones above 2 are just the
* content of the stanzas)
*/
typedef XmlNode Stanza;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment