From eb5e7c7c2f1b25c67281286cfa3e894106180e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joni=20R=C3=A4s=C3=A4nen?= Date: Thu, 25 Aug 2022 18:02:51 +0300 Subject: [PATCH] common: Fix warnings given by GCC on Linux --- include/uvgrtp/frame.hh | 21 ++++++++++++--------- include/uvgrtp/media_stream.hh | 2 +- include/uvgrtp/rtcp.hh | 4 ++-- src/frame.cc | 15 +++++++++++---- src/frame_queue.cc | 2 +- src/media_stream.cc | 2 +- src/reception_flow.cc | 4 ++-- src/rtcp.cc | 2 +- src/rtcp_packets.cc | 26 ++++++++------------------ src/zrtp/zrtp_message.cc | 4 ++-- src/zrtp/zrtp_message.hh | 4 ++-- 11 files changed, 43 insertions(+), 43 deletions(-) diff --git a/include/uvgrtp/frame.hh b/include/uvgrtp/frame.hh index 783b269..46d652c 100644 --- a/include/uvgrtp/frame.hh +++ b/include/uvgrtp/frame.hh @@ -162,14 +162,6 @@ namespace uvgrtp { rtp_frame *alloc_rtp_frame(size_t payload_len); rtp_frame *alloc_rtp_frame(size_t payload_len, size_t pz_size); - /* Allocate ZRTP frame - * Parameter "payload_size" defines the length of the frame - * - * Return pointer to frame on success - * Return nullptr on error and set rtp_errno to: - * RTP_MEMORY_ERROR if allocation of memory failed - * RTP_INVALID_VALUE if "payload_size" is 0 */ - zrtp_frame *alloc_zrtp_frame(size_t payload_size); /* Deallocate RTP frame * @@ -177,11 +169,22 @@ namespace uvgrtp { * Return RTP_INVALID_VALUE if "frame" is nullptr */ rtp_error_t dealloc_frame(uvgrtp::frame::rtp_frame *frame); + + /* Allocate ZRTP frame + * Parameter "payload_size" defines the length of the frame + * + * Return pointer to frame on success + * Return nullptr on error and set rtp_errno to: + * RTP_MEMORY_ERROR if allocation of memory failed + * RTP_INVALID_VALUE if "payload_size" is 0 */ + void* alloc_zrtp_frame(size_t payload_size); + + /* Deallocate ZRTP frame * * Return RTP_OK on successs * Return RTP_INVALID_VALUE if "frame" is nullptr */ - rtp_error_t dealloc_frame(uvgrtp::frame::zrtp_frame *frame); + rtp_error_t dealloc_frame(uvgrtp::frame::zrtp_frame* frame); } } diff --git a/include/uvgrtp/media_stream.hh b/include/uvgrtp/media_stream.hh index 8845b80..28006bb 100644 --- a/include/uvgrtp/media_stream.hh +++ b/include/uvgrtp/media_stream.hh @@ -318,7 +318,7 @@ namespace uvgrtp { rtp_error_t start_components(); - int get_default_bandwidth_kbps(rtp_format_t fmt); + uint32_t get_default_bandwidth_kbps(rtp_format_t fmt); uint32_t key_; diff --git a/include/uvgrtp/rtcp.hh b/include/uvgrtp/rtcp.hh index de27a4e..4648f12 100644 --- a/include/uvgrtp/rtcp.hh +++ b/include/uvgrtp/rtcp.hh @@ -206,7 +206,7 @@ namespace uvgrtp { /* Getter for interval_ms_, which is calculated by set_session_bandwidth */ uint32_t get_rtcp_interval_ms() const; - void set_session_bandwidth(int kbps); + void set_session_bandwidth(uint32_t kbps); /* Return SSRCs of all participants */ std::vector get_participants() const; @@ -495,7 +495,7 @@ namespace uvgrtp { bool active_; - int interval_ms_; + uint32_t interval_ms_; std::mutex packet_mutex_; diff --git a/src/frame.cc b/src/frame.cc index 9f665fa..b1fe15d 100644 --- a/src/frame.cc +++ b/src/frame.cc @@ -11,8 +11,15 @@ uvgrtp::frame::rtp_frame *uvgrtp::frame::alloc_rtp_frame() { uvgrtp::frame::rtp_frame *frame = new uvgrtp::frame::rtp_frame; - std::memset(&frame->header, 0, sizeof(uvgrtp::frame::rtp_header)); - std::memset(frame, 0, sizeof(uvgrtp::frame::rtp_frame)); + frame->header.version = 0; + frame->header.padding = 0; + frame->header.ext = 0; + frame->header.cc = 0; + frame->header.marker = 0; + frame->header.payload = 0; + frame->header.seq = 0; + frame->header.timestamp = 0; + frame->header.ssrc = 0; frame->payload = nullptr; frame->probation = nullptr; @@ -75,7 +82,7 @@ rtp_error_t uvgrtp::frame::dealloc_frame(uvgrtp::frame::rtp_frame *frame) return RTP_OK; } -uvgrtp::frame::zrtp_frame *uvgrtp::frame::alloc_zrtp_frame(size_t size) +void* uvgrtp::frame::alloc_zrtp_frame(size_t size) { if (size == 0) { rtp_errno = RTP_INVALID_VALUE; @@ -94,7 +101,7 @@ uvgrtp::frame::zrtp_frame *uvgrtp::frame::alloc_zrtp_frame(size_t size) return frame; } -rtp_error_t uvgrtp::frame::dealloc_frame(uvgrtp::frame::zrtp_frame *frame) +rtp_error_t uvgrtp::frame::dealloc_frame(uvgrtp::frame::zrtp_frame* frame) { if (!frame) return RTP_INVALID_VALUE; diff --git a/src/frame_queue.cc b/src/frame_queue.cc index f8739ec..3248b1b 100644 --- a/src/frame_queue.cc +++ b/src/frame_queue.cc @@ -304,7 +304,7 @@ rtp_error_t uvgrtp::frame_queue::flush_queue() std::chrono::nanoseconds packet_interval = frame_interval_/ active_->packets.size(); - for (int i = 0; i < active_->packets.size(); ++i) + for (size_t i = 0; i < active_->packets.size(); ++i) { std::chrono::high_resolution_clock::time_point next_packet = this_moment + i * packet_interval; diff --git a/src/media_stream.cc b/src/media_stream.cc index 2c90db8..5819de8 100644 --- a/src/media_stream.cc +++ b/src/media_stream.cc @@ -661,7 +661,7 @@ rtp_error_t uvgrtp::media_stream::init_srtp_with_zrtp(int rce_flags, int type, s } -int uvgrtp::media_stream::get_default_bandwidth_kbps(rtp_format_t fmt) +uint32_t uvgrtp::media_stream::get_default_bandwidth_kbps(rtp_format_t fmt) { int bandwidth = 50; switch (fmt) { diff --git a/src/reception_flow.cc b/src/reception_flow.cc index 216c5e5..45ea927 100644 --- a/src/reception_flow.cc +++ b/src/reception_flow.cc @@ -60,7 +60,7 @@ void uvgrtp::reception_flow::create_ring_buffer() destroy_ring_buffer(); size_t elements = buffer_size_kbytes_ / RECV_BUFFER_SIZE; - for (int i = 0; i < elements; ++i) + for (size_t i = 0; i < elements; ++i) { ring_buffer_.push_back({ new uint8_t[RECV_BUFFER_SIZE] , 0 }); } @@ -68,7 +68,7 @@ void uvgrtp::reception_flow::create_ring_buffer() void uvgrtp::reception_flow::destroy_ring_buffer() { - for (int i = 0; i < ring_buffer_.size(); ++i) + for (size_t i = 0; i < ring_buffer_.size(); ++i) { delete[] ring_buffer_.at(i).data; } diff --git a/src/rtcp.cc b/src/rtcp.cc index 72603fe..a0f4758 100644 --- a/src/rtcp.cc +++ b/src/rtcp.cc @@ -1804,7 +1804,7 @@ uint32_t uvgrtp::rtcp::get_rtcp_interval_ms() const return interval_ms_; } -void uvgrtp::rtcp::set_session_bandwidth(int kbps) +void uvgrtp::rtcp::set_session_bandwidth(uint32_t kbps) { interval_ms_ = 1000*360 / kbps; // the reduced minimum (see section 6.2 in RFC 3550) diff --git a/src/rtcp_packets.cc b/src/rtcp_packets.cc index a4d114f..bb2854e 100644 --- a/src/rtcp_packets.cc +++ b/src/rtcp_packets.cc @@ -37,14 +37,7 @@ uint32_t uvgrtp::get_sdes_packet_size(const std::vector socket, sockaddr_in& addr) diff --git a/src/zrtp/zrtp_message.hh b/src/zrtp/zrtp_message.hh index 1b72906..f48302f 100644 --- a/src/zrtp/zrtp_message.hh +++ b/src/zrtp/zrtp_message.hh @@ -34,8 +34,8 @@ namespace uvgrtp { void set_zrtp_start(uvgrtp::zrtp_msg::zrtp_msg& start, zrtp_session_t& session, std::string msgblock); - uvgrtp::frame::zrtp_frame* frame_; - uvgrtp::frame::zrtp_frame* rframe_; + void* frame_; + void* rframe_; size_t len_; size_t rlen_; };