Skip to content

Commit

Permalink
resolve warnings
Browse files Browse the repository at this point in the history
Resolves a bunch of compiler warnings, mostly missing initializers and
implicit converstions.

Signed-off-by: Alexander Krimm <[email protected]>
  • Loading branch information
wirew0rm committed Jun 11, 2024
1 parent 5db14bc commit 89fa406
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 49 deletions.
4 changes: 2 additions & 2 deletions blocks/basic/include/gnuradio-4.0/basic/SignalGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ s(t) = 2 * A * (t * f - floor(t * f + 0.5)) + O
This waveform linearly increases from -amplitude to amplitude in the first half of its period and then decreases back to -amplitude in the second half, forming a triangle shape.
s(t) = A * (4 * abs(t * f - floor(t * f + 0.75) + 0.25) - 1) + O
)"">;
PortIn<T> in; // ClockSource input
PortOut<T> out;
PortIn<T> in{}; // ClockSource input
PortOut<T> out{};

Annotated<float, "sample_rate", Visible, Doc<"sample rate">> sample_rate = 1000.f;
Annotated<std::string, "signal_type", Visible, Doc<"see signal_generator::Type">> signal_type = "Sin";
Expand Down
14 changes: 7 additions & 7 deletions blocks/basic/include/gnuradio-4.0/basic/StreamToDataSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ struct StreamFilterImpl : Block<StreamFilterImpl<T, streamOut, TMatcher>, Doc<R"

// port definitions
using OutType = std::conditional_t<streamOut, T, DataSet<T>>;
PortIn<T> in;
PortOut<OutType, Async> out;
PortIn<T> in{};
PortOut<OutType, Async> out{};

// settings
A<std::string, "filter", Visible, Doc<"syntax: '[<start trigger name>/<ctx1>, <stop trigger name>/<ctx2>]'">> filter;
A<property_map, "filter state", Doc<"">> filterState;
A<std::string, "filter", Visible, Doc<"syntax: '[<start trigger name>/<ctx1>, <stop trigger name>/<ctx2>]'">> filter{};
A<property_map, "filter state", Doc<"">> filterState{};
A<gr::Size_t, "n samples pre", Visible, Doc<"number of pre-trigger samples">> n_pre = 0U;
A<gr::Size_t, "n samples post", Visible, Doc<"number of post-trigger samples">> n_post = 0U;
A<gr::Size_t, "n samples max", Doc<"maximum number of samples (0: infinite)">> n_max = 0U;

// meta information (will be usually set by incoming tags/upstream sources
A<float, "sample_rate", Doc<"signal sample rate">> sample_rate = 1.f;
A<std::string, "signal_name", Doc<"signal name">> signal_name;
A<std::string, "signal_name", Doc<"signal name">> signal_name{};
A<std::string, "signal quantity", Doc<"physical quantity (e.g., 'voltage'). Follows ISO 80000-1:2022.">> signal_quantity;
A<std::string, "signal unit", Doc<"unit of measurement (e.g., '[V]', '[m]'). Follows ISO 80000-1:2022">> signal_unit;
A<std::string, "signal unit", Doc<"unit of measurement (e.g., '[V]', '[m]'). Follows ISO 80000-1:2022">> signal_unit{};
A<float, "signal_min", Doc<"signal physical max. (e.g. DAQ) limit">> signal_min = 0.f;
A<float, "signal_max", Doc<"signal physical max. (e.g. DAQ) limit">> signal_max = 1.f;

Expand All @@ -46,7 +46,7 @@ struct StreamFilterImpl : Block<StreamFilterImpl<T, streamOut, TMatcher>, Doc<R"
bool _accumulationActive = false;
std::size_t _nSamplesWritten = 0UZ;
std::size_t _nPostSamplesWritten = 0UZ;
DataSet<T> _tempDataSet;
DataSet<T> _tempDataSet{};
bool _dataSetAccumulation = false;

void
Expand Down
8 changes: 4 additions & 4 deletions blocks/basic/include/gnuradio-4.0/basic/clock_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ This block can generate periodic signals based on a system clock and allows for
The 'tag_times[ns]:tag_value(string)' vectors control the emission of tags with a single 'context' keys at specified times after the block started.)"">;
using TimePoint = std::chrono::time_point<ClockSourceType>;

PortOut<T> out;
PortOut<T> out{};

// Ready-to-use tags set by user
std::vector<Tag> tags{};

// Time-string tags
Annotated<std::vector<std::uint64_t>, "tag offset time", Doc<"time in nanoseconds since block start">> tag_times;
Annotated<std::vector<std::string>, "tag values", Doc<"values to be emittages as {\" context \":value_i}">> tag_values;
Annotated<std::vector<std::uint64_t>, "tag offset time", Doc<"time in nanoseconds since block start">> tag_times{};
Annotated<std::vector<std::string>, "tag values", Doc<"values to be emittages as {\" context \":value_i}">> tag_values{};
Annotated<std::uint64_t, "repeat period", Doc<"if repeat_period > last tag_time -> restart tags, in nanoseconds">> repeat_period{ 0 };
Annotated<bool, "perform zero hold", Doc<"if more tag_times than values: true=publish last tag, false=publish empty">> do_zero_order_hold{ false };

A<gr::Size_t, "n_samples_max", Visible, Doc<"0: unlimited">> n_samples_max = 1024;
gr::Size_t n_samples_produced{ 0 };
A<float, "avg. sample rate", Visible> sample_rate = 1000.f;
A<gr::Size_t, "chunk_size", Visible, Doc<"number of samples per update">> chunk_size = 100;
std::shared_ptr<std::thread> userProvidedThread;
std::shared_ptr<std::thread> userProvidedThread{};
bool verbose_console = false;

std::size_t _nextTag{ 0 };
Expand Down
4 changes: 2 additions & 2 deletions blocks/fileio/include/gnuradio-4.0/fileio/BasicFileIo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Important: this implementation assumes a host-order, CPU architecture specific b
template<typename U, gr::meta::fixed_string description = "", typename... Arguments>
using A = gr::Annotated<U, description, Arguments...>; // optional shortening

PortIn<T> in;
PortIn<T> in{};

A<std::string, "file name", Doc<"base filename, prefixed if ">, Visible> file_name;
Mode _mode = Mode::overwrite;
Expand Down Expand Up @@ -181,7 +181,7 @@ Important: this implementation assumes a host-order, CPU architecture specific b
template<typename U, gr::meta::fixed_string description = "", typename... Arguments>
using A = gr::Annotated<U, description, Arguments...>; // optional shortening

PortOut<T> out;
PortOut<T> out{};

A<std::string, "file name", Doc<"Base filename, prefixed if necessary">, Visible> file_name;
Mode _mode = Mode::overwrite;
Expand Down
4 changes: 2 additions & 2 deletions blocks/math/include/gnuradio-4.0/math/Math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ defaultValue() noexcept {

template<typename T, char op>
struct MathOpImpl : public gr::Block<MathOpImpl<T, op>> {
PortIn<T> in;
PortOut<T> out;
PortIn<T> in{};
PortOut<T> out{};
T value = detail::defaultValue<T>();

template<gr::meta::t_or_simd<T> V>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ template<typename T>
requires(std::is_arithmetic_v<T> || gr::DataSetLike<T>)
struct ImChartMonitor : public Block<ImChartMonitor<T>, BlockingIO<false>, Drawable<UICategory::ChartPane, "console">> {
using ClockSourceType = std::chrono::system_clock;
PortIn<T> in;
PortIn<T> in{};
float sample_rate = 1000.0f;
std::string signal_name = "unknown signal";

Expand Down
18 changes: 9 additions & 9 deletions blocks/testing/include/gnuradio-4.0/testing/NullSources.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct NullSource : public gr::Block<NullSource<T>> {
Used mainly for testing and benchmarking where a consistent and predictable output is essential.
Ideal for scenarios that require a simple, low-overhead source of consistent values.)"">;

gr::PortOut<T> out;
gr::PortOut<T> out{};

[[nodiscard]] constexpr T processOne() const noexcept { return T{}; }
};
Expand All @@ -27,7 +27,7 @@ struct ConstantSource : public gr::Block<ConstantSource<T>> {
This block counts the number of samples emitted and optionally halts after reaching a specified maximum.
Commonly used for testing and simulations where consistent output and finite execution are required.)"">;

gr::PortOut<T> out;
gr::PortOut<T> out{};

Annotated<T, "default value", Visible, Doc<"default value for each sample">> default_value{};
Annotated<gr::Size_t, "max samples", Doc<"count>n_samples_max -> signal DONE (0: infinite)">> n_samples_max = 0U;
Expand Down Expand Up @@ -78,7 +78,7 @@ struct CountingSource : public gr::Block<CountingSource<T>> {
This block counts the number of samples emitted and optionally halts after reaching a specified maximum.
Commonly used for testing and simulations where consistent output and finite execution are required.)"">;

gr::PortOut<T> out;
gr::PortOut<T> out{};

Annotated<T, "default value", Visible, Doc<"default value for each sample">> default_value{};
Annotated<gr::Size_t, "max samples", Doc<"count>n_samples_max -> signal DONE (0: infinite)">> n_samples_max = 0U;
Expand All @@ -102,8 +102,8 @@ struct Copy : public gr::Block<Copy<T>> {
using Description = Doc<R""(A block that passes/copies input samples directly to its output without modification.
Commonly used used to isolate parts of a flowgraph, manage buffer sizes, or simply duplicate the signal path.)"">;

gr::PortIn<T> in;
gr::PortOut<T> out;
gr::PortIn<T> in{};
gr::PortOut<T> out{};

template<gr::meta::t_or_simd<T> V>
[[nodiscard]] constexpr auto processOne(V input) const noexcept {
Expand All @@ -118,8 +118,8 @@ struct HeadBlock : public gr::Block<HeadBlock<T>> { // TODO confirm naming: whil
using Description = Doc<R""(Limits the number of output samples by copying the first N items from the input to the output and then signaling completion.
Commonly used to control data flow in systems where precise sample counts are critical, such as in file recording or when executing flow graphs without a GUI.)"">;

gr::PortIn<T> in;
gr::PortOut<T> out;
gr::PortIn<T> in{};
gr::PortOut<T> out{};

Annotated<gr::Size_t, "max samples", Doc<"count>n_samples_max -> signal DONE (0: infinite)">> n_samples_max = 0U;
Annotated<gr::Size_t, "count", Doc<"sample count (diagnostics only)">> count = 0U;
Expand All @@ -143,7 +143,7 @@ struct NullSink : public gr::Block<NullSink<T>> {
Used primarily for absorbing data in a flow graph where output processing is unnecessary.
Commonly used for testing, performance benchmarking, and in scenarios where signal flow needs to be terminated without external effects.)"">;

gr::PortIn<T> in;
gr::PortIn<T> in{};

template<gr::meta::t_or_simd<T> V>
void processOne(V) const noexcept {}
Expand All @@ -157,7 +157,7 @@ struct CountingSink : public gr::Block<CountingSink<T>> {
This block is used to control execution in systems requiring precise input processing without data output, similar to how a 'HeadBlock' manages output samples.
Commonly used for testing scenarios and signal termination where output is unnecessary but precise input count control is needed.)"">;

gr::PortIn<T> in;
gr::PortIn<T> in{};

Annotated<gr::Size_t, "max samples", Doc<"count>n_samples_max -> signal DONE (0: infinite)">> n_samples_max = 0U;
Annotated<gr::Size_t, "count", Doc<"sample count (diagnostics only)">> count = 0U;
Expand Down
8 changes: 4 additions & 4 deletions blocks/testing/include/gnuradio-4.0/testing/TagMonitors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ equal_tag_lists(const std::vector<Tag> &tags1, const std::vector<Tag> &tags2, co

template<typename T, ProcessFunction UseProcessVariant = ProcessFunction::USE_PROCESS_BULK>
struct TagSource : public Block<TagSource<T, UseProcessVariant>> {
PortOut<T> out;
PortOut<T> out{};
std::vector<Tag> tags{};
std::vector<T> values{}; // if values are set it works like repeated source. Example: values = { 1, 2, 3 }; output: 1,2,3,1,2,3... `mark_tag` is ignored in this case.
std::size_t value_index{ 0 }; // current index in values array
Expand Down Expand Up @@ -181,8 +181,8 @@ struct TagSource : public Block<TagSource<T, UseProcessVariant>> {
template<typename T, ProcessFunction UseProcessVariant>
struct TagMonitor : public Block<TagMonitor<T, UseProcessVariant>> {
using ClockSourceType = std::chrono::system_clock;
PortIn<T> in;
PortOut<T> out;
PortIn<T> in{};
PortOut<T> out{};
std::vector<T> samples{};
std::vector<Tag> tags{};
gr::Size_t n_samples_expected{ 0 };
Expand Down Expand Up @@ -281,7 +281,7 @@ struct TagMonitor : public Block<TagMonitor<T, UseProcessVariant>> {
template<typename T, ProcessFunction UseProcessVariant>
struct TagSink : public Block<TagSink<T, UseProcessVariant>> {
using ClockSourceType = std::chrono::system_clock;
PortIn<T> in;
PortIn<T> in{};
std::vector<T> samples{};
std::vector<Tag> tags{};
gr::Size_t n_samples_expected{ 0 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ inline static std::size_t n_samples_produced = 0UZ;

template<typename T, std::size_t min = 0UZ, std::size_t count = N_MAX, bool use_bulk_operation = true>
struct source : public gr::Block<source<T, min, count>> {
gr::PortOut<T> out;
gr::PortOut<T> out{};

gr::Size_t n_samples_max;
gr::Size_t n_samples_max = 256;

friend constexpr std::size_t
available_samples(const source &self) noexcept {
Expand Down Expand Up @@ -47,7 +47,7 @@ inline static std::size_t n_samples_consumed = 0UZ;

template<typename T, std::size_t N_MIN = 1UZ, std::size_t N_MAX = N_MAX>
struct sink : public gr::Block<sink<T, N_MIN, N_MAX>> {
gr::PortIn<T, gr::RequiredSamples<N_MIN, N_MAX>> in;
gr::PortIn<T, gr::RequiredSamples<N_MIN, N_MAX>> in{};
uint64_t should_receive_n_samples = 0;
int64_t _last_tag_position = -1;

Expand Down
12 changes: 6 additions & 6 deletions core/benchmarks/bm-nosonar_node_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ template<typename T, typename R = T>
struct converting_multiply : public gr::Block<converting_multiply<T, R>> {
T value = static_cast<T>(1.0f);

gr::PortIn<T> in;
gr::PortOut<R> out;
gr::PortIn<T> in{};
gr::PortOut<R> out{};

[[nodiscard]] constexpr auto
processOne(T a) const noexcept {
Expand Down Expand Up @@ -114,8 +114,8 @@ static_assert(gr::traits::block::can_processOne_simd<converting_multiply<float,
template<typename T, int addend>
class add : public gr::Block<add<T, addend>> {
public:
gr::PortIn<T> in;
gr::PortOut<T> out;
gr::PortIn<T> in{};
gr::PortOut<T> out{};

template<gr::meta::t_or_simd<T> V>
[[nodiscard]] constexpr V
Expand Down Expand Up @@ -223,8 +223,8 @@ using add_SIMD = gen_operation_SIMD<T, '+'>;
template<typename T, std::size_t N_MIN = 1, std::size_t N_MAX = N_MAX, bool use_bulk_operation = false, bool use_memcopy = true>
class copy : public gr::Block<copy<T, N_MIN, N_MAX, use_bulk_operation, use_memcopy>> {
public:
gr::PortIn<T, gr::RequiredSamples<N_MIN, N_MAX>> in;
gr::PortOut<T, gr::RequiredSamples<N_MIN, N_MAX>> out;
gr::PortIn<T, gr::RequiredSamples<N_MIN, N_MAX>> in{};
gr::PortOut<T, gr::RequiredSamples<N_MIN, N_MAX>> out{};

template<gr::meta::t_or_simd<T> V>
[[nodiscard]] constexpr V
Expand Down
6 changes: 4 additions & 2 deletions core/include/gnuradio-4.0/Block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,10 @@ class Block : public lifecycle::StateMachine<Derived>, protected std::tuple<Argu
for_each_port([&tag_data, tagOffset](PortLike auto& outPort) { outPort.publishTag(tag_data, tagOffset); }, outputPorts<PortType::STREAM>(&self()));
}

inline constexpr void publishEoS() noexcept { const property_map& tag_data{{gr::tag::END_OF_STREAM, true}};
for_each_port([&tag_data](PortLike auto& outPort) { outPort.publishTag(tag_data, outPort.streamWriter().nSamplesPublished()); }, outputPorts<PortType::STREAM>(&self())); }
inline constexpr void publishEoS() noexcept {
const property_map& tag_data{{gr::tag::END_OF_STREAM, true}};
for_each_port([&tag_data](PortLike auto& outPort) { outPort.publishTag(tag_data, static_cast<gr::Tag::signed_index_type>(outPort.streamWriter().nSamplesPublished())); }, outputPorts<PortType::STREAM>(&self()));
}

constexpr void requestStop() noexcept { emitErrorMessageIfAny("requestStop()", this->changeStateTo(lifecycle::State::REQUESTED_STOP)); }

Expand Down
2 changes: 1 addition & 1 deletion core/include/gnuradio-4.0/Port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ struct Port {
break;
}
}
bool result = tags.tryConsume(tagsToConsume);
std::ignore = tags.tryConsume(tagsToConsume);
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions core/test/plugins/good_conversion_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace good {
template<typename From, typename To>
class convert : public gr::Block<convert<From, To>> {
public:
gr::PortIn<From> in;
gr::PortOut<To> out;
gr::PortIn<From> in{};
gr::PortOut<To> out{};

[[nodiscard]] constexpr auto
processOne(From value) const noexcept {
Expand Down
4 changes: 2 additions & 2 deletions core/test/qa_Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static_assert(gr::BlockLike<CountSource<float>>);

template<typename T>
struct ExpectSink : public gr::Block<ExpectSink<T>> {
gr::PortIn<T> in;
gr::PortIn<T> in{};
gr::Size_t n_samples_max = 0;
std::shared_ptr<Tracer> tracer{};
gr::Size_t count = 0;
Expand Down Expand Up @@ -250,7 +250,7 @@ checkBlockNames(const std::vector<TBlock> &joblist, std::set<std::string> set) {

template<typename T>
struct LifecycleSource : public gr::Block<LifecycleSource<T>> {
gr::PortOut<T> out;
gr::PortOut<T> out{};
std::int32_t n_samples_produced = 0;
std::int32_t n_samples_max = 10;

Expand Down
4 changes: 2 additions & 2 deletions core/test/qa_grc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ ENABLE_REFLECTION_FOR_TEMPLATE(ArraySource, outA, outB);

template<typename T>
struct ArraySink : public gr::Block<ArraySink<T>> {
std::array<gr::PortIn<T>, 2> inA;
std::array<gr::PortIn<T>, 2> inB;
std::array<gr::PortIn<T>, 2> inA{};
std::array<gr::PortIn<T>, 2> inB{};
gr::Annotated<bool, "bool setting"> bool_setting{ false };
gr::Annotated<std::string, "String setting"> string_setting;
gr::Annotated<std::vector<bool>, "Bool vector setting"> bool_vector;
Expand Down

0 comments on commit 89fa406

Please sign in to comment.