changeset 185:b5758826f5fc

Misc: style
author David Demelier <markand@malikania.fr>
date Wed, 01 Jun 2016 13:37:22 +0200
parents 0ff84eeea2b0
children b55435ce84be
files lib/irccd/fs.cpp lib/irccd/logger.cpp lib/irccd/mod-directory.cpp lib/irccd/mod-server.cpp lib/irccd/net.hpp lib/irccd/options.cpp lib/irccd/path.cpp lib/irccd/plugin-js.hpp lib/irccd/rule.cpp lib/irccd/server-state-connected.cpp lib/irccd/server.cpp lib/irccd/server.hpp lib/irccd/service-rule.hpp lib/irccd/service-transport.cpp lib/irccd/service-transport.hpp lib/irccd/service.hpp lib/irccd/signals.hpp lib/irccd/system.cpp lib/irccd/timer.cpp lib/irccd/timer.hpp lib/irccd/transport-server.cpp lib/irccd/util.cpp
diffstat 22 files changed, 216 insertions(+), 272 deletions(-) [+]
line wrap: on
line diff
--- a/lib/irccd/fs.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/fs.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -349,7 +349,6 @@
 				(void)::remove(path.c_str());
 		}
 	} catch (...) {
-		/* Silently discard to remove as much as possible */
 	}
 
 #if defined(_WIN32)
--- a/lib/irccd/logger.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/logger.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -68,7 +68,7 @@
 
 	void debug(std::string line)
 	{
-	/* Print only in debug mode, the buffer is flushed anyway */
+		// Print only in debug mode, the buffer is flushed anyway.
 #if !defined(NDEBUG)
 		iface->debug(filter->preDebug(std::move(line)));
 #else
@@ -78,10 +78,9 @@
 
 	void info(std::string line)
 	{
-		/* Print only if verbose, the buffer will be flushed anyway. */
-		if (verbose) {
+		// Print only if verbose, the buffer will be flushed anyway.
+		if (verbose)
 			iface->info(filter->preInfo(std::move(line)));
-		}
 	}
 
 	void warning(std::string line)
@@ -104,7 +103,7 @@
 		while ((pos = buffer.find("\n")) != std::string::npos) {
 			std::string line = buffer.substr(0, pos);
 
-			/* Remove this line */
+			// Remove this line.
 			buffer.erase(buffer.begin(), buffer.begin() + pos + 1);
 
 			switch (m_level) {
@@ -133,16 +132,12 @@
  * ------------------------------------------------------------------
  */
 
-/* Information buffer */
+// Buffers.
 Buffer bufferInfo{Buffer::Info};
-
-/* Warning buffer */
 Buffer bufferWarning{Buffer::Warning};
-
-/* Debug buffer */
 Buffer bufferDebug{Buffer::Debug};
 
-/* Stream outputs. */
+// Stream outputs.
 std::ostream streamInfo(&bufferInfo);
 std::ostream streamWarning(&bufferWarning);
 std::ostream streamDebug(&bufferDebug);
@@ -267,27 +262,24 @@
 
 std::ostream &info(const std::string &message)
 {
-	if (!message.empty()) {
+	if (!message.empty())
 		streamInfo << message << std::endl;
-	}
 
 	return streamInfo;
 }
 
 std::ostream &warning(const std::string &message)
 {
-	if (!message.empty()) {
+	if (!message.empty())
 		streamWarning << message << std::endl;
-	}
 
 	return streamWarning;
 }
 
 std::ostream &debug(const std::string &message)
 {
-	if (!message.empty()) {
+	if (!message.empty())
 		streamDebug << message << std::endl;
-	}
 
 	return streamDebug;
 }
--- a/lib/irccd/mod-directory.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/mod-directory.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -73,10 +73,9 @@
 	 */
 	auto entries = fs::readdir(base);
 
-	for (const auto &entry : entries) {
+	for (const auto &entry : entries)
 		if (entry.type != fs::Entry::Dir && pred(entry.name))
 			return base + entry.name;
-	}
 
 	if (!recursive)
 		return "";
--- a/lib/irccd/mod-server.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/mod-server.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -427,7 +427,6 @@
 	return 0;
 }
 
-
 /*
  * Function: Irccd.Server.add(s)
  * ------------------------------------------------------------------
--- a/lib/irccd/net.hpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/net.hpp	Wed Jun 01 13:37:22 2016 +0200
@@ -16,8 +16,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#ifndef NET_HPP
-#define NET_HPP
+#ifndef IRCCD_NET_HPP
+#define IRCCD_NET_HPP
 
 /**
  * \file net.hpp
@@ -4959,4 +4959,4 @@
 
 } // !net
 
-#endif // !NET_HPP
+#endif // !IRCCD_NET_HPP
--- a/lib/irccd/options.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/options.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -57,7 +57,7 @@
 	if (opt == definition.end())
 		throw InvalidOption(arg);
 
-	/* Need argument? */
+	// Need argument?
 	if (opt->second) {
 		if (it == end || isOption(*it))
 			throw MissingValue(arg);
@@ -121,7 +121,7 @@
 
 			if (opt->second) {
 				if (i == (len - 1)) {
-					/* End of string, get the next argument (see 2.) */
+					// End of string, get the next argument (see 2.).
 					if (++it == end || isOption(*it))
 						throw MissingValue(arg);
 
@@ -131,9 +131,8 @@
 					result.insert(std::make_pair(arg, value.substr(i + 1)));
 					i = len;
 				}
-			} else {
+			} else
 				result.insert(std::make_pair(arg, ""));
-			}
 		}
 
 		it = args.erase(args.begin(), args.begin() + toremove);
--- a/lib/irccd/path.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/path.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -84,15 +84,14 @@
 {
 	std::string result;
 	std::size_t size = MAX_PATH;
-	
+
 	result.resize(size);
-	
-	if (!(size = GetModuleFileNameA(nullptr, &result[0], size))) {
+
+	if (!(size = GetModuleFileNameA(nullptr, &result[0], size)))
 		throw std::runtime_error("GetModuleFileName error");
-	}
-	
+
 	result.resize(size);
-	
+
 	return result;
 }
 
@@ -101,17 +100,16 @@
 std::string executablePath()
 {
 	std::string result;
-	
+
 	result.resize(2048);
-	
+
 	auto size = readlink("/proc/self/exe", &result[0], 2048);
-	
-	if (size < 0) {
+
+	if (size < 0)
 		throw std::invalid_argument(std::strerror(errno));
-	}
-	
+
 	result.resize(size);
-	
+
 	return result;
 }
 
@@ -122,15 +120,14 @@
 	std::array<int, 4> mib{ { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 } };
 	std::string result;
 	std::size_t size = PATH_MAX + 1;
-	
+
 	result.resize(size);
-	
-	if (sysctl(mib.data(), 4, &result[0], &size, nullptr, 0) < 0) {
+
+	if (sysctl(mib.data(), 4, &result[0], &size, nullptr, 0) < 0)
 		throw std::runtime_error(std::strerror(errno));
-	}
-	
+
 	result.resize(size);
-	
+
 	return result;
 }
 
@@ -140,15 +137,14 @@
 {
 	std::string result;
 	std::size_t size = PROC_PIDPATHINFO_MAXSIZE;
-	
+
 	result.resize(size);
-	
-	if ((size = proc_pidpath(getpid(), &result[0], size)) == 0) {
+
+	if ((size = proc_pidpath(getpid(), &result[0], size)) == 0)
 		throw std::runtime_error(std::strerror(errno));
-	}
-	
+
 	result.resize(size);
-	
+
 	return result;
 }
 
@@ -234,9 +230,9 @@
 #if defined(IRCCD_SYSTEM_WINDOWS)
 	char path[MAX_PATH];
 
-	if (SHGetFolderPathA(nullptr, CSIDL_LOCAL_APPDATA, nullptr, 0, path) != S_OK) {
+	if (SHGetFolderPathA(nullptr, CSIDL_LOCAL_APPDATA, nullptr, 0, path) != S_OK)
 		oss << "";
-	} else {
+	else {
 		oss << path;
 		oss << "\\irccd\\config\\";
 	}
@@ -249,9 +245,8 @@
 	} catch (const std::exception &) {
 		const char *home = getenv("HOME");
 
-		if (home != nullptr) {
+		if (home != nullptr)
 			oss << home;
-		}
 
 		oss << "/.config/irccd/";
 	}
@@ -282,9 +277,9 @@
 #if defined(IRCCD_SYSTEM_WINDOWS)
 	char path[MAX_PATH];
 
-	if (SHGetFolderPathA(nullptr, CSIDL_LOCAL_APPDATA, nullptr, 0, path) != S_OK) {
+	if (SHGetFolderPathA(nullptr, CSIDL_LOCAL_APPDATA, nullptr, 0, path) != S_OK)
 		oss << "";
-	} else {
+	else {
 		oss << path;
 		oss << "\\irccd\\share";
 	}
@@ -297,9 +292,8 @@
 	} catch (const std::exception &) {
 		const char *home = getenv("HOME");
 
-		if (home != nullptr) {
+		if (home != nullptr)
 			oss << home;
-		}
 
 		oss << "/.local/share/irccd/";
 	}
@@ -342,9 +336,8 @@
 	} catch (const std::exception &) {
 		const char *home = getenv("HOME");
 
-		if (home != nullptr) {
+		if (home != nullptr)
 			oss << home;
-		}
 
 		oss << "/.cache/irccd/";
 	}
@@ -394,9 +387,9 @@
 	 * In the worst case use current working directory.
 	 */
 	if (base.empty()) {
-		if (fs::isAbsolute(argv0)) {
+		if (fs::isAbsolute(argv0))
 			base = argv0;
-		} else {
+		else {
 			std::string name = fs::baseName(argv0);
 
 			for (const auto &dir : util::split(sys::env("PATH"), std::string(1, Separator))) {
@@ -408,21 +401,19 @@
 				}
 			}
 
-			/* Not found in PATH? add dummy value */
-			if (base.empty()) {
+			// Not found in PATH? add dummy value.
+			if (base.empty())
 				base = std::string(".") + fs::separator() + WITH_BINDIR + fs::separator() + "dummy";
-			}
 		}
 	}
 
-	/* Find bin/<progname> */
+	// Find bin/<progname>.
 	auto pos = base.rfind(std::string(WITH_BINDIR) + fs::separator() + fs::baseName(base));
 
-	if (pos != std::string::npos) {
+	if (pos != std::string::npos)
 		base.erase(pos);
-	}
 
-	/* Add trailing / or \\ for convenience */
+	// Add trailing / or \\ for convenience.
 	base = clean(base);
 
 	assert(!base.empty());
@@ -430,22 +421,20 @@
 
 std::string clean(std::string input)
 {
-	if (input.empty()) {
+	if (input.empty())
 		return input;
-	}
 
-	/* First, remove any duplicates */
+	// First, remove any duplicates.
 	input.erase(std::unique(input.begin(), input.end(), [&] (char c1, char c2) {
 		return c1 == c2 && (c1 == '/' || c1 == '\\');
 	}), input.end());
 
-	/* Add a trailing / or \\ */
+	// Add a trailing / or \\.
 	char c = input[input.length() - 1];
-	if (c != '/' && c != '\\') {
+	if (c != '/' && c != '\\')
 		input += fs::separator();
-	}
 
-	/* Now converts all / to \\ for Windows and the opposite for Unix */
+	// Now converts all / to \\ for Windows and the opposite for Unix.
 #if defined(IRCCD_SYSTEM_WINDOWS)
 	std::replace(input.begin(), input.end(), '/', '\\');
 #else
--- a/lib/irccd/plugin-js.hpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/plugin-js.hpp	Wed Jun 01 13:37:22 2016 +0200
@@ -74,148 +74,148 @@
 	}
 
 	/**
-	* \copydoc Plugin::onCommand
-	*/
+	 * \copydoc Plugin::onCommand
+	 */
 	IRCCD_EXPORT void onCommand(Irccd &irccd,
-		const std::shared_ptr<Server> &server,
-		const std::string &origin,
-		const std::string &channel,
-		const std::string &message) override;
+				    const std::shared_ptr<Server> &server,
+				    const std::string &origin,
+				    const std::string &channel,
+				    const std::string &message) override;
 
 	/**
-	* \copydoc Plugin::onConnect
-	*/
+	 * \copydoc Plugin::onConnect
+	 */
 	IRCCD_EXPORT void onConnect(Irccd &irccd, const std::shared_ptr<Server> &server) override;
 
 	/**
-	* \copydoc Plugin::onChannelMode
-	*/
+	 * \copydoc Plugin::onChannelMode
+	 */
 	IRCCD_EXPORT void onChannelMode(Irccd &irccd,
-		const std::shared_ptr<Server> &server,
-		const std::string &origin,
-		const std::string &channel,
-		const std::string &mode,
-		const std::string &arg) override;
+					const std::shared_ptr<Server> &server,
+					const std::string &origin,
+					const std::string &channel,
+					const std::string &mode,
+					const std::string &arg) override;
 
 	/**
-	* \copydoc Plugin::onChannelNotice
-	*/
+	 * \copydoc Plugin::onChannelNotice
+	 */
 	IRCCD_EXPORT void onChannelNotice(Irccd &irccd,
-		const std::shared_ptr<Server> &server,
-		const std::string &origin,
-		const std::string &channel,
-		const std::string &notice) override;
+					  const std::shared_ptr<Server> &server,
+					  const std::string &origin,
+					  const std::string &channel,
+					  const std::string &notice) override;
 
 	/**
-	* \copydoc Plugin::onInvite
-	*/
+	 * \copydoc Plugin::onInvite
+	 */
 	IRCCD_EXPORT void onInvite(Irccd &irccd, const std::shared_ptr<Server> &server, const std::string &origin, const std::string &channel) override;
 
 	/**
-	* \copydoc Plugin::onJoin
-	*/
+	 * \copydoc Plugin::onJoin
+	 */
 	IRCCD_EXPORT void onJoin(Irccd &irccd, const std::shared_ptr<Server> &server, const std::string &origin, const std::string &channel) override;
 
 	/**
-	* \copydoc Plugin::onKick
-	*/
+	 * \copydoc Plugin::onKick
+	 */
 	IRCCD_EXPORT void onKick(Irccd &irccd,
-		const std::shared_ptr<Server> &server,
-		const std::string &origin,
-		const std::string &channel,
-		const std::string &target,
-		const std::string &reason) override;
+				 const std::shared_ptr<Server> &server,
+				 const std::string &origin,
+				 const std::string &channel,
+				 const std::string &target,
+				 const std::string &reason) override;
 
 	/**
-	* \copydoc Plugin::onLoad
-	*/
+	 * \copydoc Plugin::onLoad
+	 */
 	IRCCD_EXPORT void onLoad(Irccd &irccd) override;
 
 	/**
-	* \copydoc Plugin::onMessage
-	*/
+	 * \copydoc Plugin::onMessage
+	 */
 	IRCCD_EXPORT void onMessage(Irccd &irccd,
-		const std::shared_ptr<Server> &server,
-		const std::string &origin,
-		const std::string &channel,
-		const std::string &message) override;
+				    const std::shared_ptr<Server> &server,
+				    const std::string &origin,
+				    const std::string &channel,
+				    const std::string &message) override;
 
 	/**
-	* \copydoc Plugin::onMe
-	*/
+	 * \copydoc Plugin::onMe
+	 */
 	IRCCD_EXPORT void onMe(Irccd &irccd,
-		const std::shared_ptr<Server> &server,
-		const std::string &origin,
-		const std::string &channel,
-		const std::string &message) override;
+			       const std::shared_ptr<Server> &server,
+			       const std::string &origin,
+			       const std::string &channel,
+			       const std::string &message) override;
 
 	/**
-	* \copydoc Plugin::onMode
-	*/
+	 * \copydoc Plugin::onMode
+	 */
 	IRCCD_EXPORT void onMode(Irccd &irccd, const std::shared_ptr<Server> &server, const std::string &origin, const std::string &mode) override;
 
 	/**
-	* \copydoc Plugin::onNames
-	*/
+	 * \copydoc Plugin::onNames
+	 */
 	IRCCD_EXPORT void onNames(Irccd &irccd,
-		const std::shared_ptr<Server> &server,
-		const std::string &channel,
-		const std::vector<std::string> &list) override;
+				  const std::shared_ptr<Server> &server,
+				  const std::string &channel,
+				  const std::vector<std::string> &list) override;
 
 	/**
-	* \copydoc Plugin::onNick
-	*/
+	 * \copydoc Plugin::onNick
+	 */
 	IRCCD_EXPORT void onNick(Irccd &irccd, const std::shared_ptr<Server> &server, const std::string &origin, const std::string &nick) override;
 
 	/**
-	* \copydoc Plugin::onNotice
-	*/
+	 * \copydoc Plugin::onNotice
+	 */
 	IRCCD_EXPORT void onNotice(Irccd &irccd, const std::shared_ptr<Server> &server, const std::string &origin, const std::string &notice) override;
 
 	/**
-	* \copydoc Plugin::onPart
-	*/
+	 * \copydoc Plugin::onPart
+	 */
 	IRCCD_EXPORT void onPart(Irccd &irccd,
-		const std::shared_ptr<Server> &server,
-		const std::string &origin,
-		const std::string &channel,
-		const std::string &reason) override;
+				 const std::shared_ptr<Server> &server,
+				 const std::string &origin,
+				 const std::string &channel,
+				 const std::string &reason) override;
 
 	/**
-	* \copydoc Plugin::onQuery
-	*/
+	 * \copydoc Plugin::onQuery
+	 */
 	IRCCD_EXPORT void onQuery(Irccd &irccd, const std::shared_ptr<Server> &server, const std::string &origin, const std::string &message) override;
 
 	/**
-	* \copydoc Plugin::onQueryCommand
-	*/
+	 * \copydoc Plugin::onQueryCommand
+	 */
 	IRCCD_EXPORT void onQueryCommand(Irccd &irccd,
-		const std::shared_ptr<Server> &server,
-		const std::string &origin,
-		const std::string &message) override;
+			    const std::shared_ptr<Server> &server,
+			    const std::string &origin,
+			    const std::string &message) override;
 
 	/**
-	* \copydoc Plugin::onReload
-	*/
+	 * \copydoc Plugin::onReload
+	 */
 	IRCCD_EXPORT void onReload(Irccd &irccd) override;
 
 	/**
-	* \copydoc Plugin::onTopic
-	*/
+	 * \copydoc Plugin::onTopic
+	 */
 	IRCCD_EXPORT void onTopic(Irccd &irccd,
-		const std::shared_ptr<Server> &server,
-		const std::string &origin,
-		const std::string &channel,
-		const std::string &topic) override;
+				  const std::shared_ptr<Server> &server,
+				  const std::string &origin,
+				  const std::string &channel,
+				  const std::string &topic) override;
 
 	/**
-	* \copydoc Plugin::onUnload
-	*/
+	 * \copydoc Plugin::onUnload
+	 */
 	IRCCD_EXPORT void onUnload(Irccd &irccd) override;
 
 	/**
-	* \copydoc Plugin::onWhois
-	*/
+	 * \copydoc Plugin::onWhois
+	 */
 	IRCCD_EXPORT void onWhois(Irccd &irccd, const std::shared_ptr<Server> &server, const ServerWhois &info) override;
 };
 
--- a/lib/irccd/rule.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/rule.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -63,11 +63,9 @@
 	, m_events(std::move(events))
 	, m_action(action)
 {
-	for (const std::string &n : m_events) {
-		if (validEvents.count(n) == 0) {
+	for (const std::string &n : m_events)
+		if (validEvents.count(n) == 0)
 			throw std::invalid_argument(n + " is not a valid event name");
-		}
-	}
 }
 
 bool Rule::match(const std::string &server,
--- a/lib/irccd/server-state-connected.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/server-state-connected.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -36,9 +36,8 @@
 	if (!irc_is_connected(server.session())) {
 		log::warning() << "server " << server.name() << ": disconnected" << std::endl;
 
-		if (settings.reconnectDelay > 0) {
+		if (settings.reconnectDelay > 0)
 			log::warning("server {}: retrying in {} seconds"_format(server.name(), settings.reconnectDelay));
-		}
 
 		server.next(std::make_unique<state::Disconnected>());
 	} else if (server.cache().pingTimer.elapsed() >= settings.pingTimeout * 1000) {
--- a/lib/irccd/server.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/server.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -57,13 +57,12 @@
  */
 std::string cleanPrefix(const ServerInfo &info, std::string nickname)
 {
-	if (nickname.length() > 0) {
-		for (const auto &pair : info.modes) {
-			if (nickname[0] == pair.second) {
-				nickname.erase(0, 1);
-			}
-		}
-	}
+	if (nickname.length() == 0)
+		return nickname;
+
+	for (const auto &pair : info.modes)
+		if (nickname[0] == pair.second)
+			nickname.erase(0, 1);
 
 	return nickname;
 }
@@ -80,30 +79,27 @@
 	std::string buf = line.substr(7);
 	std::map<ServerChanMode, char> modes;
 
-	for (int i = 0; i < 16; ++i) {
+	for (int i = 0; i < 16; ++i)
 		table[i] = std::make_pair(-1, -1);
-	}
 
 	int j = 0;
 	bool readModes = true;
 	for (size_t i = 0; i < buf.size(); ++i) {
-		if (buf[i] == '(') {
+		if (buf[i] == '(')
 			continue;
-		}
 		if (buf[i] == ')') {
 			j = 0;
 			readModes = false;
 			continue;
 		}
 
-		if (readModes) {
+		if (readModes)
 			table[j++].first = buf[i];
-		} else {
+		else
 			table[j++].second = buf[i];
-		}
 	}
 
-	/* Put these as a map of mode to prefix */
+	// Put these as a map of mode to prefix.
 	for (int i = 0; i < 16; ++i) {
 		auto key = static_cast<ServerChanMode>(table[i].first);
 		auto value = table[i].second;
@@ -118,17 +114,17 @@
 
 void Server::handleConnect(const char *, const char **) noexcept
 {
-	/* Reset the number of tried reconnection. */
+	// Reset the number of tried reconnection.
 	m_cache.reconnectCurrent = 0;
 
-	/* Reset the timer. */
+	// Reset the timer.
 	m_cache.pingTimer.reset();
 
-	/* Don't forget to change state and notify. */
+	// Don't forget to change state and notify.
 	next(std::make_unique<state::Connected>());
 	onConnect();
 
-	/* Auto join listed channels. */
+	// Auto join listed channels.
 	for (const ServerChannel &channel : m_settings.channels) {
 		log::info() << "server " << m_name << ": auto joining " << channel.name << std::endl;
 		join(channel.name, channel.password);
@@ -157,10 +153,9 @@
 
 void Server::handleInvite(const char *orig, const char **params) noexcept
 {
-	/* If joininvite is set, join the channel */
-	if ((m_settings.flags & ServerSettings::JoinInvite) && isSelf(strify(params[0]))) {
+	// If joininvite is set, join the channel.
+	if ((m_settings.flags & ServerSettings::JoinInvite) && isSelf(strify(params[0])))
 		join(strify(params[1]));
-	}
 
 	/*
 	 * The libircclient says that invite contains the target nickname, it's quite
@@ -177,10 +172,9 @@
 
 void Server::handleKick(const char *orig, const char **params) noexcept
 {
-	/* Rejoin the channel if the option has been set and I was kicked. */
-	if ((m_settings.flags & ServerSettings::AutoRejoin) && isSelf(strify(params[1]))) {
+	// Rejoin the channel if the option has been set and I was kicked.
+	if ((m_settings.flags & ServerSettings::AutoRejoin) && isSelf(strify(params[1])))
 		join(strify(params[0]));
-	}
 
 	onKick(strify(orig), strify(params[0]), strify(params[1]), strify(params[2]));
 }
@@ -192,19 +186,16 @@
 
 void Server::handleNick(const char *orig, const char **params) noexcept
 {
-	/* Update our nickname. */
-	if (isSelf(strify(orig))) {
+	// Update our nickname.
+	if (isSelf(strify(orig)))
 		m_identity.nickname = strify(params[0]);
-	}
 
 	onNick(strify(orig), strify(params[0]));
 }
 
 void Server::handleNotice(const char *orig, const char **params) noexcept
 {
-	/*
-	 * As for handleInvite, the notice provides the target nickname, we discard it.
-	 */
+	// Like handleInvite, the notice provides the target nickname, we discard it.
 	onNotice(strify(orig), strify(params[1]));
 }
 
@@ -221,16 +212,14 @@
 		 *
 		 * IDEA for the future: maybe give the appropriate mode as a second parameter in onNames.
 		 */
-		if (c < 4 || params[2] == nullptr || params[3] == nullptr) {
+		if (c < 4 || params[2] == nullptr || params[3] == nullptr)
 			return;
-		}
 
 		std::vector<std::string> users = util::split(params[3], " \t");
 
-		/* The listing may add some prefixes, remove them if needed */
-		for (std::string u : users) {
+		// The listing may add some prefixes, remove them if needed.
+		for (std::string u : users)
 			m_cache.namesMap[params[2]].insert(cleanPrefix(m_info, u));
-		}
 	} else if (event == LIBIRC_RFC_RPL_ENDOFNAMES) {
 		/*
 		 * Called when end of name listing has finished on a channel.
@@ -239,16 +228,14 @@
 		 * params[1] == channel
 		 * params[2] == End of NAMES list
 		 */
-
-		if (c < 3 || params[1] == nullptr) {
+		if (c < 3 || params[1] == nullptr)
 			return;
-		}
 
 		auto it = m_cache.namesMap.find(params[1]);
 		if (it != m_cache.namesMap.end()) {
 			onNames(params[1], it->second);
 
-			/* Don't forget to remove the list */
+			// Don't forget to remove the list.
 			m_cache.namesMap.erase(it);
 		}
 	} else if (event == LIBIRC_RFC_RPL_WHOISUSER) {
@@ -262,9 +249,8 @@
 		 * params[4] == * (no idea what is that)
 		 * params[5] == realname
 		 */
-		if (c < 6 || !params[1] || !params[2] || !params[3] || !params[5]) {
+		if (c < 6 || !params[1] || !params[2] || !params[3] || !params[5])
 			return;
-		}
 
 		ServerWhois info;
 
@@ -282,20 +268,17 @@
 		 * params[1] == nickname
 		 * params[2] == list of channels with their prefixes
 		 */
-		if (c < 3 || !params[1] || !params[2]) {
+		if (c < 3 || !params[1] || !params[2])
 			return;
-		}
 
 		auto it = m_cache.whoisMap.find(params[1]);
 		if (it != m_cache.whoisMap.end()) {
 			std::vector<std::string> channels = util::split(params[2], " \t");
 
-			/* Clean their prefixes */
-			for (auto &s : channels) {
+			// Clean their prefixes.
+			for (auto &s : channels)
 				s = cleanPrefix(m_info, s);
-			}
 
-			/* Insert */
 			it->second.channels = std::move(channels);
 		}
 	} else if (event == LIBIRC_RFC_RPL_ENDOFWHOIS) {
@@ -306,12 +289,11 @@
 		 * params[1] == nickname
 		 * params[2] == End of WHOIS list
 		 */
-
 		auto it = m_cache.whoisMap.find(params[1]);
 		if (it != m_cache.whoisMap.end()) {
 			onWhois(it->second);
 
-			/* Don't forget to remove */
+			// Don't forget to remove.
 			m_cache.whoisMap.erase(it);
 		}
 	} else if (event == /* RPL_BOUNCE */ 5) {
@@ -334,10 +316,10 @@
 
 void Server::handlePing(const char *, const char **params) noexcept
 {
-	/* Reset the timer to detect disconnection. */
+	// Reset the timer to detect disconnection.
 	m_cache.pingTimer.reset();
 
-	/* Don't forget to respond */
+	// Don't forget to respond.
 	send("PONG {}"_format(params[0]));
 }
 
@@ -355,9 +337,8 @@
 {
 	auto pos = value.find(':');
 
-	if (pos != std::string::npos) {
+	if (pos != std::string::npos)
 		return ServerChannel{value.substr(0, pos), value.substr(pos + 1)};
-	}
 
 	return ServerChannel{value, ""};
 }
@@ -435,7 +416,7 @@
 
 	m_session->handle() = Session::Handle{irc_create_session(&callbacks), irc_destroy_session};
 
-	/* Save this to the session */
+	// Save this to the session.
 	irc_set_ctx(*m_session, this);
 	irc_set_ctcp_version(*m_session, m_identity.ctcpversion.c_str());
 }
@@ -480,14 +461,13 @@
 	bool done = false;
 
 	while (!m_queue.empty() && !done) {
-		if (m_queue.front()()) {
+		if (m_queue.front()())
 			m_queue.pop();
-		} else {
+		else
 			done = true;
-		}
 	}
 
-	/* 2. Read data */
+	// 2. Read data.
 	irc_process_select_descriptors(*m_session, &setinput, &setoutput);
 }
 
@@ -582,9 +562,8 @@
 void Server::part(std::string channel, std::string reason)
 {
 	m_queue.push([=] () -> bool {
-		if (reason.empty()) {
+		if (reason.empty())
 			return irc_cmd_part(*m_session, channel.c_str()) == 0;
-		}
 
 		return irc_send_raw(*m_session, "PART %s :%s", channel.c_str(), reason.c_str());
 	});
--- a/lib/irccd/server.hpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/server.hpp	Wed Jun 01 13:37:22 2016 +0200
@@ -148,13 +148,13 @@
 /**
  * \brief The class that connect to a IRC server
  *
- * The server is a class that stores callbacks which will be called on IRC events. It is the lowest part of the
- * connection to a server, it can be used directly by the user to connect to a server.
+ * The server is a class that stores callbacks which will be called on IRC events. It is the lowest part of the connection to a server, it
+ * can be used directly by the user to connect to a server.
  *
  * The server has several signals that will be emitted when data has arrived.
  *
- * When adding a server to the irccd instance using Irccd::addServer, these signals are connected to generate
- * events that will be dispatched to the plugins and to the transports.
+ * When adding a server to the ServerService in irccd, these signals are connected to generate events that will be dispatched to the plugins
+ * and to the transports.
  *
  * Note: the server is set in non blocking mode, commands are placed in a queue and sent when only when they are ready.
  */
--- a/lib/irccd/service-rule.hpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/service-rule.hpp	Wed Jun 01 13:37:22 2016 +0200
@@ -54,7 +54,7 @@
 	 *
 	 * \return the number of rules
 	 */
-	inline unsigned length() const noexcept
+	inline std::size_t length() const noexcept
 	{
 		return m_rules.size();
 	}
--- a/lib/irccd/service-transport.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/service-transport.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -41,7 +41,7 @@
 		// 1. Check if the Json object is valid.
 		auto name = object.find("command");
 		if (name == object.end() || name->typeOf() != json::Type::String) {
-			// TODO: send error
+			// TODO: send error.
 			log::warning("invalid command object");
 			return;
 		}
@@ -50,7 +50,7 @@
 		auto cmd = m_irccd.commandService().find(name->toString());
 
 		if (!cmd) {
-			// TODO: send error again
+			// TODO: send error again.
 			log::warning("command does not exists");
 			return;
 		}
@@ -157,9 +157,8 @@
 	}
 
 	// Transport clients.
-	for (const auto &client : m_clients) {
+	for (const auto &client : m_clients)
 		client->sync(in, out);
-	}
 }
 
 void TransportService::add(std::shared_ptr<TransportServer> ts)
--- a/lib/irccd/service-transport.hpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/service-transport.hpp	Wed Jun 01 13:37:22 2016 +0200
@@ -82,7 +82,6 @@
 	 * \param data the data
 	 */
 	IRCCD_EXPORT void broadcast(std::string data);
-
 };
 
 } // !irccd
--- a/lib/irccd/service.hpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/service.hpp	Wed Jun 01 13:37:22 2016 +0200
@@ -40,11 +40,9 @@
  *
  * This class can be used to prepare a set of sockets that will be selected by Irccd class.
  *
- * First, the function prepare is called, the user is responsible to fill the input and output set and adjust max
- * accordingly.
+ * First, the function prepare is called, the user is responsible to fill the input and output set and adjust max accordingly.
  *
- * Second, after select has been called, sync is called. The user is responsible of checking which sockets are ready
- * for input or output.
+ * Second, after select has been called, sync is called. The user is responsible of checking which sockets are ready for input or output.
  */
 class Service {
 public:
--- a/lib/irccd/signals.hpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/signals.hpp	Wed Jun 01 13:37:22 2016 +0200
@@ -35,9 +35,8 @@
  * \class SignalConnection
  * \brief Stores the reference to the callable
  *
- * This class can be stored to remove a registered function from a Signal, be
- * careful to not mix connections between different signals as they are just
- * referenced by ids.
+ * This class can be stored to remove a registered function from a Signal, be careful to not mix connections between different signals as
+ * they are just referenced by ids.
  */
 class SignalConnection {
 private:
@@ -148,8 +147,7 @@
 	void operator()(Args... args) const
 	{
 		/*
-		 * Make a copy of the ids before iterating because the callbacks may eventually remove or modify
-		 * the list.
+		 * Make a copy of the ids before iterating because the callbacks may eventually remove or modify the list.
 		 */
 		std::vector<unsigned> ids;
 
@@ -157,8 +155,8 @@
 			ids.push_back(pair.first);
 
 		/*
-		 * Now iterate while checking if the next id is still available, however if any new signals were
-		 * added while iterating, they will not be called immediately.
+		 * Now iterate while checking if the next id is still available, however if any new signals were added while iterating, they
+		 * will not be called immediately.
 		 */
 		for (unsigned i : ids) {
 			auto it = m_functions.find(i);
--- a/lib/irccd/system.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/system.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -89,11 +89,11 @@
  *
  * Finally, when the id is resolved, the setter function (setuid, setgid) will be called.
  *
- * @param typeName the type of id (uid or gid)
- * @param value the value (numeric or name)
- * @param lookup the lookup function to resolve the name (getpwnam or getgrnam)
- * @param setter the function to apply the id (setuid or setgid)
- * @param getter the function to get the id from the informal structure
+ *   - typeName the type of id (uid or gid)
+ *   - value the value (numeric or name)
+ *   - lookup the lookup function to resolve the name (getpwnam or getgrnam)
+ *   - setter the function to apply the id (setuid or setgid)
+ *   - getter the function to get the id from the informal structure
  */
 template <typename IntType, typename LookupFunc, typename SetterFunc, typename FieldGetter>
 void setHelper(const std::string &typeName, const std::string &value, LookupFunc lookup, SetterFunc setter, FieldGetter getter)
@@ -203,7 +203,6 @@
 
 	return difftime(csec, bsec);
 #else
-	// BSD.
 	struct timespec ts;
 
 	if (clock_gettime(CLOCK_UPTIME, &ts) < 0)
--- a/lib/irccd/timer.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/timer.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -28,27 +28,25 @@
 	while (m_state != Stopped) {
 		std::unique_lock<std::mutex> lock(m_mutex);
 
-		/* Wait in case the timer is paused */
+		// Wait in case the timer is paused.
 		m_condition.wait(lock, [&] () {
 			return m_state != Paused;
 		});
 
-		if (m_state != Running) {
+		if (m_state != Running)
 			continue;
-		}
 
-		/* Wait the timer delay or the interrupt */
+		// Wait the timer delay or the interrupt.
 		m_condition.wait_for(lock, std::chrono::milliseconds(m_delay), [&] () {
 			return m_state != Running;
 		});
 
 		if (m_state == Running) {
-			/* Signal process */
+			// Signal process.
 			onSignal();
 
-			if (m_type == TimerType::Single) {
+			if (m_type == TimerType::Single)
 				m_state = Stopped;
-			}
 		}
 	}
 
@@ -58,7 +56,7 @@
 Timer::Timer(TimerType type, unsigned delay) noexcept
 	: m_type(type)
 	, m_delay(delay)
-	, m_thread([this] () { run(); })
+	, m_thread(std::bind(&Timer::run, this))
 {
 }
 
--- a/lib/irccd/timer.hpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/timer.hpp	Wed Jun 01 13:37:22 2016 +0200
@@ -85,7 +85,7 @@
 	TimerType m_type;
 	unsigned m_delay;
 
-	/* Thread management */
+	// Thread management.
 	std::atomic<int> m_state{Paused};
 	std::mutex m_mutex;
 	std::condition_variable m_condition;
--- a/lib/irccd/transport-server.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/transport-server.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -37,7 +37,7 @@
 TransportServerIp::TransportServerIp(int domain, const std::string &address, int port, bool ipv6only)
 	: m_socket(domain, SOCK_STREAM, 0)
 {
-	m_socket.set(net::option::SockReuseAddress{true});
+	m_socket.set(net::option::SockReuseAddress(true));
 
 	// Disable or enable IPv4 when using IPv6.
 	if (domain == AF_INET6)
--- a/lib/irccd/util.cpp	Wed Jun 01 12:48:04 2016 +0200
+++ b/lib/irccd/util.cpp	Wed Jun 01 13:37:22 2016 +0200
@@ -310,7 +310,7 @@
 std::vector<std::string> split(const std::string &list, const std::string &delimiters, int max)
 {
 	std::vector<std::string> result;
-	size_t next = -1, current;
+	std::size_t next = -1, current;
 	int count = 1;
 	bool finished = false;
 
@@ -383,11 +383,11 @@
 {
 	if (str.empty())
 		return false;
-	
+
 	char *ptr;
-	
+
 	std::strtol(str.c_str(), &ptr, base);
-	
+
 	return *ptr == 0;
 }
 
@@ -395,11 +395,11 @@
 {
 	if (str.empty())
 		return false;
-	
+
 	char *ptr;
-	
+
 	std::strtod(str.c_str(), &ptr);
-	
+
 	return *ptr == 0;
 }