summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2019-08-17 20:32:20 +0200
committerMarcus Müller <marcus@hostalia.de>2019-08-22 15:05:58 +0200
commitb08d13aed2a7e7ffdee09833bb24db8ce92dce66 (patch)
tree4846eebe25b48c615cbe07d2a9f4e79d5e8ff72d /gnuradio-runtime/lib
parentc6cb3bbc35153a9635d69eddab0d252f7441b854 (diff)
clang-tidy in gnuradio-runtime: use empty() instead of size()!=0
Diffstat (limited to 'gnuradio-runtime/lib')
-rw-r--r--gnuradio-runtime/lib/block_executor.cc8
-rw-r--r--gnuradio-runtime/lib/flowgraph.cc4
-rw-r--r--gnuradio-runtime/lib/hier_block2.cc15
-rw-r--r--gnuradio-runtime/lib/hier_block2_detail.cc4
-rw-r--r--gnuradio-runtime/lib/io_signature.cc3
-rw-r--r--gnuradio-runtime/lib/logger.cc8
-rw-r--r--gnuradio-runtime/lib/prefs.cc6
-rw-r--r--gnuradio-runtime/lib/tpb_thread_body.cc4
8 files changed, 29 insertions, 23 deletions
diff --git a/gnuradio-runtime/lib/block_executor.cc b/gnuradio-runtime/lib/block_executor.cc
index eb08c84de4..97e163b683 100644
--- a/gnuradio-runtime/lib/block_executor.cc
+++ b/gnuradio-runtime/lib/block_executor.cc
@@ -124,10 +124,11 @@ static bool propagate_tags(block::tag_propagation_policy_t policy,
d->get_tags_in_range(
rtags, i, start_nitems_read[i], d->nitems_read(i), block_id);
- if (rtags.size() == 0)
+ if (rtags.empty()) {
continue;
+ }
- if (out_buf.size() == 0) {
+ if (out_buf.empty()) {
out_buf.reserve(d->noutputs());
for (int o = 0; o < d->noutputs(); o++)
out_buf.push_back(d->output(o));
@@ -176,8 +177,9 @@ static bool propagate_tags(block::tag_propagation_policy_t policy,
d->get_tags_in_range(
rtags, i, start_nitems_read[i], d->nitems_read(i), block_id);
- if (rtags.size() == 0)
+ if (rtags.empty()) {
continue;
+ }
out_buf = d->output(i);
diff --git a/gnuradio-runtime/lib/flowgraph.cc b/gnuradio-runtime/lib/flowgraph.cc
index 11c816f79f..435611f599 100644
--- a/gnuradio-runtime/lib/flowgraph.cc
+++ b/gnuradio-runtime/lib/flowgraph.cc
@@ -328,7 +328,7 @@ std::vector<basic_block_vector_t> flowgraph::partition()
basic_block_vector_t blocks = calc_used_blocks();
basic_block_vector_t graph;
- while (blocks.size() > 0) {
+ while (!blocks.empty()) {
graph = calc_reachable_blocks(blocks[0], blocks);
assert(graph.size());
result.push_back(topological_sort(graph));
@@ -432,7 +432,7 @@ basic_block_vector_t flowgraph::sort_sources_first(basic_block_vector_t& blocks)
bool flowgraph::source_p(basic_block_sptr block)
{
- return (calc_upstream_edges(block).size() == 0);
+ return calc_upstream_edges(block).empty();
}
void flowgraph::topological_dfs_visit(basic_block_sptr block,
diff --git a/gnuradio-runtime/lib/hier_block2.cc b/gnuradio-runtime/lib/hier_block2.cc
index 755977c841..4f98e66af9 100644
--- a/gnuradio-runtime/lib/hier_block2.cc
+++ b/gnuradio-runtime/lib/hier_block2.cc
@@ -171,9 +171,10 @@ int hier_block2::max_output_buffer(size_t port)
void hier_block2::set_max_output_buffer(int max_output_buffer)
{
if (output_signature()->max_streams() > 0) {
- if (d_detail->d_max_output_buffer.size() == 0)
+ if (d_detail->d_max_output_buffer.empty()) {
throw std::length_error("hier_block2::set_max_output_buffer(int): out_sig "
"greater than zero, buff_vect isn't");
+ }
for (int idx = 0; idx < output_signature()->max_streams(); idx++) {
d_detail->d_max_output_buffer[idx] = max_output_buffer;
}
@@ -182,10 +183,10 @@ void hier_block2::set_max_output_buffer(int max_output_buffer)
void hier_block2::set_max_output_buffer(size_t port, int max_output_buffer)
{
- if (port >= d_detail->d_max_output_buffer.size())
+ if (port >= d_detail->d_max_output_buffer.size()) {
throw std::invalid_argument(
"hier_block2::set_max_output_buffer(size_t,int): port out of range.");
- else {
+ } else {
d_detail->d_max_output_buffer[port] = max_output_buffer;
}
}
@@ -201,9 +202,10 @@ int hier_block2::min_output_buffer(size_t port)
void hier_block2::set_min_output_buffer(int min_output_buffer)
{
if (output_signature()->max_streams() > 0) {
- if (d_detail->d_min_output_buffer.size() == 0)
+ if (d_detail->d_min_output_buffer.empty()) {
throw std::length_error("hier_block2::set_min_output_buffer(int): out_sig "
"greater than zero, buff_vect isn't");
+ }
for (int idx = 0; idx < output_signature()->max_streams(); idx++) {
d_detail->d_min_output_buffer[idx] = min_output_buffer;
}
@@ -222,8 +224,9 @@ void hier_block2::set_min_output_buffer(size_t port, int min_output_buffer)
bool hier_block2::all_min_output_buffer_p(void)
{
- if (!d_detail->d_min_output_buffer.size())
+ if (d_detail->d_min_output_buffer.empty()) {
return false;
+ }
for (size_t idx = 1; idx < d_detail->d_min_output_buffer.size(); idx++) {
if (d_detail->d_min_output_buffer[0] != d_detail->d_min_output_buffer[idx])
return false;
@@ -232,7 +235,7 @@ bool hier_block2::all_min_output_buffer_p(void)
}
bool hier_block2::all_max_output_buffer_p(void)
{
- if (!d_detail->d_max_output_buffer.size())
+ if (d_detail->d_max_output_buffer.empty())
return false;
for (size_t idx = 1; idx < d_detail->d_max_output_buffer.size(); idx++) {
if (d_detail->d_max_output_buffer[0] != d_detail->d_max_output_buffer[idx])
diff --git a/gnuradio-runtime/lib/hier_block2_detail.cc b/gnuradio-runtime/lib/hier_block2_detail.cc
index 59f290bf99..0e06c07e31 100644
--- a/gnuradio-runtime/lib/hier_block2_detail.cc
+++ b/gnuradio-runtime/lib/hier_block2_detail.cc
@@ -288,7 +288,7 @@ void hier_block2_detail::disconnect(basic_block_sptr block)
}
}
- if (edges.size() == 0) {
+ if (edges.empty()) {
std::stringstream msg;
msg << "cannot disconnect block " << block << ", not found";
throw std::invalid_argument(msg.str());
@@ -784,7 +784,7 @@ void hier_block2_detail::flatten_aux(flat_flowgraph_sptr sfg) const
// Now add the list of connected input blocks
std::stringstream msg;
for (unsigned int i = 0; i < d_inputs.size(); i++) {
- if (d_inputs[i].size() == 0) {
+ if (d_inputs[i].empty()) {
msg << "In hierarchical block " << d_owner->name() << ", input " << i
<< " is not connected internally";
throw std::runtime_error(msg.str());
diff --git a/gnuradio-runtime/lib/io_signature.cc b/gnuradio-runtime/lib/io_signature.cc
index d5bb427ab8..dc8f65d0b9 100644
--- a/gnuradio-runtime/lib/io_signature.cc
+++ b/gnuradio-runtime/lib/io_signature.cc
@@ -79,8 +79,9 @@ io_signature::io_signature(int min_streams,
if (min_streams < 0 || (max_streams != IO_INFINITE && max_streams < min_streams))
throw std::invalid_argument("gr::io_signature(1)");
- if (sizeof_stream_items.size() < 1)
+ if (sizeof_stream_items.empty()) {
throw std::invalid_argument("gr::io_signature(2)");
+ }
for (size_t i = 0; i < sizeof_stream_items.size(); i++) {
if (max_streams != 0 && sizeof_stream_items[i] < 1)
diff --git a/gnuradio-runtime/lib/logger.cc b/gnuradio-runtime/lib/logger.cc
index 6aab82b603..ce2772cadf 100644
--- a/gnuradio-runtime/lib/logger.cc
+++ b/gnuradio-runtime/lib/logger.cc
@@ -157,7 +157,7 @@ logger_ptr logger_get_logger(std::string name)
bool logger_load_config(const std::string& config_filename)
{
- if (config_filename.size() != 0) {
+ if (!config_filename.empty()) {
try {
log4cpp::PropertyConfigurator::configure(config_filename);
return true;
@@ -343,7 +343,7 @@ bool configure_default_loggers(gr::logger_ptr& l,
GR_LOG_GETLOGGER(LOG, "gr_log." + name);
GR_LOG_SET_LEVEL(LOG, log_level);
- if (log_file.size() > 0) {
+ if (!log_file.empty()) {
if (log_file == "stdout") {
GR_LOG_SET_CONSOLE_APPENDER(LOG, "stdout", "gr::log :%p: %c{1} - %m%n");
} else if (log_file == "stderr") {
@@ -356,7 +356,7 @@ bool configure_default_loggers(gr::logger_ptr& l,
GR_LOG_GETLOGGER(DLOG, "gr_log_debug." + name);
GR_LOG_SET_LEVEL(DLOG, debug_level);
- if (debug_file.size() > 0) {
+ if (!debug_file.empty()) {
if (debug_file == "stdout") {
GR_LOG_SET_CONSOLE_APPENDER(DLOG, "stdout", "gr::debug :%p: %c{1} - %m%n");
} else if (debug_file == "stderr") {
@@ -376,7 +376,7 @@ bool update_logger_alias(const std::string& name, const std::string& alias)
std::string debug_file = p->get_string("LOG", "debug_file", "");
GR_LOG_GETLOGGER(LOG, "gr_log." + name);
- if (log_file.size() > 0) {
+ if (!log_file.empty()) {
if (log_file == "stdout") {
boost::format str("gr::log :%%p: %1% - %%m%%n");
GR_LOG_SET_CONSOLE_APPENDER(LOG, "stdout", boost::str(str % alias));
diff --git a/gnuradio-runtime/lib/prefs.cc b/gnuradio-runtime/lib/prefs.cc
index f59a2346f7..4173973c2e 100644
--- a/gnuradio-runtime/lib/prefs.cc
+++ b/gnuradio-runtime/lib/prefs.cc
@@ -243,7 +243,7 @@ bool prefs::get_bool(const std::string& section,
{
if (has_option(section, option)) {
std::string str = get_string(section, option, "");
- if (str == "") {
+ if (str.empty()) {
return default_val;
}
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
@@ -281,7 +281,7 @@ long prefs::get_long(const std::string& section,
{
if (has_option(section, option)) {
std::string str = get_string(section, option, "");
- if (str == "") {
+ if (str.empty()) {
return default_val;
}
std::stringstream sstr(str);
@@ -316,7 +316,7 @@ double prefs::get_double(const std::string& section,
{
if (has_option(section, option)) {
std::string str = get_string(section, option, "");
- if (str == "") {
+ if (str.empty()) {
return default_val;
}
std::stringstream sstr(str);
diff --git a/gnuradio-runtime/lib/tpb_thread_body.cc b/gnuradio-runtime/lib/tpb_thread_body.cc
index ff70ae197f..d64fd2f623 100644
--- a/gnuradio-runtime/lib/tpb_thread_body.cc
+++ b/gnuradio-runtime/lib/tpb_thread_body.cc
@@ -68,7 +68,7 @@ tpb_thread_body::tpb_thread_body(block_sptr block,
GR_LOG_GETLOGGER(LOG, "gr_log.tpb_thread_body");
GR_LOG_SET_LEVEL(LOG, log_level);
GR_CONFIG_LOGGER(config_file);
- if (log_file.size() > 0) {
+ if (!log_file.empty()) {
if (log_file == "stdout") {
GR_LOG_SET_CONSOLE_APPENDER(LOG, "stdout", "gr::log :%p: %c{1} - %m%n");
} else if (log_file == "stderr") {
@@ -79,7 +79,7 @@ tpb_thread_body::tpb_thread_body(block_sptr block,
}
// Set thread affinity if it was set before fg was started.
- if (block->processor_affinity().size() > 0) {
+ if (!block->processor_affinity().empty()) {
gr::thread::thread_bind_to_processor(d->thread, block->processor_affinity());
}