Commit 2d7b0eae authored by dosuperuser's avatar dosuperuser

Minor refactoring

parent bee96d84
...@@ -340,12 +340,12 @@ public: ...@@ -340,12 +340,12 @@ public:
/// Serializes the state of this actor to `sink`. This function is /// Serializes the state of this actor to `sink`. This function is
/// only called if this actor has set the `is_serializable` flag. /// only called if this actor has set the `is_serializable` flag.
/// The default implementation throws a `std::logic_error`. /// The default implementation throws a `std::logic_error`.
virtual error save_state(serializer& sink, unsigned int version); virtual error save_state(serializer& sink, unsigned int version) const;
/// Deserializes the state of this actor from `source`. This function is /// Deserializes the state of this actor from `source`. This function is
/// only called if this actor has set the `is_serializable` flag. /// only called if this actor has set the `is_serializable` flag.
/// The default implementation throws a `std::logic_error`. /// The default implementation throws a `std::logic_error`.
virtual error load_state(deserializer& source, unsigned int version); virtual error load_state(deserializer& source, unsigned int version) const;
/// Returns the currently defined fail state. If this reason is not /// Returns the currently defined fail state. If this reason is not
/// `none` then the actor will terminate with this error after executing /// `none` then the actor will terminate with this error after executing
......
...@@ -54,7 +54,7 @@ struct literal { ...@@ -54,7 +54,7 @@ struct literal {
}; };
void parse(string_parser_state& ps, literal& x) { void parse(string_parser_state& ps, literal& x) {
CAF_ASSERT(x.str.size() > 0); CAF_ASSERT(!x.str.empty());
if (ps.current() != x.str[0]) { if (ps.current() != x.str[0]) {
ps.code = pec::unexpected_character; ps.code = pec::unexpected_character;
return; return;
......
...@@ -108,11 +108,11 @@ const char* local_actor::name() const { ...@@ -108,11 +108,11 @@ const char* local_actor::name() const {
return "actor"; return "actor";
} }
error local_actor::save_state(serializer&, const unsigned int) { error local_actor::save_state(serializer&, const unsigned int) const {
CAF_RAISE_ERROR("local_actor::serialize called"); CAF_RAISE_ERROR("local_actor::serialize called");
} }
error local_actor::load_state(deserializer&, const unsigned int) { error local_actor::load_state(deserializer&, const unsigned int) const {
CAF_RAISE_ERROR("local_actor::deserialize called"); CAF_RAISE_ERROR("local_actor::deserialize called");
} }
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
#include "caf/message.hpp" #include "caf/message.hpp"
#include <iostream>
#include <utility>
#include <utility> #include <utility>
#include "caf/actor_system.hpp" #include "caf/actor_system.hpp"
......
...@@ -215,7 +215,7 @@ void stream_manager::register_input_path(inbound_path* ptr) { ...@@ -215,7 +215,7 @@ void stream_manager::register_input_path(inbound_path* ptr) {
void stream_manager::deregister_input_path(inbound_path* ptr) noexcept { void stream_manager::deregister_input_path(inbound_path* ptr) noexcept {
CAF_ASSERT(ptr != nullptr); CAF_ASSERT(ptr != nullptr);
CAF_LOG_TRACE(CAF_ARG2("path", *ptr)); CAF_LOG_TRACE(CAF_ARG2("path", *ptr));
CAF_ASSERT(inbound_paths_.size() > 0); CAF_ASSERT(!inbound_paths_.empty());
using std::swap; using std::swap;
if (ptr != inbound_paths_.back()) { if (ptr != inbound_paths_.back()) {
auto i = std::find(inbound_paths_.begin(), inbound_paths_.end(), ptr); auto i = std::find(inbound_paths_.begin(), inbound_paths_.end(), ptr);
......
...@@ -74,5 +74,5 @@ CAF_TEST(test_serial_reply) { ...@@ -74,5 +74,5 @@ CAF_TEST(test_serial_reply) {
[&](const error& err) { [&](const error& err) {
CAF_ERROR("Error: " << self->system().render(err)); CAF_ERROR("Error: " << self->system().render(err));
}); });
CAF_REQUIRE(self->mailbox().size() == 0); CAF_REQUIRE(self->mailbox().empty());
} }
...@@ -243,7 +243,7 @@ error_code<sec> save_endpoint(ip_endpoint& ep, uint32_t& f, std::string& h, ...@@ -243,7 +243,7 @@ error_code<sec> save_endpoint(ip_endpoint& ep, uint32_t& f, std::string& h,
l = *ep.length(); l = *ep.length();
} else { } else {
f = 0; f = 0;
h = ""; h.clear();
p = 0; p = 0;
l = 0; l = 0;
} }
......
...@@ -116,9 +116,9 @@ void manager::init(actor_system_config&) { ...@@ -116,9 +116,9 @@ void manager::init(actor_system_config&) {
SSL_library_init(); SSL_library_init();
SSL_load_error_strings(); SSL_load_error_strings();
if (authentication_enabled()) { if (authentication_enabled()) {
if (system().config().openssl_certificate.size() == 0) if (system().config().openssl_certificate.empty())
CAF_RAISE_ERROR("No certificate configured for SSL endpoint"); CAF_RAISE_ERROR("No certificate configured for SSL endpoint");
if (system().config().openssl_key.size() == 0) if (system().config().openssl_key.empty())
CAF_RAISE_ERROR("No private key configured for SSL endpoint"); CAF_RAISE_ERROR("No private key configured for SSL endpoint");
} }
#if OPENSSL_VERSION_NUMBER < 0x10100000L #if OPENSSL_VERSION_NUMBER < 0x10100000L
...@@ -145,9 +145,9 @@ void* manager::subtype_ptr() { ...@@ -145,9 +145,9 @@ void* manager::subtype_ptr() {
bool manager::authentication_enabled() { bool manager::authentication_enabled() {
auto& cfg = system().config(); auto& cfg = system().config();
return cfg.openssl_certificate.size() > 0 || cfg.openssl_key.size() > 0 return !cfg.openssl_certificate.empty() || !cfg.openssl_key.empty()
|| cfg.openssl_passphrase.size() > 0 || cfg.openssl_capath.size() > 0 || !cfg.openssl_passphrase.empty() || !cfg.openssl_capath.empty()
|| cfg.openssl_cafile.size() > 0; || !cfg.openssl_cafile.empty();
} }
actor_system::module* manager::make(actor_system& sys, detail::type_list<>) { actor_system::module* manager::make(actor_system& sys, detail::type_list<>) {
......
...@@ -215,25 +215,25 @@ SSL_CTX* session::create_ssl_context() { ...@@ -215,25 +215,25 @@ SSL_CTX* session::create_ssl_context() {
if (sys_.openssl_manager().authentication_enabled()) { if (sys_.openssl_manager().authentication_enabled()) {
// Require valid certificates on both sides. // Require valid certificates on both sides.
auto& cfg = sys_.config(); auto& cfg = sys_.config();
if (cfg.openssl_certificate.size() > 0 if (!cfg.openssl_certificate.empty()
&& SSL_CTX_use_certificate_chain_file(ctx, && SSL_CTX_use_certificate_chain_file(ctx,
cfg.openssl_certificate.c_str()) cfg.openssl_certificate.c_str())
!= 1) != 1)
CAF_RAISE_ERROR("cannot load certificate"); CAF_RAISE_ERROR("cannot load certificate");
if (cfg.openssl_passphrase.size() > 0) { if (!cfg.openssl_passphrase.empty()) {
openssl_passphrase_ = cfg.openssl_passphrase; openssl_passphrase_ = cfg.openssl_passphrase;
SSL_CTX_set_default_passwd_cb(ctx, pem_passwd_cb); SSL_CTX_set_default_passwd_cb(ctx, pem_passwd_cb);
SSL_CTX_set_default_passwd_cb_userdata(ctx, this); SSL_CTX_set_default_passwd_cb_userdata(ctx, this);
} }
if (cfg.openssl_key.size() > 0 if (!cfg.openssl_key.empty()
&& SSL_CTX_use_PrivateKey_file(ctx, cfg.openssl_key.c_str(), && SSL_CTX_use_PrivateKey_file(ctx, cfg.openssl_key.c_str(),
SSL_FILETYPE_PEM) SSL_FILETYPE_PEM)
!= 1) != 1)
CAF_RAISE_ERROR("cannot load private key"); CAF_RAISE_ERROR("cannot load private key");
auto cafile auto cafile
= (cfg.openssl_cafile.size() > 0 ? cfg.openssl_cafile.c_str() : nullptr); = (!cfg.openssl_cafile.empty() ? cfg.openssl_cafile.c_str() : nullptr);
auto capath auto capath
= (cfg.openssl_capath.size() > 0 ? cfg.openssl_capath.c_str() : nullptr); = (!cfg.openssl_capath.empty() ? cfg.openssl_capath.c_str() : nullptr);
if (cafile || capath) { if (cafile || capath) {
if (SSL_CTX_load_verify_locations(ctx, cafile, capath) != 1) if (SSL_CTX_load_verify_locations(ctx, cafile, capath) != 1)
CAF_RAISE_ERROR("cannot load trusted CA certificates"); CAF_RAISE_ERROR("cannot load trusted CA certificates");
...@@ -270,7 +270,7 @@ SSL_CTX* session::create_ssl_context() { ...@@ -270,7 +270,7 @@ SSL_CTX* session::create_ssl_context() {
std::string session::get_ssl_error() { std::string session::get_ssl_error() {
std::string msg = ""; std::string msg = "";
while (auto err = ERR_get_error()) { while (auto err = ERR_get_error()) {
if (msg.size() > 0) if (!msg.empty())
msg += " "; msg += " ";
char buf[256]; char buf[256];
ERR_error_string_n(err, buf, sizeof(buf)); ERR_error_string_n(err, buf, sizeof(buf));
......
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