From 2a805e7b8ba924aa0eac1139fc7dc1c51e26c6a3 Mon Sep 17 00:00:00 2001 From: Dmitriy Shilin Date: Fri, 20 Oct 2023 11:20:47 +0300 Subject: [PATCH] GH-303 Ensure implementations of packet::IReader use ROC_ATTR_NODISCARD See also: https://github.com/roc-streaming/roc-toolkit/pull/591#discussion_r1359320296 --- src/internal_modules/roc_fec/reader.h | 2 +- src/internal_modules/roc_packet/concurrent_queue.h | 2 +- src/internal_modules/roc_packet/delayed_reader.h | 2 +- src/internal_modules/roc_packet/queue.h | 2 +- src/internal_modules/roc_packet/sorted_queue.h | 2 +- src/internal_modules/roc_rtp/populator.h | 2 +- src/internal_modules/roc_rtp/timestamp_injector.h | 2 +- src/internal_modules/roc_rtp/validator.h | 2 +- src/tests/roc_audio/test_depacketizer.cpp | 2 +- src/tests/roc_fec/test_writer_reader.cpp | 2 +- src/tests/roc_packet/test_delayed_reader.cpp | 2 +- src/tests/roc_rtp/test_helpers/status_reader.h | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/internal_modules/roc_fec/reader.h b/src/internal_modules/roc_fec/reader.h index b0d04ca57..bacc64120 100644 --- a/src/internal_modules/roc_fec/reader.h +++ b/src/internal_modules/roc_fec/reader.h @@ -69,7 +69,7 @@ class Reader : public packet::IReader, public core::NonCopyable<> { //! Read packet. //! @remarks //! When a packet loss is detected, try to restore it from repair packets. - virtual status::StatusCode read(packet::PacketPtr&); + virtual ROC_ATTR_NODISCARD status::StatusCode read(packet::PacketPtr&); private: status::StatusCode read_(packet::PacketPtr&); diff --git a/src/internal_modules/roc_packet/concurrent_queue.h b/src/internal_modules/roc_packet/concurrent_queue.h index 5a144dca6..7aa0bd668 100644 --- a/src/internal_modules/roc_packet/concurrent_queue.h +++ b/src/internal_modules/roc_packet/concurrent_queue.h @@ -41,7 +41,7 @@ class ConcurrentQueue : public IReader, public IWriter, public core::NonCopyable //! If reads are not concurrent, and queue is non-blocking, then //! reads are wait-free. Otherwise they may block. //! @see Mode. - virtual status::StatusCode read(PacketPtr&); + virtual ROC_ATTR_NODISCARD status::StatusCode read(PacketPtr&); //! Add packet to the queue. //! Wait-free operation. diff --git a/src/internal_modules/roc_packet/delayed_reader.h b/src/internal_modules/roc_packet/delayed_reader.h index 4f75608c0..5d7e03db6 100644 --- a/src/internal_modules/roc_packet/delayed_reader.h +++ b/src/internal_modules/roc_packet/delayed_reader.h @@ -38,7 +38,7 @@ class DelayedReader : public IReader, public core::NonCopyable<> { const audio::SampleSpec& sample_spec); //! Read packet. - virtual status::StatusCode read(PacketPtr&); + virtual ROC_ATTR_NODISCARD status::StatusCode read(PacketPtr&); private: status::StatusCode fetch_packets_(); diff --git a/src/internal_modules/roc_packet/queue.h b/src/internal_modules/roc_packet/queue.h index aabd0b19f..12c776a1e 100644 --- a/src/internal_modules/roc_packet/queue.h +++ b/src/internal_modules/roc_packet/queue.h @@ -25,7 +25,7 @@ namespace packet { class Queue : public IReader, public IWriter, public core::NonCopyable<> { public: //! Read next packet. - virtual status::StatusCode read(PacketPtr& packet); + virtual ROC_ATTR_NODISCARD status::StatusCode read(PacketPtr& packet); //! Add packet to the queue. //! @remarks diff --git a/src/internal_modules/roc_packet/sorted_queue.h b/src/internal_modules/roc_packet/sorted_queue.h index 18a25cd78..727c90080 100644 --- a/src/internal_modules/roc_packet/sorted_queue.h +++ b/src/internal_modules/roc_packet/sorted_queue.h @@ -42,7 +42,7 @@ class SortedQueue : public IWriter, public IReader, public core::NonCopyable<> { //! //! @remarks //! Removes returned packet from the queue. - virtual status::StatusCode read(PacketPtr& packet); + virtual ROC_ATTR_NODISCARD status::StatusCode read(PacketPtr& packet); //! Get number of packets in queue. size_t size() const; diff --git a/src/internal_modules/roc_rtp/populator.h b/src/internal_modules/roc_rtp/populator.h index 9512bf616..40dd3572a 100644 --- a/src/internal_modules/roc_rtp/populator.h +++ b/src/internal_modules/roc_rtp/populator.h @@ -29,7 +29,7 @@ class Populator : public packet::IReader, public core::NonCopyable<> { const audio::SampleSpec& sample_spec); //! Read next packet. - virtual status::StatusCode read(packet::PacketPtr&); + virtual ROC_ATTR_NODISCARD status::StatusCode read(packet::PacketPtr&); private: packet::IReader& reader_; diff --git a/src/internal_modules/roc_rtp/timestamp_injector.h b/src/internal_modules/roc_rtp/timestamp_injector.h index cbecff53b..ef728d871 100644 --- a/src/internal_modules/roc_rtp/timestamp_injector.h +++ b/src/internal_modules/roc_rtp/timestamp_injector.h @@ -36,7 +36,7 @@ class TimestampInjector : public packet::IReader, public core::NonCopyable<> { //! Get packet with filled capture ts field. //! @remarks //! If update_mapping has not been called yet, capture timestamp will be 0. - virtual status::StatusCode read(packet::PacketPtr&); + virtual ROC_ATTR_NODISCARD status::StatusCode read(packet::PacketPtr&); //! Get a pair of a reference timestamps. void update_mapping(core::nanoseconds_t capture_ts, diff --git a/src/internal_modules/roc_rtp/validator.h b/src/internal_modules/roc_rtp/validator.h index a88412823..f65b97924 100644 --- a/src/internal_modules/roc_rtp/validator.h +++ b/src/internal_modules/roc_rtp/validator.h @@ -51,7 +51,7 @@ class Validator : public packet::IReader, public core::NonCopyable<> { //! //! @remarks //! Reads packet from the underlying reader and validates it. - virtual status::StatusCode read(packet::PacketPtr& pp); + virtual ROC_ATTR_NODISCARD status::StatusCode read(packet::PacketPtr& pp); private: bool validate_(const packet::RTP& prev, const packet::RTP& next) const; diff --git a/src/tests/roc_audio/test_depacketizer.cpp b/src/tests/roc_audio/test_depacketizer.cpp index c2ba1f049..309597180 100644 --- a/src/tests/roc_audio/test_depacketizer.cpp +++ b/src/tests/roc_audio/test_depacketizer.cpp @@ -133,7 +133,7 @@ class TestReader : public packet::IReader { , code_(default_code_) { } - virtual status::StatusCode read(packet::PacketPtr& pp) { + virtual ROC_ATTR_NODISCARD status::StatusCode read(packet::PacketPtr& pp) { ++call_count_; if (code_enabled_) { diff --git a/src/tests/roc_fec/test_writer_reader.cpp b/src/tests/roc_fec/test_writer_reader.cpp index 8190d9255..e6efe6932 100644 --- a/src/tests/roc_fec/test_writer_reader.cpp +++ b/src/tests/roc_fec/test_writer_reader.cpp @@ -69,7 +69,7 @@ class StatusReader : public packet::IReader { : code_(code) { } - virtual status::StatusCode read(packet::PacketPtr&) { + virtual ROC_ATTR_NODISCARD status::StatusCode read(packet::PacketPtr&) { return code_; } diff --git a/src/tests/roc_packet/test_delayed_reader.cpp b/src/tests/roc_packet/test_delayed_reader.cpp index 85e610dae..20331ca67 100644 --- a/src/tests/roc_packet/test_delayed_reader.cpp +++ b/src/tests/roc_packet/test_delayed_reader.cpp @@ -49,7 +49,7 @@ class StatusReader : public IReader { : code_(code) { } - virtual status::StatusCode read(PacketPtr&) { + virtual ROC_ATTR_NODISCARD status::StatusCode read(PacketPtr&) { return code_; } diff --git a/src/tests/roc_rtp/test_helpers/status_reader.h b/src/tests/roc_rtp/test_helpers/status_reader.h index 34fc1549a..a0576daa4 100644 --- a/src/tests/roc_rtp/test_helpers/status_reader.h +++ b/src/tests/roc_rtp/test_helpers/status_reader.h @@ -22,7 +22,7 @@ class StatusReader : public packet::IReader { : code_(code) { } - virtual status::StatusCode read(packet::PacketPtr&) { + virtual ROC_ATTR_NODISCARD status::StatusCode read(packet::PacketPtr&) { return code_; }