Skip to content

Commit a998bae

Browse files
committed
(cont) Typo and minor style fixes similar to recent ones.
1 parent b7bd40b commit a998bae

File tree

16 files changed

+53
-31
lines changed

16 files changed

+53
-31
lines changed

src/flow/cfg/option_set.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ class Option_set_base
382382
*
383383
* ### Recommended conventions ###
384384
* Firstly, it is recommended to store all durations in your `Value_set` as util::Fine_duration instead of using
385-
* coarser units like `chrono::seconds()` or even `chrono::milliseconds()`. This tends to lead to more consistent
385+
* coarser units like `chrono::seconds` or even `chrono::milliseconds`. This tends to lead to more consistent
386386
* and maintainable code, in the author's (ygoldfel) opinion, as util::Fine_duration *can* store durations expressed
387387
* in essentially any units, without losing precision; *does* use the same underlying storage type -- `int64_t` --
388388
* and hence presents no performance or overflow difficulties (usually); and changing the desired units of a duration

src/flow/error/error.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ Runtime_error::Runtime_error(const Error_code& err_code_or_success, util::String
2727
// This strange-looking dichotomy is explained in ###Rationale### in m_context_if_no_code doc header.
2828
boost::system::system_error(err_code_or_success,
2929
err_code_or_success
30-
? std::string(context)
31-
: std::string()),
30+
? std::string{context}
31+
: std::string{}),
3232
// code() == err_code_or_success, now.
3333
m_context_if_no_code(code()
34-
? std::string()
35-
: std::string(context))
34+
? std::string{}
35+
: std::string{context})
3636
{
3737
// Nothing.
3838
}
3939

4040
Runtime_error::Runtime_error(util::String_view context) :
41-
Runtime_error(Error_code(), context) // Our formal contract is to be equivalent to this.
41+
Runtime_error(Error_code{}, context) // Our formal contract is to be equivalent to this.
4242
{
4343
// Nothing.
4444
}

src/flow/error/error.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace flow::error
3737
* ### Rationale ###
3838
* It is questionable whether Runtime_error is really necessary. One can equally well simply throw
3939
* `boost::system::system_error(err_code, context)` when `bool(err_code) == true`, and
40-
* `std::runtime_error(context)` otherwise. Indeed the user should feel 100% free to do that if desired.
40+
* `std::runtime_error{context}` otherwise. Indeed the user should feel 100% free to do that if desired.
4141
* flow::error::Runtime_error is mere syntactic sugar for code brevity, when one indeed has an `err_code` that may
4242
* or may not be falsy: they can just construct+throw a Runtime_error and not worry about the bifurcation.
4343
* In the end one likely just catches `std::exception exc` and logs/prints `exc.what()`: how precisely it was thrown

src/flow/log/buffer_logger.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ bool Buffer_logger::logs_asynchronously() const // Virtual.
4444
void Buffer_logger::do_log(Msg_metadata* metadata, util::String_view msg) // Virtual.
4545
{
4646
// Prevent simultaneous logging, reading-by-copy.
47-
util::Lock_guard<decltype(m_log_mutex)> lock(m_log_mutex);
47+
util::Lock_guard<decltype(m_log_mutex)> lock{m_log_mutex};
4848

4949
// m_os_writer wraps (as of this writing) String_ostream, which wraps std::string. Write msg+metadata to std::string.
5050
m_os_writer.log(*metadata, msg);
@@ -58,7 +58,7 @@ const std::string& Buffer_logger::buffer_str() const
5858
const std::string Buffer_logger::buffer_str_copy() const
5959
{
6060
// Prevent simultaneous logging, reading.
61-
util::Lock_guard<decltype(m_log_mutex)> lock(m_log_mutex);
61+
util::Lock_guard<decltype(m_log_mutex)> lock{m_log_mutex};
6262

6363
return buffer_str(); // Copy occurs here; then mutex is unlocked.
6464
}

src/flow/log/simple_ostream_logger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void Simple_ostream_logger::do_log(Msg_metadata* metadata, util::String_view msg
6666
* line, for example. So it still seems best to avoid any interleaving even when it's further away from our control,
6767
* as in that latter situation. So just don't mess with it and always use one mutex to avoid as much interleaving
6868
* as we can. */
69-
util::Lock_guard<decltype(m_log_mutex)> lock(m_log_mutex);
69+
util::Lock_guard<decltype(m_log_mutex)> lock{m_log_mutex};
7070

7171
/* This next part will block calling thread for however long the writing takes.
7272
* This is likely not an issue with cout/cerr but can be a significant issue with ofstream. Hence why

src/flow/net_flow/asio/server_socket.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ void Server_socket::async_accept(const Handler& on_result)
275275
template<typename Handler>
276276
void Server_socket::async_accept(bool reactor_pattern, const Handler& on_result)
277277
{
278-
async_accept_impl(Handler_func(on_result), Fine_time_pt{}, reactor_pattern);
278+
async_accept_impl(Handler_func{on_result}, Fine_time_pt{}, reactor_pattern);
279279
}
280280

281281
template<typename Rep, typename Period, typename Handler>

src/flow/net_flow/detail/cong_ctl/cong_ctl_classic_bw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace flow::net_flow
2424

2525
// Use conservative start value which will be overridden with the next ACK. (Value taken from Linux tcp_westwood.c.)
2626
const Send_bandwidth_estimator::Time_unit Congestion_control_classic_with_bandwidth_est::S_INIT_RTT_MIN
27-
= boost::chrono::seconds(20);
27+
= boost::chrono::seconds{20};
2828

2929
// Implementations.
3030

src/flow/net_flow/event_set.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,7 @@ bool Event_set::sync_wait_impl(const Fine_duration& max_wait, Error_code* err_co
456456

457457
bool Event_set::sync_wait(Error_code* err_code)
458458
{
459-
using boost::chrono::microseconds;
460-
return sync_wait(microseconds(microseconds::max()), err_code); // Wait indefinitely. May throw.
459+
return sync_wait(boost::chrono::microseconds::max(), err_code); // Wait indefinitely. May throw.
461460
}
462461

463462
void Event_set::close(Error_code* err_code)
@@ -736,9 +735,9 @@ Event_set::Ev_type_to_socks_map Event_set::empty_ev_type_to_socks_map() // Stati
736735
return Ev_type_to_socks_map
737736
{{
738737
// Linked_hash_map order is significant. Iteration will occur in this canonical order in logs, etc.
739-
{ Event_type::S_PEER_SOCKET_READABLE, Sockets() },
740-
{ Event_type::S_PEER_SOCKET_WRITABLE, Sockets() },
741-
{ Event_type::S_SERVER_SOCKET_ACCEPTABLE, Sockets() }
738+
{ Event_type::S_PEER_SOCKET_READABLE, Sockets{} },
739+
{ Event_type::S_PEER_SOCKET_WRITABLE, Sockets{} },
740+
{ Event_type::S_SERVER_SOCKET_ACCEPTABLE, Sockets{} }
742741
}};
743742
}
744743

@@ -1425,7 +1424,7 @@ void Node::interrupt_all_waits_worker()
14251424
for (Event_set::Ptr event_set : m_event_sets)
14261425
{
14271426
// Work on one Event_set at a time. Lock it.
1428-
Event_set::Lock_guard lock(event_set->m_mutex);
1427+
Event_set::Lock_guard lock{event_set->m_mutex};
14291428

14301429
if (event_set->m_state == Event_set::State::S_WAITING)
14311430
{

src/flow/net_flow/event_set.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ bool Event_set::add_wanted_socket(typename Socket::Ptr sock, Event_type ev_type,
10221022
// We are in thread U != W.
10231023

10241024
// Accessing m_state, socket sets, etc. which may be written by other threads at any time. Must lock.
1025-
Lock_guard lock(m_mutex);
1025+
Lock_guard lock{m_mutex};
10261026

10271027
FLOW_LOG_TRACE("Object [" << sock << "] wanted for event type [" << ev_type << "] in Event_set [" << this << "].");
10281028

@@ -1059,7 +1059,7 @@ bool Event_set::remove_wanted_socket(typename Socket::Ptr sock, Event_type ev_ty
10591059
// We are in thread U != W.
10601060

10611061
// Accessing m_state, the sets, etc. which may be written by other threads at any time. Must lock.
1062-
Lock_guard lock(m_mutex);
1062+
Lock_guard lock{m_mutex};
10631063

10641064
FLOW_LOG_TRACE("Object [" << sock << "] no longer wanted for event type [" << ev_type << "] in "
10651065
"Event_set [" << this << "].");

src/flow/net_flow/node.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Node::Node(log::Logger* logger_ptr, const util::Udp_endpoint& low_lvl_endpoint,
4242
log::Log_context(this_thread_init_logger_setup("", logger_ptr),
4343
Flow_log_component::S_NET_FLOW),
4444
/* Take the given Node_options set and copy it into our stored global options. (Note the default
45-
* is Node_options().) The default is safe, but if they actually are providing a custom set of
45+
* is Node_options{}.) The default is safe, but if they actually are providing a custom set of
4646
* options, then we must validate before accepting. This may result in a validation error.
4747
* If !err_code, then it'll throw exception right here. If err_code, then it will set *err_code,
4848
* so we check for it inside the constructor body and exit. */
@@ -339,7 +339,7 @@ void Node::worker_run(const util::Udp_endpoint low_lvl_endpoint)
339339
while (!m_event_sets.empty()) // As above.
340340
{
341341
const Event_set::Ptr event_set = *m_event_sets.begin();
342-
Event_set::Lock_guard lock(event_set->m_mutex); // Pre-condition for event_set_close_worker().
342+
Event_set::Lock_guard lock{event_set->m_mutex}; // Pre-condition for event_set_close_worker().
343343
event_set_close_worker(event_set);
344344
}
345345

0 commit comments

Comments
 (0)