Unverified 提交 c6517f8e authored 作者: José Luis Millán's avatar José Luis Millán 提交者: GitHub

clang-tidy C++ (#1308)

modernize clang-tidy and fix tasks.py command
上级 e485eaa4
...@@ -200,8 +200,15 @@ Runs [clang-tidy](http://clang.llvm.org/extra/clang-tidy) and performs C++ code ...@@ -200,8 +200,15 @@ Runs [clang-tidy](http://clang.llvm.org/extra/clang-tidy) and performs C++ code
- `invoke clean` and `invoke mediasoup-worker` must have been called first. - `invoke clean` and `invoke mediasoup-worker` must have been called first.
- [PyYAML](https://pyyaml.org) is required. - [PyYAML](https://pyyaml.org) is required.
- In OSX install it with `brew install libyaml` and `sudo easy_install-X.Y pyyaml`. - In OSX install it with `brew install libyaml` and `sudo easy_install-X.Y pyyaml`.
- [clang-tools-extra](https://clang.llvm.org/extra/index.html) is required.
- In OSX install it with `brew install clang-tools-extra`.
- In linux the package name is `clang-tools-extra`.
"MEDIASOUP_TIDY_CHECKS" environment variable with a comma separated list of checks overrides the checks defined in `.clang-tidy` file. **Environment variables**
- "MEDIASOUP_TIDY_CHECKS": comma separated list of checks. Overrides the checks defined in `.clang-tidy` file.
- "MEDIASOUP_TIDY_FILES": space separated source files to process, including their path. All .cpp files will be processes by default.
- "MEDIASOUP_CLANG_TIDY_DIR": path to directory containing clang tools (run-clang-tidy, clang-tidy, clang-apply-replacements).
### `invoke fuzzer` ### `invoke fuzzer`
......
--- ---
Checks: "*,\ Checks: "*,\
-altera*,\ -altera*,\
-android*,\
-boost-use-to-string,\ -boost-use-to-string,\
-bugprone-easily-swappable-parameters,\ -bugprone-easily-swappable-parameters,\
-bugprone-implicit-widening-of-multiplication-result,\
-bugprone-lambda-function-name,\ -bugprone-lambda-function-name,\
-bugprone-macro-parentheses,\ -bugprone-macro-parentheses,\
-bugprone-reserved-identifier,\
-cert-*,\ -cert-*,\
-clang-analyzer-optin.osx.*,\ -clang-analyzer-optin.osx.*,\
-clang-analyzer-osx.*,\ -clang-analyzer-osx.*,\
-cppcoreguidelines-avoid-c-arrays,\ -cppcoreguidelines-avoid-c-arrays,\
-cppcoreguidelines-avoid-do-while,\ -cppcoreguidelines-avoid-do-while,\
-cppcoreguidelines-avoid-goto,\ -cppcoreguidelines-avoid-goto,\
-cppcoreguidelines-avoid-non-const-global-variables,\
-cppcoreguidelines-avoid-magic-numbers,\ -cppcoreguidelines-avoid-magic-numbers,\
-cppcoreguidelines-init-variables,\ -cppcoreguidelines-init-variables,\
-cppcoreguidelines-no-malloc,\ -cppcoreguidelines-no-malloc,\
-cppcoreguidelines-non-private-member-variables-in-classes,\ -cppcoreguidelines-non-private-member-variables-in-classes,\
-cppcoreguidelines-owning-memory,\ -cppcoreguidelines-owning-memory,\
-cppcoreguidelines-prefer-member-initializer,\
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,\ -cppcoreguidelines-pro-bounds-array-to-pointer-decay,\
-cppcoreguidelines-pro-bounds-constant-array-index,\ -cppcoreguidelines-pro-bounds-constant-array-index,\
-cppcoreguidelines-pro-bounds-pointer-arithmetic,\ -cppcoreguidelines-pro-bounds-pointer-arithmetic,\
...@@ -27,9 +32,11 @@ Checks: "*,\ ...@@ -27,9 +32,11 @@ Checks: "*,\
-cppcoreguidelines-special-member-functions,\ -cppcoreguidelines-special-member-functions,\
-fuchsia-default-arguments-calls,\ -fuchsia-default-arguments-calls,\
-fuchsia-default-arguments-declarations,\ -fuchsia-default-arguments-declarations,\
-fuchsia-overloaded-operator,\
-google-default-arguments,\ -google-default-arguments,\
-google-readability-*,\ -google-readability-*,\
-google-runtime-references,\ -google-runtime-references,\
-google-upgrade-googletest-case,\
-hicpp-avoid-c-arrays,\ -hicpp-avoid-c-arrays,\
-hicpp-avoid-goto,\ -hicpp-avoid-goto,\
-hicpp-braces-around-statements,\ -hicpp-braces-around-statements,\
...@@ -42,7 +49,9 @@ Checks: "*,\ ...@@ -42,7 +49,9 @@ Checks: "*,\
-llvm-header-guard,\ -llvm-header-guard,\
-llvm-else-after-return,\ -llvm-else-after-return,\
-llvmlibc-*,\ -llvmlibc-*,\
-misc-confusable-identifiers,\
-misc-non-private-member-variables-in-classes,\ -misc-non-private-member-variables-in-classes,\
-misc-use-anonymous-namespace,\
-modernize-avoid-c-arrays,\ -modernize-avoid-c-arrays,\
-modernize-concat-nested-namespaces,\ -modernize-concat-nested-namespaces,\
-modernize-make-unique,\ -modernize-make-unique,\
...@@ -59,7 +68,6 @@ Checks: "*,\ ...@@ -59,7 +68,6 @@ Checks: "*,\
-readability-uppercase-literal-suffix,\ -readability-uppercase-literal-suffix,\
" "
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false AnalyzeTemporaryDtors: false
User: mediasoup User: mediasoup
FormatStyle: file FormatStyle: file
...@@ -332,7 +340,7 @@ CheckOptions: ...@@ -332,7 +340,7 @@ CheckOptions:
- key: readability-identifier-naming.UnionSuffix - key: readability-identifier-naming.UnionSuffix
value: '' value: ''
- key: readability-identifier-naming.ValueTemplateParameterCase - key: readability-identifier-naming.ValueTemplateParameterCase
value: camelBack value: CamelCase
- key: readability-identifier-naming.ValueTemplateParameterPrefix - key: readability-identifier-naming.ValueTemplateParameterPrefix
value: '' value: ''
- key: readability-identifier-naming.ValueTemplateParameterSuffix - key: readability-identifier-naming.ValueTemplateParameterSuffix
......
...@@ -53,7 +53,7 @@ namespace Channel ...@@ -53,7 +53,7 @@ namespace Channel
void TypeError(const char* reason = nullptr); void TypeError(const char* reason = nullptr);
private: private:
void Send(uint8_t* buffer, size_t size); void Send(uint8_t* buffer, size_t size) const;
void SendResponse(const flatbuffers::Offset<FBS::Response::Response>& response); void SendResponse(const flatbuffers::Offset<FBS::Response::Response>& response);
public: public:
......
...@@ -210,8 +210,7 @@ namespace RTC ...@@ -210,8 +210,7 @@ namespace RTC
{ {
public: public:
RtpHeaderExtensionParameters() = default; RtpHeaderExtensionParameters() = default;
explicit RtpHeaderExtensionParameters( explicit RtpHeaderExtensionParameters(const FBS::RtpParameters::RtpHeaderExtensionParameters* data);
const FBS::RtpParameters::RtpHeaderExtensionParameters* const data);
flatbuffers::Offset<FBS::RtpParameters::RtpHeaderExtensionParameters> FillBuffer( flatbuffers::Offset<FBS::RtpParameters::RtpHeaderExtensionParameters> FillBuffer(
flatbuffers::FlatBufferBuilder& builder) const; flatbuffers::FlatBufferBuilder& builder) const;
......
...@@ -18,21 +18,21 @@ namespace RTC ...@@ -18,21 +18,21 @@ namespace RTC
public: public:
struct SeqLowerThan struct SeqLowerThan
{ {
bool operator()(const T lhs, const T rhs) const; bool operator()(T lhs, T rhs) const;
}; };
struct SeqHigherThan struct SeqHigherThan
{ {
bool operator()(const T lhs, const T rhs) const; bool operator()(T lhs, T rhs) const;
}; };
private: private:
static const SeqLowerThan isSeqLowerThan; static const SeqLowerThan isSeqLowerThan; // NOLINT(readability-identifier-naming)
static const SeqHigherThan isSeqHigherThan; static const SeqHigherThan isSeqHigherThan; // NOLINT(readability-identifier-naming)
public: public:
static bool IsSeqLowerThan(const T lhs, const T rhs); static bool IsSeqLowerThan(T lhs, T rhs);
static bool IsSeqHigherThan(const T lhs, const T rhs); static bool IsSeqHigherThan(T lhs, T rhs);
public: public:
SeqManager() = default; SeqManager() = default;
...@@ -40,7 +40,7 @@ namespace RTC ...@@ -40,7 +40,7 @@ namespace RTC
public: public:
void Sync(T input); void Sync(T input);
void Drop(T input); void Drop(T input);
bool Input(const T input, T& output); bool Input(T input, T& output);
T GetMaxInput() const; T GetMaxInput() const;
T GetMaxOutput() const; T GetMaxOutput() const;
......
...@@ -55,8 +55,8 @@ public: ...@@ -55,8 +55,8 @@ public:
thread_local static struct Configuration configuration; thread_local static struct Configuration configuration;
private: private:
static absl::flat_hash_map<std::string, LogLevel> string2LogLevel; static absl::flat_hash_map<std::string, LogLevel> String2LogLevel; // NOLINT(readability-identifier-naming)
static absl::flat_hash_map<LogLevel, std::string> logLevel2String; static absl::flat_hash_map<LogLevel, std::string> LogLevel2String; // NOLINT(readability-identifier-naming)
}; };
#endif #endif
...@@ -57,9 +57,7 @@ namespace Utils ...@@ -57,9 +57,7 @@ namespace Utils
std::memcmp( std::memcmp(
std::addressof(reinterpret_cast<const struct sockaddr_in6*>(addr1)->sin6_addr), std::addressof(reinterpret_cast<const struct sockaddr_in6*>(addr1)->sin6_addr),
std::addressof(reinterpret_cast<const struct sockaddr_in6*>(addr2)->sin6_addr), std::addressof(reinterpret_cast<const struct sockaddr_in6*>(addr2)->sin6_addr),
16) == 0 16) == 0);
? true
: false);
} }
default: default:
...@@ -71,7 +69,9 @@ namespace Utils ...@@ -71,7 +69,9 @@ namespace Utils
static struct sockaddr_storage CopyAddress(const struct sockaddr* addr) static struct sockaddr_storage CopyAddress(const struct sockaddr* addr)
{ {
struct sockaddr_storage copiedAddr; struct sockaddr_storage copiedAddr
{
};
switch (addr->sa_family) switch (addr->sa_family)
{ {
...@@ -125,7 +125,7 @@ namespace Utils ...@@ -125,7 +125,7 @@ namespace Utils
auto byte0 = data[i + 2]; // The less significant byte. auto byte0 = data[i + 2]; // The less significant byte.
// Check bit 7 (sign). // Check bit 7 (sign).
uint8_t extension = byte2 & 0b10000000 ? 0b11111111 : 0b00000000; const uint8_t extension = byte2 & 0b10000000 ? 0b11111111 : 0b00000000;
return int32_t{ byte0 } | (int32_t{ byte1 } << 8) | (int32_t{ byte2 } << 16) | return int32_t{ byte0 } | (int32_t{ byte1 } << 8) | (int32_t{ byte2 } << 16) |
(int32_t{ extension } << 24); (int32_t{ extension } << 24);
...@@ -252,10 +252,10 @@ namespace Utils ...@@ -252,10 +252,10 @@ namespace Utils
return (((Crypto::seed >> 4) & 0x7FFF7FFF) % (max - min + 1)) + min; return (((Crypto::seed >> 4) & 0x7FFF7FFF) % (max - min + 1)) + min;
} }
static const std::string GetRandomString(size_t len) static std::string GetRandomString(size_t len)
{ {
char buffer[64]; char buffer[64];
static const char chars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', static const char Chars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b',
'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
...@@ -266,10 +266,10 @@ namespace Utils ...@@ -266,10 +266,10 @@ namespace Utils
for (size_t i{ 0 }; i < len; ++i) for (size_t i{ 0 }; i < len; ++i)
{ {
buffer[i] = chars[GetRandomUInt(0, sizeof(chars) - 1)]; buffer[i] = Chars[GetRandomUInt(0, sizeof(Chars) - 1)];
} }
return std::string(buffer, len); return { buffer, len };
} }
static uint32_t GetCRC32(const uint8_t* data, size_t size) static uint32_t GetCRC32(const uint8_t* data, size_t size)
...@@ -279,7 +279,7 @@ namespace Utils ...@@ -279,7 +279,7 @@ namespace Utils
while (size--) while (size--)
{ {
crc = Crypto::crc32Table[(crc ^ *p++) & 0xFF] ^ (crc >> 8); crc = Crypto::Crc32Table[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
} }
return crc ^ ~0U; return crc ^ ~0U;
...@@ -292,7 +292,7 @@ namespace Utils ...@@ -292,7 +292,7 @@ namespace Utils
thread_local static EVP_MAC* mac; thread_local static EVP_MAC* mac;
thread_local static EVP_MAC_CTX* hmacSha1Ctx; thread_local static EVP_MAC_CTX* hmacSha1Ctx;
thread_local static uint8_t hmacSha1Buffer[]; thread_local static uint8_t hmacSha1Buffer[];
static const uint32_t crc32Table[256]; static const uint32_t Crc32Table[256];
}; };
class String class String
...@@ -328,7 +328,7 @@ namespace Utils ...@@ -328,7 +328,7 @@ namespace Utils
static Time::Ntp TimeMs2Ntp(uint64_t ms) static Time::Ntp TimeMs2Ntp(uint64_t ms)
{ {
Time::Ntp ntp; // NOLINT(cppcoreguidelines-pro-type-member-init) Time::Ntp ntp{}; // NOLINT(cppcoreguidelines-pro-type-member-init)
ntp.seconds = ms / 1000; ntp.seconds = ms / 1000;
ntp.fractions = ntp.fractions =
......
...@@ -30,7 +30,7 @@ private: ...@@ -30,7 +30,7 @@ private:
RTC::WebRtcServer* GetWebRtcServer(const std::string& webRtcServerId) const; RTC::WebRtcServer* GetWebRtcServer(const std::string& webRtcServerId) const;
RTC::Router* GetRouter(const std::string& routerId) const; RTC::Router* GetRouter(const std::string& routerId) const;
void CheckNoWebRtcServer(const std::string& webRtcServerId) const; void CheckNoWebRtcServer(const std::string& webRtcServerId) const;
void CheckNoRouter(const std::string& webRtcServerId) const; void CheckNoRouter(const std::string& routerId) const;
/* Methods inherited from Channel::ChannelSocket::RequestHandler. */ /* Methods inherited from Channel::ChannelSocket::RequestHandler. */
public: public:
......
...@@ -84,8 +84,10 @@ private: ...@@ -84,8 +84,10 @@ private:
/* Callbacks fired by UV events. */ /* Callbacks fired by UV events. */
public: public:
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
void OnUvRecvAlloc(size_t suggestedSize, uv_buf_t* buf); void OnUvRecvAlloc(size_t suggestedSize, uv_buf_t* buf);
void OnUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags); void OnUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags);
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
void OnUvSend(int status, UdpSocketHandle::onSendCallback* cb); void OnUvSend(int status, UdpSocketHandle::onSendCallback* cb);
/* Pure virtual methods that must be implemented by the subclass. */ /* Pure virtual methods that must be implemented by the subclass. */
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
}, },
"dependencies": { "dependencies": {
"clang-format": "^1.8.0", "clang-format": "^1.8.0",
"clang-tools-prebuilt": "^0.1.4",
"glob": "^10.3.10" "glob": "^10.3.10"
} }
} }
...@@ -156,7 +156,7 @@ namespace Channel ...@@ -156,7 +156,7 @@ namespace Channel
this->SendResponse(response); this->SendResponse(response);
} }
void ChannelRequest::Send(uint8_t* buffer, size_t size) void ChannelRequest::Send(uint8_t* buffer, size_t size) const
{ {
this->channel->Send(buffer, size); this->channel->Send(buffer, size);
} }
......
...@@ -62,7 +62,7 @@ namespace RTC ...@@ -62,7 +62,7 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
size_t len = static_cast<size_t>(ntohs(commonHeader->length) + 1) * 4; const size_t len = static_cast<size_t>(ntohs(commonHeader->length) + 1) * 4;
if (len > availableLen) if (len > availableLen)
{ {
...@@ -86,8 +86,8 @@ namespace RTC ...@@ -86,8 +86,8 @@ namespace RTC
// Make contentData point to the beginning of the chunks. // Make contentData point to the beginning of the chunks.
uint8_t* contentData = data + FeedbackRtpTransportPacket::fixedHeaderSize; uint8_t* contentData = data + FeedbackRtpTransportPacket::fixedHeaderSize;
// Make contentLen be the available length for chunks. // Make contentLen be the available length for chunks.
size_t contentLen = len - Packet::CommonHeaderSize - FeedbackPacket::HeaderSize - const size_t contentLen = len - Packet::CommonHeaderSize - FeedbackPacket::HeaderSize -
FeedbackRtpTransportPacket::fixedHeaderSize; FeedbackRtpTransportPacket::fixedHeaderSize;
size_t offset{ 0u }; size_t offset{ 0u };
uint16_t count{ 0u }; uint16_t count{ 0u };
uint16_t receivedPacketStatusCount{ 0u }; uint16_t receivedPacketStatusCount{ 0u };
...@@ -618,8 +618,8 @@ namespace RTC ...@@ -618,8 +618,8 @@ namespace RTC
return nullptr; return nullptr;
} }
auto bytes = Utils::Byte::Get2Bytes(data, 0); auto bytes = Utils::Byte::Get2Bytes(data, 0);
uint8_t chunkType = (bytes >> 15) & 0x01; const uint8_t chunkType = (bytes >> 15) & 0x01;
// Run length chunk. // Run length chunk.
if (chunkType == 0) if (chunkType == 0)
...@@ -649,7 +649,7 @@ namespace RTC ...@@ -649,7 +649,7 @@ namespace RTC
// Vector chunk. // Vector chunk.
else else
{ {
uint8_t symbolSize = data[0] & 0x40; const uint8_t symbolSize = data[0] & 0x40;
if (symbolSize == 0) if (symbolSize == 0)
{ {
...@@ -750,7 +750,8 @@ namespace RTC ...@@ -750,7 +750,8 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
bool received = (this->status == Status::SmallDelta || this->status == Status::LargeDelta); const bool received =
(this->status == Status::SmallDelta || this->status == Status::LargeDelta);
for (uint16_t count{ 1u }; count <= this->count; ++count) for (uint16_t count{ 1u }; count <= this->count; ++count)
{ {
...@@ -875,7 +876,7 @@ namespace RTC ...@@ -875,7 +876,7 @@ namespace RTC
for (auto status : this->statuses) for (auto status : this->statuses)
{ {
bool received = (status == Status::SmallDelta || status == Status::LargeDelta); const bool received = (status == Status::SmallDelta || status == Status::LargeDelta);
packetResults.emplace_back(++currentSequenceNumber, received); packetResults.emplace_back(++currentSequenceNumber, received);
} }
...@@ -1015,7 +1016,7 @@ namespace RTC ...@@ -1015,7 +1016,7 @@ namespace RTC
for (auto status : this->statuses) for (auto status : this->statuses)
{ {
bool received = (status == Status::SmallDelta || status == Status::LargeDelta); const bool received = (status == Status::SmallDelta || status == Status::LargeDelta);
packetResults.emplace_back(++currentSequenceNumber, received); packetResults.emplace_back(++currentSequenceNumber, received);
} }
......
...@@ -54,8 +54,8 @@ namespace RTC ...@@ -54,8 +54,8 @@ namespace RTC
return first; return first;
} }
auto* header = const_cast<CommonHeader*>(reinterpret_cast<const CommonHeader*>(data)); auto* header = const_cast<CommonHeader*>(reinterpret_cast<const CommonHeader*>(data));
size_t packetLen = static_cast<size_t>(ntohs(header->length) + 1) * 4; const size_t packetLen = static_cast<size_t>(ntohs(header->length) + 1) * 4;
if (len < packetLen) if (len < packetLen)
{ {
......
...@@ -56,23 +56,23 @@ namespace RTC ...@@ -56,23 +56,23 @@ namespace RTC
if (!this->recvTransportId.empty()) if (!this->recvTransportId.empty())
{ {
std::cout << ", \"recvTransportId\": \"" << this->recvTransportId << "\""; std::cout << R"(, "recvTransportId": ")" << this->recvTransportId << "\"";
} }
if (!this->sendTransportId.empty()) if (!this->sendTransportId.empty())
{ {
std::cout << ", \"sendTransportId\": \"" << this->sendTransportId << "\""; std::cout << R"(, "sendTransportId": ")" << this->sendTransportId << "\"";
} }
if (!this->routerId.empty()) if (!this->routerId.empty())
{ {
std::cout << ", \"routerId\": \"" << this->routerId << "\""; std::cout << R"(, "routerId": ")" << this->routerId << "\"";
} }
if (!this->producerId.empty()) if (!this->producerId.empty())
{ {
std::cout << ", \"producerId\": \"" << this->producerId << "\""; std::cout << R"(, "producerId": ")" << this->producerId << "\"";
} }
if (!this->consumerId.empty()) if (!this->consumerId.empty())
{ {
std::cout << ", \"consumerId\": \"" << this->consumerId << "\""; std::cout << R"(, "consumerId": ")" << this->consumerId << "\"";
} }
std::cout << ", \"recvRtpTimestamp\": " << this->recvRtpTimestamp; std::cout << ", \"recvRtpTimestamp\": " << this->recvRtpTimestamp;
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "Logger.hpp" #include "Logger.hpp"
#include "MediaSoupErrors.hpp" #include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "RTC/RtpDictionaries.hpp" #include "RTC/RtpDictionaries.hpp"
namespace RTC namespace RTC
......
...@@ -127,6 +127,7 @@ namespace RTC ...@@ -127,6 +127,7 @@ namespace RTC
int ret; int ret;
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
this->socket = usrsctp_socket( this->socket = usrsctp_socket(
AF_CONN, AF_CONN,
SOCK_STREAM, SOCK_STREAM,
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "Logger.hpp" #include "Logger.hpp"
#include "MediaSoupErrors.hpp" #include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "RTC/SctpDictionaries.hpp" #include "RTC/SctpDictionaries.hpp"
namespace RTC namespace RTC
......
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
namespace RTC namespace RTC
{ {
template<typename T, uint8_t N> template<typename T, uint8_t N>
bool SeqManager<T, N>::SeqLowerThan::operator()(const T lhs, const T rhs) const bool SeqManager<T, N>::SeqLowerThan::operator()(T lhs, T rhs) const
{ {
return ((rhs > lhs) && (rhs - lhs <= MaxValue / 2)) || return ((rhs > lhs) && (rhs - lhs <= MaxValue / 2)) ||
((lhs > rhs) && (lhs - rhs > MaxValue / 2)); ((lhs > rhs) && (lhs - rhs > MaxValue / 2));
} }
template<typename T, uint8_t N> template<typename T, uint8_t N>
bool SeqManager<T, N>::SeqHigherThan::operator()(const T lhs, const T rhs) const bool SeqManager<T, N>::SeqHigherThan::operator()(T lhs, T rhs) const
{ {
return ((lhs > rhs) && (lhs - rhs <= MaxValue / 2)) || return ((lhs > rhs) && (lhs - rhs <= MaxValue / 2)) ||
((rhs > lhs) && (rhs - lhs > MaxValue / 2)); ((rhs > lhs) && (rhs - lhs > MaxValue / 2));
...@@ -28,13 +28,13 @@ namespace RTC ...@@ -28,13 +28,13 @@ namespace RTC
const typename SeqManager<T, N>::SeqHigherThan SeqManager<T, N>::isSeqHigherThan{}; const typename SeqManager<T, N>::SeqHigherThan SeqManager<T, N>::isSeqHigherThan{};
template<typename T, uint8_t N> template<typename T, uint8_t N>
bool SeqManager<T, N>::IsSeqLowerThan(const T lhs, const T rhs) bool SeqManager<T, N>::IsSeqLowerThan(T lhs, T rhs)
{ {
return isSeqLowerThan(lhs, rhs); return isSeqLowerThan(lhs, rhs);
} }
template<typename T, uint8_t N> template<typename T, uint8_t N>
bool SeqManager<T, N>::IsSeqHigherThan(const T lhs, const T rhs) bool SeqManager<T, N>::IsSeqHigherThan(T lhs, T rhs)
{ {
return isSeqHigherThan(lhs, rhs); return isSeqHigherThan(lhs, rhs);
} }
...@@ -69,7 +69,7 @@ namespace RTC ...@@ -69,7 +69,7 @@ namespace RTC
} }
template<typename T, uint8_t N> template<typename T, uint8_t N>
bool SeqManager<T, N>::Input(const T input, T& output) bool SeqManager<T, N>::Input(T input, T& output)
{ {
auto base = this->base; auto base = this->base;
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "DepLibUV.hpp" #include "DepLibUV.hpp"
#include "Logger.hpp" #include "Logger.hpp"
#include "MediaSoupErrors.hpp" #include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "RTC/Codecs/Tools.hpp" #include "RTC/Codecs/Tools.hpp"
namespace RTC namespace RTC
......
...@@ -2260,6 +2260,7 @@ namespace RTC ...@@ -2260,6 +2260,7 @@ namespace RTC
auto* consumer = it->second; auto* consumer = it->second;
auto bweType = this->tccClient->GetBweType(); auto bweType = this->tccClient->GetBweType();
// NOLINTNEXTLINE(bugprone-too-small-loop-variable)
for (uint8_t i{ 1u }; i <= (baseAllocation ? 1u : priority); ++i) for (uint8_t i{ 1u }; i <= (baseAllocation ? 1u : priority); ++i)
{ {
uint32_t usedBitrate{ 0u }; uint32_t usedBitrate{ 0u };
......
...@@ -24,14 +24,14 @@ static std::mutex GlobalSyncMutex; ...@@ -24,14 +24,14 @@ static std::mutex GlobalSyncMutex;
thread_local struct Settings::Configuration Settings::configuration; thread_local struct Settings::Configuration Settings::configuration;
// clang-format off // clang-format off
absl::flat_hash_map<std::string, LogLevel> Settings::string2LogLevel = absl::flat_hash_map<std::string, LogLevel> Settings::String2LogLevel =
{ {
{ "debug", LogLevel::LOG_DEBUG }, { "debug", LogLevel::LOG_DEBUG },
{ "warn", LogLevel::LOG_WARN }, { "warn", LogLevel::LOG_WARN },
{ "error", LogLevel::LOG_ERROR }, { "error", LogLevel::LOG_ERROR },
{ "none", LogLevel::LOG_NONE } { "none", LogLevel::LOG_NONE }
}; };
absl::flat_hash_map<LogLevel, std::string> Settings::logLevel2String = absl::flat_hash_map<LogLevel, std::string> Settings::LogLevel2String =
{ {
{ LogLevel::LOG_DEBUG, "debug" }, { LogLevel::LOG_DEBUG, "debug" },
{ LogLevel::LOG_WARN, "warn" }, { LogLevel::LOG_WARN, "warn" },
...@@ -275,7 +275,7 @@ void Settings::PrintConfiguration() ...@@ -275,7 +275,7 @@ void Settings::PrintConfiguration()
MS_DEBUG_TAG( MS_DEBUG_TAG(
info, info,
" logLevel : %s", " logLevel : %s",
Settings::logLevel2String[Settings::configuration.logLevel].c_str()); Settings::LogLevel2String[Settings::configuration.logLevel].c_str());
MS_DEBUG_TAG(info, " logTags : %s", logTagsStream.str().c_str()); MS_DEBUG_TAG(info, " logTags : %s", logTagsStream.str().c_str());
MS_DEBUG_TAG(info, " rtcMinPort : %" PRIu16, Settings::configuration.rtcMinPort); MS_DEBUG_TAG(info, " rtcMinPort : %" PRIu16, Settings::configuration.rtcMinPort);
MS_DEBUG_TAG(info, " rtcMaxPort : %" PRIu16, Settings::configuration.rtcMaxPort); MS_DEBUG_TAG(info, " rtcMaxPort : %" PRIu16, Settings::configuration.rtcMaxPort);
...@@ -348,12 +348,12 @@ void Settings::SetLogLevel(std::string& level) ...@@ -348,12 +348,12 @@ void Settings::SetLogLevel(std::string& level)
// Lowcase given level. // Lowcase given level.
Utils::String::ToLowerCase(level); Utils::String::ToLowerCase(level);
if (Settings::string2LogLevel.find(level) == Settings::string2LogLevel.end()) if (Settings::String2LogLevel.find(level) == Settings::String2LogLevel.end())
{ {
MS_THROW_TYPE_ERROR("invalid value '%s' for logLevel", level.c_str()); MS_THROW_TYPE_ERROR("invalid value '%s' for logLevel", level.c_str());
} }
Settings::configuration.logLevel = Settings::string2LogLevel[level]; Settings::configuration.logLevel = Settings::String2LogLevel[level];
} }
void Settings::SetLogTags(const std::vector<std::string>& tags) void Settings::SetLogTags(const std::vector<std::string>& tags)
......
...@@ -14,7 +14,7 @@ namespace Utils ...@@ -14,7 +14,7 @@ namespace Utils
thread_local EVP_MAC_CTX* Crypto::hmacSha1Ctx{ nullptr }; thread_local EVP_MAC_CTX* Crypto::hmacSha1Ctx{ nullptr };
thread_local uint8_t Crypto::hmacSha1Buffer[SHA_DIGEST_LENGTH]; thread_local uint8_t Crypto::hmacSha1Buffer[SHA_DIGEST_LENGTH];
// clang-format off // clang-format off
const uint32_t Crypto::crc32Table[] = const uint32_t Crypto::Crc32Table[] =
{ {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
......
...@@ -77,7 +77,7 @@ namespace Utils ...@@ -77,7 +77,7 @@ namespace Utils
*pos++ = '='; *pos++ = '=';
} }
return std::string(reinterpret_cast<const char*>(out), pos - out); return { reinterpret_cast<const char*>(out), static_cast<size_t>(pos - out) };
} }
std::string Utils::String::Base64Encode(const std::string& str) std::string Utils::String::Base64Encode(const std::string& str)
......
...@@ -312,7 +312,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) ...@@ -312,7 +312,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request)
{ {
const auto* const body = request->data->body_as<FBS::Worker::CreateWebRtcServerRequest>(); const auto* const body = request->data->body_as<FBS::Worker::CreateWebRtcServerRequest>();
std::string webRtcServerId = body->webRtcServerId()->str(); const std::string webRtcServerId = body->webRtcServerId()->str();
CheckNoWebRtcServer(webRtcServerId); CheckNoWebRtcServer(webRtcServerId);
......
...@@ -187,6 +187,7 @@ void TcpConnectionHandle::Start() ...@@ -187,6 +187,7 @@ void TcpConnectionHandle::Start()
return; return;
} }
// NOLINTNEXTLINE(misc-const-correctness)
int err = uv_read_start( int err = uv_read_start(
reinterpret_cast<uv_stream_t*>(this->uvHandle), reinterpret_cast<uv_stream_t*>(this->uvHandle),
static_cast<uv_alloc_cb>(onAlloc), static_cast<uv_alloc_cb>(onAlloc),
......
...@@ -66,11 +66,10 @@ UdpSocketHandle::UdpSocketHandle(uv_udp_t* uvHandle) : uvHandle(uvHandle) ...@@ -66,11 +66,10 @@ UdpSocketHandle::UdpSocketHandle(uv_udp_t* uvHandle) : uvHandle(uvHandle)
{ {
MS_TRACE(); MS_TRACE();
int err;
this->uvHandle->data = static_cast<void*>(this); this->uvHandle->data = static_cast<void*>(this);
err = uv_udp_recv_start( // NOLINTNEXTLINE(misc-const-correctness)
int err = uv_udp_recv_start(
this->uvHandle, static_cast<uv_alloc_cb>(onAlloc), static_cast<uv_udp_recv_cb>(onRecv)); this->uvHandle, static_cast<uv_alloc_cb>(onAlloc), static_cast<uv_udp_recv_cb>(onRecv));
if (err != 0) if (err != 0)
......
...@@ -441,10 +441,22 @@ def tidy(ctx): ...@@ -441,10 +441,22 @@ def tidy(ctx):
Perform C++ checks with clang-tidy Perform C++ checks with clang-tidy
""" """
mediasoup_tidy_checks = os.getenv('MEDIASOUP_TIDY_CHECKS') or ''; mediasoup_tidy_checks = os.getenv('MEDIASOUP_TIDY_CHECKS') or '';
mediasoup_tidy_files = os.getenv('MEDIASOUP_TIDY_FILES') or '';
mediasoup_clang_tidy_dir = os.getenv('MEDIASOUP_CLANG_TIDY_DIR');
if not mediasoup_clang_tidy_dir:
print('missing MEDIASOUP_CLANG_TIDY_DIR env varialbe');
return;
if mediasoup_tidy_checks:
mediasoup_tidy_checks = '-*,' + mediasoup_tidy_checks;
if not mediasoup_tidy_files:
mediasoup_tidy_files = 'src/*.cpp src/**/*.cpp src/**/**.cpp';
with ctx.cd(f'"{WORKER_DIR}"'): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{PYTHON}" ./scripts/clang-tidy.py -clang-tidy-binary=./scripts/node_modules/.bin/clang-tidy -clang-apply-replacements-binary=./scripts/node_modules/.bin/clang-apply-replacements -header-filter="(Channel/**/*.hpp|DepLibSRTP.hpp|DepLibUV.hpp|DepLibWebRTC.hpp|DepOpenSSL.hpp|DepUsrSCTP.hpp|LogLevel.hpp|Logger.hpp|MediaSoupError.hpp|RTC/**/*.hpp|Settings.hpp|Utils.hpp|Worker.hpp|common.hpp|handles/**/*.hpp)" -p="{BUILD_DIR}" -j={NUM_CORES} -checks={mediasoup_tidy_checks} -quiet', f'"{PYTHON}" "{mediasoup_clang_tidy_dir}/run-clang-tidy" -clang-tidy-binary="{mediasoup_clang_tidy_dir}/clang-tidy" -clang-apply-replacements-binary="{mediasoup_clang_tidy_dir}/clang-apply-replacements" -p=./ -j={NUM_CORES} -fix -checks={mediasoup_tidy_checks} {mediasoup_tidy_files}',
echo=True, echo=True,
pty=PTY_SUPPORTED, pty=PTY_SUPPORTED,
shell=SHELL shell=SHELL
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论