Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
strseb committed Apr 11, 2024
1 parent eb98e29 commit f2e3dd3
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions src/platforms/windows/windowspingsender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct ICMP_ECHO_REPLY_BUFFER {
#pragma pack(pop)

// If the Size is not the MinimumReplyBufferSize, the compiler added
// padding, so the fields will not be properly aligned with
// padding, so the fields will not be properly aligned with
// what IcmpSendEcho2 will write.
static_assert(sizeof(ICMP_ECHO_REPLY_BUFFER) == MinimumReplyBufferSize,
"Fulfills the size requirements");
Expand All @@ -72,8 +72,6 @@ struct WindowsPingSenderPrivate {
ICMP_ECHO_REPLY_BUFFER m_replyBuffer;
};



namespace {
Logger logger("WindowsPingSender");
}
Expand Down Expand Up @@ -131,32 +129,32 @@ void WindowsPingSender::sendPing(const QHostAddress& dest, quint16 sequence) {

quint32 v4dst = dest.toIPv4Address();
if (m_source.isNull()) {
IcmpSendEcho2(m_private->m_handle, // IcmpHandle,
m_private->m_event, // Event
nullptr, // ApcRoutine
nullptr, // ApcContext
qToBigEndian<quint32>(v4dst), // DestinationAddress
&sequence, // RequestData
sizeof(sequence), // RequestSize
nullptr, // RequestOptions
&m_private->m_replyBuffer, // [OUT] ReplyBuffer
IcmpSendEcho2(m_private->m_handle, // IcmpHandle,
m_private->m_event, // Event
nullptr, // ApcRoutine
nullptr, // ApcContext
qToBigEndian<quint32>(v4dst), // DestinationAddress
&sequence, // RequestData
sizeof(sequence), // RequestSize
nullptr, // RequestOptions
&m_private->m_replyBuffer, // [OUT] ReplyBuffer
sizeof(m_private->m_replyBuffer), // ReplySize
10000 // Timeout
10000 // Timeout
);
} else {
quint32 v4src = m_source.toIPv4Address();
IcmpSendEcho2Ex(m_private->m_handle, // IcmpHandle
m_private->m_event, // Event
nullptr, // ApcRoutine
nullptr, // ApcContext
qToBigEndian<quint32>(v4src), // SourceAddress
qToBigEndian<quint32>(v4dst), // DestinationAddress
&sequence, // RequestData
sizeof(sequence), // RequestSize
nullptr, // RequestOptions
IcmpSendEcho2Ex(m_private->m_handle, // IcmpHandle
m_private->m_event, // Event
nullptr, // ApcRoutine
nullptr, // ApcContext
qToBigEndian<quint32>(v4src), // SourceAddress
qToBigEndian<quint32>(v4dst), // DestinationAddress
&sequence, // RequestData
sizeof(sequence), // RequestSize
nullptr, // RequestOptions
&m_private->m_replyBuffer, // [OUT] ReplyBuffer
sizeof(m_private->m_replyBuffer), // ReplySize
10000 // Timeout
sizeof(m_private->m_replyBuffer), // ReplySize
10000 // Timeout
);
}

Expand All @@ -171,9 +169,7 @@ void WindowsPingSender::sendPing(const QHostAddress& dest, quint16 sequence) {

void WindowsPingSender::pingEventReady() {
// Cleanup all data once we're done with m_replyBuffer.
const auto guard = qScopeGuard([this](){
m_private->m_replyBuffer = {};
});
const auto guard = qScopeGuard([this]() { m_private->m_replyBuffer = {}; });

DWORD replyCount = IcmpParseReplies(&m_private->m_replyBuffer,
sizeof(m_private->m_replyBuffer));
Expand All @@ -187,16 +183,16 @@ void WindowsPingSender::pingEventReady() {
<< " Message: " << errmsg;
return;
}
// We only allocated for one reply, so more should be impossible.
if (replyCount != 1){
// We only allocated for one reply, so more should be impossible.
if (replyCount != 1) {
logger.error() << "Invalid amount of responses recieved";
return;
}
if (m_private->m_replyBuffer.reply.Data == nullptr) {
logger.error() << "Did get a ping response without payload";
return;
}
// Assert that the (void*) pointer of Data is pointing
// Assert that the (void*) pointer of Data is pointing
// to our ReplyBuffer payload.
if (m_private->m_replyBuffer.reply.Data == nullptr) {
logger.error() << "Did get a ping response without payload";
Expand Down

0 comments on commit f2e3dd3

Please sign in to comment.