~singpolyma/biboumi

720e31a5113c25e48d7754bb812ab84c6c31d1d9 — Florent Le Coz 7 years ago 0ab5ece
Fix a few issues reported by static analyzers
M src/bridge/bridge.cpp => src/bridge/bridge.cpp +1 -1
@@ 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);
}

M src/bridge/bridge.hpp => src/bridge/bridge.hpp +1 -1
@@ 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
   */

M src/bridge/colors.cpp => src/bridge/colors.cpp +0 -2
@@ 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;

M src/config/config.cpp => src/config/config.cpp +0 -7
@@ 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();

M src/config/config.hpp => src/config/config.hpp +0 -8
@@ 53,14 53,6 @@ public:
   */
  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.
   */

M src/irc/irc_channel.cpp => src/irc/irc_channel.cpp +1 -1
@@ 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();

M src/irc/irc_channel.hpp => src/irc/irc_channel.hpp +1 -1
@@ 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();

M src/network/poller.cpp => src/network/poller.cpp +1 -1
@@ 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());

M src/test.cpp => src/test.cpp +1 -1
@@ 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());

  /**

M src/utils/encoding.cpp => src/utils/encoding.cpp +1 -0
@@ 197,6 197,7 @@ namespace utils
              case E2BIG:
                // This should never happen
                done = true;
                break;
              default:
                // This should happen even neverer
                done = true;

M src/xmpp/adhoc_commands_handler.cpp => src/xmpp/adhoc_commands_handler.cpp +2 -2
@@ 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)

M src/xmpp/adhoc_commands_handler.hpp => src/xmpp/adhoc_commands_handler.hpp +1 -1
@@ 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

M src/xmpp/xmpp_component.cpp => src/xmpp/xmpp_component.cpp +0 -1
@@ 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"); }));

M src/xmpp/xmpp_stanza.hpp => src/xmpp/xmpp_stanza.hpp +1 -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;