Commit 2d7b0eae authored by dosuperuser's avatar dosuperuser

Minor refactoring

parent bee96d84
......@@ -340,12 +340,12 @@ public:
/// Serializes the state of this actor to `sink`. This function is
/// only called if this actor has set the `is_serializable` flag.
/// 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
/// only called if this actor has set the `is_serializable` flag.
/// 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
/// `none` then the actor will terminate with this error after executing
......
......@@ -54,7 +54,7 @@ struct literal {
};
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]) {
ps.code = pec::unexpected_character;
return;
......
......@@ -108,11 +108,11 @@ const char* local_actor::name() const {
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");
}
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");
}
......
......@@ -18,8 +18,6 @@
#include "caf/message.hpp"
#include <iostream>
#include <utility>
#include <utility>
#include "caf/actor_system.hpp"
......
......@@ -215,7 +215,7 @@ void stream_manager::register_input_path(inbound_path* ptr) {
void stream_manager::deregister_input_path(inbound_path* ptr) noexcept {
CAF_ASSERT(ptr != nullptr);
CAF_LOG_TRACE(CAF_ARG2("path", *ptr));
CAF_ASSERT(inbound_paths_.size() > 0);
CAF_ASSERT(!inbound_paths_.empty());
using std::swap;
if (ptr != inbound_paths_.back()) {
auto i = std::find(inbound_paths_.begin(), inbound_paths_.end(), ptr);
......
......@@ -74,5 +74,5 @@ CAF_TEST(test_serial_reply) {
[&](const error& 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,
l = *ep.length();
} else {
f = 0;
h = "";
h.clear();
p = 0;
l = 0;
}
......
......@@ -116,9 +116,9 @@ void manager::init(actor_system_config&) {
SSL_library_init();
SSL_load_error_strings();
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");
if (system().config().openssl_key.size() == 0)
if (system().config().openssl_key.empty())
CAF_RAISE_ERROR("No private key configured for SSL endpoint");
}
#if OPENSSL_VERSION_NUMBER < 0x10100000L
......@@ -145,9 +145,9 @@ void* manager::subtype_ptr() {
bool manager::authentication_enabled() {
auto& cfg = system().config();
return cfg.openssl_certificate.size() > 0 || cfg.openssl_key.size() > 0
|| cfg.openssl_passphrase.size() > 0 || cfg.openssl_capath.size() > 0
|| cfg.openssl_cafile.size() > 0;
return !cfg.openssl_certificate.empty() || !cfg.openssl_key.empty()
|| !cfg.openssl_passphrase.empty() || !cfg.openssl_capath.empty()
|| !cfg.openssl_cafile.empty();
}
actor_system::module* manager::make(actor_system& sys, detail::type_list<>) {
......
......@@ -215,25 +215,25 @@ SSL_CTX* session::create_ssl_context() {
if (sys_.openssl_manager().authentication_enabled()) {
// Require valid certificates on both sides.
auto& cfg = sys_.config();
if (cfg.openssl_certificate.size() > 0
if (!cfg.openssl_certificate.empty()
&& SSL_CTX_use_certificate_chain_file(ctx,
cfg.openssl_certificate.c_str())
!= 1)
CAF_RAISE_ERROR("cannot load certificate");
if (cfg.openssl_passphrase.size() > 0) {
if (!cfg.openssl_passphrase.empty()) {
openssl_passphrase_ = cfg.openssl_passphrase;
SSL_CTX_set_default_passwd_cb(ctx, pem_passwd_cb);
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_FILETYPE_PEM)
!= 1)
CAF_RAISE_ERROR("cannot load private key");
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
= (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 (SSL_CTX_load_verify_locations(ctx, cafile, capath) != 1)
CAF_RAISE_ERROR("cannot load trusted CA certificates");
......@@ -270,7 +270,7 @@ SSL_CTX* session::create_ssl_context() {
std::string session::get_ssl_error() {
std::string msg = "";
while (auto err = ERR_get_error()) {
if (msg.size() > 0)
if (!msg.empty())
msg += " ";
char buf[256];
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