提交 fd6d6aa0 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Code clean up based on cppcheck report.

上级 641c14f8
...@@ -44,7 +44,7 @@ namespace RTC ...@@ -44,7 +44,7 @@ namespace RTC
Protocol protocol; Protocol protocol;
uint16_t port; uint16_t port;
CandidateType type; CandidateType type;
TcpCandidateType tcpType; TcpCandidateType tcpType = TcpCandidateType::PASSIVE;
}; };
} }
......
...@@ -26,8 +26,8 @@ namespace RTC { namespace RTCP ...@@ -26,8 +26,8 @@ namespace RTC { namespace RTCP
virtual size_t GetSize() override; virtual size_t GetSize() override;
private: private:
uint8_t *data; uint8_t* data = nullptr;
size_t size; size_t size = 0;
}; };
/* Inline instance methods. */ /* Inline instance methods. */
......
...@@ -58,7 +58,7 @@ namespace RTC { namespace RTCP ...@@ -58,7 +58,7 @@ namespace RTC { namespace RTCP
private: private:
Header* header = nullptr; Header* header = nullptr;
size_t length; size_t length = 0;
}; };
// Rpsi packet declaration. // Rpsi packet declaration.
......
...@@ -88,7 +88,7 @@ namespace RTC { namespace RTCP ...@@ -88,7 +88,7 @@ namespace RTC { namespace RTCP
private: private:
// SSRC of packet sender. // SSRC of packet sender.
uint32_t ssrc; uint32_t ssrc = 0;
std::vector<ReceiverReport*> reports; std::vector<ReceiverReport*> reports;
}; };
......
...@@ -17,12 +17,22 @@ if ! type "cppcheck-htmlreport" &> /dev/null; then ...@@ -17,12 +17,22 @@ if ! type "cppcheck-htmlreport" &> /dev/null; then
exit 1 exit 1
fi fi
IGNORE_MACROS="-U SOCK_CLOEXEC -U SOCK_NONBLOCK" __IGNORE_MACROS="-U SOCK_CLOEXEC -U SOCK_NONBLOCK"
CPPCHECKS="style,performance,portability,unusedFunction" CPPCHECKS="warning,style,performance,portability,unusedFunction"
XML_FILE="/tmp/mediasoup-worker-cppcheck.xml" XML_FILE="/tmp/mediasoup-worker-cppcheck.xml"
REPORT_DIR="/tmp/mediasoup-worker-cppcheck-report" REPORT_DIR="/tmp/mediasoup-worker-cppcheck-report"
cppcheck --std=c++11 --std=posix --enable=$CPPCHECKS -v -q --error-exitcode=1 -I include src --xml 2> $XML_FILE echo ">>> [INFO] running cppcheck ..."
cppcheck --std=c++11 --enable=$CPPCHECKS -v --quiet --report-progress --inline-suppr --error-exitcode=13 -I include src --xml-version=2 2> $XML_FILE
# If exit code is 1 it means that some cppcheck option is wrong, so abort.
if [ $? -eq 1 ] ; then
echo ">>> [ERROR] cppcheck returned 1: wrong arguments" >&2
exit 1
fi
echo ">>> [INFO] running cppcheck-htmlreport ..."
cppcheck-htmlreport --title="mediasoup-worker" --file=$XML_FILE --report-dir=$REPORT_DIR --source-dir=. > /dev/null cppcheck-htmlreport --title="mediasoup-worker" --file=$XML_FILE --report-dir=$REPORT_DIR --source-dir=. > /dev/null
echo ">>> [INFO] opening HTML report ..."
open $REPORT_DIR/index.html open $REPORT_DIR/index.html
...@@ -174,7 +174,7 @@ namespace RTC ...@@ -174,7 +174,7 @@ namespace RTC
// If bind() fails for more that MAX_BIND_ATTEMPTS then raise an error. // If bind() fails for more that MAX_BIND_ATTEMPTS then raise an error.
if (bind_attempt > MAX_BIND_ATTEMPTS) if (bind_attempt > MAX_BIND_ATTEMPTS)
MS_THROW_ERROR("uv_tcp_bind() fails more than %u times for IP '%s'", MAX_BIND_ATTEMPTS, listen_ip); MS_THROW_ERROR("uv_tcp_bind() fails more than %" PRIu16 " times for IP '%s'", (uint16_t)MAX_BIND_ATTEMPTS, listen_ip);
// If we have tried all the ports in the range raise an error. // If we have tried all the ports in the range raise an error.
if (iterating_port == initial_port) if (iterating_port == initial_port)
......
...@@ -173,7 +173,7 @@ namespace RTC ...@@ -173,7 +173,7 @@ namespace RTC
// If bind() fails for more that MAX_BIND_ATTEMPTS then raise an error. // If bind() fails for more that MAX_BIND_ATTEMPTS then raise an error.
if (bind_attempt > MAX_BIND_ATTEMPTS) if (bind_attempt > MAX_BIND_ATTEMPTS)
MS_THROW_ERROR("uv_udp_bind() fails more than %u times for IP '%s'", MAX_BIND_ATTEMPTS, listen_ip); MS_THROW_ERROR("uv_udp_bind() fails more than %" PRIu16 " times for IP '%s'", (uint16_t)MAX_BIND_ATTEMPTS, listen_ip);
// If we have tried all the ports in the range raise an error. // If we have tried all the ports in the range raise an error.
if (iterating_port == initial_port) if (iterating_port == initial_port)
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论