Fix a few issues reported by static analyzers
This commit is contained in:
@@ -480,7 +480,7 @@ void Bridge::send_user_join(const std::string& hostname,
|
|||||||
affiliation, role, this->user_jid, self);
|
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);
|
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
|
* 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
|
* Send a MUC message from some participant
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -166,10 +166,8 @@ Xmpp::body irc_format_to_xhtmlim(const std::string& s)
|
|||||||
{
|
{
|
||||||
current_node->close();
|
current_node->close();
|
||||||
result->add_child(current_node);
|
result->add_child(current_node);
|
||||||
current_node = result.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
result->close();
|
result->close();
|
||||||
Xmpp::body body_res = std::make_tuple(cleaned, std::move(result));
|
Xmpp::body body_res = std::make_tuple(cleaned, std::move(result));
|
||||||
return body_res;
|
return body_res;
|
||||||
|
|||||||
@@ -28,13 +28,6 @@ int Config::get_int(const std::string& option, const int& def)
|
|||||||
return 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)
|
void Config::set(const std::string& option, const std::string& value, bool save)
|
||||||
{
|
{
|
||||||
Config* self = Config::instance().get();
|
Config* self = Config::instance().get();
|
||||||
|
|||||||
@@ -52,14 +52,6 @@ public:
|
|||||||
* @param save if true, save the config file
|
* @param save if true, save the config file
|
||||||
*/
|
*/
|
||||||
static void set(const std::string&, const std::string&, bool save = false);
|
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
|
* Adds a function to a list. This function will be called whenever a
|
||||||
* configuration change occurs.
|
* configuration change occurs.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ void IrcChannel::set_self(const std::string& name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
IrcUser* IrcChannel::add_user(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));
|
this->users.emplace_back(std::make_unique<IrcUser>(name, prefix_to_mode));
|
||||||
return this->users.back().get();
|
return this->users.back().get();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public:
|
|||||||
void set_self(const std::string& name);
|
void set_self(const std::string& name);
|
||||||
IrcUser* get_self() const;
|
IrcUser* get_self() const;
|
||||||
IrcUser* add_user(const std::string& name,
|
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;
|
IrcUser* find_user(const std::string& name) const;
|
||||||
void remove_user(const IrcUser* user);
|
void remove_user(const IrcUser* user);
|
||||||
void remove_all_users();
|
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)
|
int Poller::poll(const std::chrono::milliseconds& timeout)
|
||||||
{
|
{
|
||||||
if (this->socket_handlers.size() == 0)
|
if (this->socket_handlers.empty())
|
||||||
return -1;
|
return -1;
|
||||||
#if POLLER == POLL
|
#if POLLER == POLL
|
||||||
int nb_events = ::poll(this->fds, this->nfds, timeout.count());
|
int nb_events = ::poll(this->fds, this->nfds, timeout.count());
|
||||||
|
|||||||
+1
-1
@@ -222,7 +222,7 @@ int main()
|
|||||||
IrcUser user2("coucou!~other@host.bla", prefixes);
|
IrcUser user2("coucou!~other@host.bla", prefixes);
|
||||||
assert(user2.nick == "coucou");
|
assert(user2.nick == "coucou");
|
||||||
assert(user2.host == "~other@host.bla");
|
assert(user2.host == "~other@host.bla");
|
||||||
assert(user2.modes.size() == 0);
|
assert(user2.modes.empty());
|
||||||
assert(user2.modes.find('a') == user2.modes.end());
|
assert(user2.modes.find('a') == user2.modes.end());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ namespace utils
|
|||||||
case E2BIG:
|
case E2BIG:
|
||||||
// This should never happen
|
// This should never happen
|
||||||
done = true;
|
done = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// This should happen even neverer
|
// This should happen even neverer
|
||||||
done = true;
|
done = true;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const std::map<const std::string, const AdhocCommand>& AdhocCommandsHandler::get
|
|||||||
return this->commands;
|
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");
|
std::string action = command_node.get_tag("action");
|
||||||
if (action.empty())
|
if (action.empty())
|
||||||
@@ -127,7 +127,7 @@ XmlNode&& AdhocCommandsHandler::handle_request(const std::string& executor_jid,
|
|||||||
command_node.add_child(std::move(error));
|
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)
|
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
|
* Takes a copy of the <command/> node so we can actually edit it and use
|
||||||
* it as our return value.
|
* 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
|
* 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
|
* 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;
|
uint64_t usec;
|
||||||
if (sd_watchdog_enabled(0, &usec) > 0)
|
if (sd_watchdog_enabled(0, &usec) > 0)
|
||||||
{
|
{
|
||||||
std::chrono::microseconds delay(usec);
|
|
||||||
TimedEventsManager::instance().add_event(TimedEvent(
|
TimedEventsManager::instance().add_event(TimedEvent(
|
||||||
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::microseconds(usec / 2)),
|
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::microseconds(usec / 2)),
|
||||||
[]() { sd_notify(0, "WATCHDOG=1"); }));
|
[]() { 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
|
* 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)
|
* content of the stanzas)
|
||||||
*/
|
*/
|
||||||
typedef XmlNode Stanza;
|
typedef XmlNode Stanza;
|
||||||
|
|||||||
Reference in New Issue
Block a user