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

C++: qualified auto (#1299)

上级 913cf8fe
...@@ -52,7 +52,7 @@ namespace RTC ...@@ -52,7 +52,7 @@ namespace RTC
static const size_t CommonHeaderSize{ 4 }; static const size_t CommonHeaderSize{ 4 };
static bool IsRtcp(const uint8_t* data, size_t len) static bool IsRtcp(const uint8_t* data, size_t len)
{ {
auto header = const_cast<CommonHeader*>(reinterpret_cast<const CommonHeader*>(data)); auto* header = const_cast<CommonHeader*>(reinterpret_cast<const CommonHeader*>(data));
// clang-format off // clang-format off
return ( return (
......
...@@ -120,7 +120,7 @@ namespace RTC ...@@ -120,7 +120,7 @@ namespace RTC
{ {
// NOTE: RtcpPacket::IsRtcp() must always be called before this method. // NOTE: RtcpPacket::IsRtcp() must always be called before this method.
auto header = const_cast<Header*>(reinterpret_cast<const Header*>(data)); auto* header = const_cast<Header*>(reinterpret_cast<const Header*>(data));
// clang-format off // clang-format off
return ( return (
......
...@@ -190,7 +190,7 @@ namespace RTC ...@@ -190,7 +190,7 @@ namespace RTC
{ {
case AF_INET: case AF_INET:
{ {
auto* remoteSockAddrIn = reinterpret_cast<const struct sockaddr_in*>(remoteSockAddr); const auto* remoteSockAddrIn = reinterpret_cast<const struct sockaddr_in*>(remoteSockAddr);
const uint64_t address = ntohl(remoteSockAddrIn->sin_addr.s_addr); const uint64_t address = ntohl(remoteSockAddrIn->sin_addr.s_addr);
const uint64_t port = (ntohs(remoteSockAddrIn->sin_port)); const uint64_t port = (ntohs(remoteSockAddrIn->sin_port));
...@@ -204,8 +204,10 @@ namespace RTC ...@@ -204,8 +204,10 @@ namespace RTC
case AF_INET6: case AF_INET6:
{ {
auto* remoteSockAddrIn6 = reinterpret_cast<const struct sockaddr_in6*>(remoteSockAddr); const auto* remoteSockAddrIn6 =
auto* a = reinterpret_cast<const uint32_t*>(std::addressof(remoteSockAddrIn6->sin6_addr)); reinterpret_cast<const struct sockaddr_in6*>(remoteSockAddr);
const auto* a =
reinterpret_cast<const uint32_t*>(std::addressof(remoteSockAddrIn6->sin6_addr));
const auto address1 = a[0] ^ a[1] ^ a[2] ^ a[3]; const auto address1 = a[0] ^ a[1] ^ a[2] ^ a[3];
const auto address2 = a[0]; const auto address2 = a[0];
......
...@@ -429,7 +429,7 @@ namespace RTC ...@@ -429,7 +429,7 @@ namespace RTC
MS_THROW_TYPE_ERROR("missing srtpParameters (SRTP enabled)"); MS_THROW_TYPE_ERROR("missing srtpParameters (SRTP enabled)");
} }
const auto srtpParameters = body->srtpParameters(); const auto* const srtpParameters = body->srtpParameters();
// Update out SRTP crypto suite with the one used by the remote. // Update out SRTP crypto suite with the one used by the remote.
auto previousSrtpCryptoSuite = this->srtpCryptoSuite; auto previousSrtpCryptoSuite = this->srtpCryptoSuite;
......
...@@ -273,7 +273,7 @@ namespace RTC ...@@ -273,7 +273,7 @@ namespace RTC
std::vector<RTC::IceCandidate> iceCandidates; std::vector<RTC::IceCandidate> iceCandidates;
uint16_t iceLocalPreferenceDecrement{ 0 }; uint16_t iceLocalPreferenceDecrement{ 0 };
for (auto& item : this->udpSocketOrTcpServers) for (const auto& item : this->udpSocketOrTcpServers)
{ {
if (item.udpSocket && enableUdp) if (item.udpSocket && enableUdp)
{ {
......
...@@ -303,7 +303,7 @@ void Settings::HandleRequest(Channel::ChannelRequest* request) ...@@ -303,7 +303,7 @@ void Settings::HandleRequest(Channel::ChannelRequest* request)
{ {
case Channel::ChannelRequest::Method::WORKER_UPDATE_SETTINGS: case Channel::ChannelRequest::Method::WORKER_UPDATE_SETTINGS:
{ {
auto body = request->data->body_as<FBS::Worker::UpdateSettingsRequest>(); const auto* body = request->data->body_as<FBS::Worker::UpdateSettingsRequest>();
if (flatbuffers::IsFieldPresent(body, FBS::Worker::UpdateSettingsRequest::VT_LOGLEVEL)) if (flatbuffers::IsFieldPresent(body, FBS::Worker::UpdateSettingsRequest::VT_LOGLEVEL))
{ {
......
...@@ -17,7 +17,7 @@ namespace Utils ...@@ -17,7 +17,7 @@ namespace Utils
return AF_UNSPEC; return AF_UNSPEC;
} }
auto ipPtr = ip.c_str(); const auto* ipPtr = ip.c_str();
char ipBuffer[INET6_ADDRSTRLEN] = { 0 }; char ipBuffer[INET6_ADDRSTRLEN] = { 0 };
if (uv_inet_pton(AF_INET, ipPtr, ipBuffer) == 0) if (uv_inet_pton(AF_INET, ipPtr, ipBuffer) == 0)
......
...@@ -84,7 +84,7 @@ namespace Utils ...@@ -84,7 +84,7 @@ namespace Utils
{ {
MS_TRACE(); MS_TRACE();
auto* data = reinterpret_cast<const uint8_t*>(str.c_str()); const auto* data = reinterpret_cast<const uint8_t*>(str.c_str());
return Base64Encode(data, str.size()); return Base64Encode(data, str.size());
} }
...@@ -186,7 +186,7 @@ namespace Utils ...@@ -186,7 +186,7 @@ namespace Utils
{ {
MS_TRACE(); MS_TRACE();
auto* data = reinterpret_cast<const uint8_t*>(str.c_str()); const auto* data = reinterpret_cast<const uint8_t*>(str.c_str());
return Base64Decode(data, str.size(), outLen); return Base64Decode(data, str.size(), outLen);
} }
......
...@@ -310,7 +310,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) ...@@ -310,7 +310,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request)
{ {
try try
{ {
const auto 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(); std::string webRtcServerId = body->webRtcServerId()->str();
...@@ -340,7 +340,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) ...@@ -340,7 +340,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request)
{ {
RTC::WebRtcServer* webRtcServer{ nullptr }; RTC::WebRtcServer* webRtcServer{ nullptr };
auto body = request->data->body_as<FBS::Worker::CloseWebRtcServerRequest>(); const auto* body = request->data->body_as<FBS::Worker::CloseWebRtcServerRequest>();
auto webRtcServerId = body->webRtcServerId()->str(); auto webRtcServerId = body->webRtcServerId()->str();
...@@ -367,7 +367,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) ...@@ -367,7 +367,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request)
case Channel::ChannelRequest::Method::WORKER_CREATE_ROUTER: case Channel::ChannelRequest::Method::WORKER_CREATE_ROUTER:
{ {
auto body = request->data->body_as<FBS::Worker::CreateRouterRequest>(); const auto* body = request->data->body_as<FBS::Worker::CreateRouterRequest>();
auto routerId = body->routerId()->str(); auto routerId = body->routerId()->str();
...@@ -395,7 +395,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) ...@@ -395,7 +395,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request)
{ {
RTC::Router* router{ nullptr }; RTC::Router* router{ nullptr };
auto body = request->data->body_as<FBS::Worker::CloseRouterRequest>(); const auto* body = request->data->body_as<FBS::Worker::CloseRouterRequest>();
auto routerId = body->routerId()->str(); auto routerId = body->routerId()->str();
......
...@@ -38,7 +38,7 @@ inline static void onWrite(uv_write_t* req, int status) ...@@ -38,7 +38,7 @@ inline static void onWrite(uv_write_t* req, int status)
auto* writeData = static_cast<TcpConnectionHandle::UvWriteData*>(req->data); auto* writeData = static_cast<TcpConnectionHandle::UvWriteData*>(req->data);
auto* handle = req->handle; auto* handle = req->handle;
auto* connection = static_cast<TcpConnectionHandle*>(handle->data); auto* connection = static_cast<TcpConnectionHandle*>(handle->data);
auto* cb = writeData->cb; const auto* cb = writeData->cb;
if (connection) if (connection)
{ {
......
...@@ -43,7 +43,7 @@ inline static void onSend(uv_udp_send_t* req, int status) ...@@ -43,7 +43,7 @@ inline static void onSend(uv_udp_send_t* req, int status)
auto* sendData = static_cast<UdpSocketHandle::UvSendData*>(req->data); auto* sendData = static_cast<UdpSocketHandle::UvSendData*>(req->data);
auto* handle = req->handle; auto* handle = req->handle;
auto* socket = static_cast<UdpSocketHandle*>(handle->data); auto* socket = static_cast<UdpSocketHandle*>(handle->data);
auto* cb = sendData->cb; const auto* cb = sendData->cb;
if (socket) if (socket)
{ {
......
...@@ -127,7 +127,7 @@ SCENARIO("Utils::IP::GetAddressInfo()") ...@@ -127,7 +127,7 @@ SCENARIO("Utils::IP::GetAddressInfo()")
sin.sin_port = htons(10251); sin.sin_port = htons(10251);
sin.sin_addr.s_addr = inet_addr("82.99.219.114"); sin.sin_addr.s_addr = inet_addr("82.99.219.114");
auto* addr = reinterpret_cast<const struct sockaddr*>(&sin); const auto* addr = reinterpret_cast<const struct sockaddr*>(&sin);
int family; int family;
std::string ip; std::string ip;
uint16_t port; uint16_t port;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论