Reformat TxThread/run {} to use less vertical space

This commit is contained in:
Srivats P 2023-03-08 18:14:45 +05:30
parent f3a9b507b0
commit ebccc44cdf

View File

@ -283,29 +283,23 @@ void PcapTxThread::run()
getTimeStamp(&startTime); getTimeStamp(&startTime);
state_ = kRunning; state_ = kRunning;
i = 0; i = 0;
while (i < packetSequenceList_.size()) while (i < packetSequenceList_.size()) {
{
_restart: _restart:
int rptSz = packetSequenceList_.at(i)->repeatSize_; int rptSz = packetSequenceList_.at(i)->repeatSize_;
int rptCnt = packetSequenceList_.at(i)->repeatCount_; int rptCnt = packetSequenceList_.at(i)->repeatCount_;
for (int j = 0; j < rptCnt; j++) for (int j = 0; j < rptCnt; j++) {
{ for (int k = 0; k < rptSz; k++) {
for (int k = 0; k < rptSz; k++)
{
int ret; int ret;
PacketSequence *seq = packetSequenceList_.at(i+k); PacketSequence *seq = packetSequenceList_.at(i+k);
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
TimeStamp ovrStart, ovrEnd; TimeStamp ovrStart, ovrEnd;
if (seq->usecDuration_ <= long(1e6)) // 1s if (seq->usecDuration_ <= long(1e6)) { // 1s
{
getTimeStamp(&ovrStart); getTimeStamp(&ovrStart);
ret = pcap_sendqueue_transmit(handle_, ret = pcap_sendqueue_transmit(handle_,
seq->sendQueue_, kSyncTransmit); seq->sendQueue_, kSyncTransmit);
if (ret >= 0) if (ret >= 0) {
{
stats_->pkts += seq->packets_; stats_->pkts += seq->packets_;
stats_->bytes += seq->bytes_; stats_->bytes += seq->bytes_;
@ -316,9 +310,7 @@ _restart:
} }
if (stop_) if (stop_)
ret = -2; ret = -2;
} } else {
else
{
ret = sendQueueTransmit(handle_, seq->sendQueue_, ret = sendQueueTransmit(handle_, seq->sendQueue_,
overHead, kSyncTransmit); overHead, kSyncTransmit);
} }
@ -327,41 +319,33 @@ _restart:
overHead, kSyncTransmit); overHead, kSyncTransmit);
#endif #endif
if (ret >= 0) if (ret >= 0) {
{
long usecs = seq->usecDelay_ + overHead; long usecs = seq->usecDelay_ + overHead;
if (usecs > 0) if (usecs > 0) {
{
(*udelayFn_)(usecs); (*udelayFn_)(usecs);
overHead = 0; overHead = 0;
} } else
else
overHead = usecs; overHead = usecs;
} } else {
else
{
qDebug("error %d in sendQueueTransmit()", ret); qDebug("error %d in sendQueueTransmit()", ret);
qDebug("overHead = %ld", overHead); qDebug("overHead = %ld", overHead);
stop_ = false; stop_ = false;
goto _exit; goto _exit;
} }
} } // rptSz
} } // rptCnt
// Move to the next Packet Set // Move to the next Packet Set
i += rptSz; i += rptSz;
} }
if (returnToQIdx_ >= 0) if (returnToQIdx_ >= 0) {
{
long usecs = loopDelay_ + overHead; long usecs = loopDelay_ + overHead;
if (usecs > 0) if (usecs > 0) {
{
(*udelayFn_)(usecs); (*udelayFn_)(usecs);
overHead = 0; overHead = 0;
} } else
else
overHead = usecs; overHead = usecs;
i = returnToQIdx_; i = returnToQIdx_;