Skip to content

Commit

Permalink
[core] Fix unused-variable warning
Browse files Browse the repository at this point in the history
  • Loading branch information
quink-black authored and maxsharabayko committed Jul 12, 2021
1 parent e932e8f commit 94322d4
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion srtcore/api.cpp
Expand Up @@ -1384,7 +1384,7 @@ int srt::CUDTUnited::groupConnect(CUDTGroup* pg, SRT_SOCKGROUPCONFIG* targets, i

// Set all options that were requested by the options set on a group
// prior to connecting.
string error_reason ATR_UNUSED;
string error_reason SRT_ATR_UNUSED;
try
{
for (size_t i = 0; i < g.m_config.size(); ++i)
Expand Down
4 changes: 2 additions & 2 deletions srtcore/buffer.cpp
Expand Up @@ -986,8 +986,8 @@ int CRcvBuffer::readBufferToFile(fstream& ofs, int len)
int lastack = m_iLastAckPos;
int rs = len;

int32_t trace_seq ATR_UNUSED = SRT_SEQNO_NONE;
int trace_shift ATR_UNUSED = -1;
int32_t trace_seq SRT_ATR_UNUSED = SRT_SEQNO_NONE;
int trace_shift SRT_ATR_UNUSED = -1;

while ((p != lastack) && (rs > 0))
{
Expand Down
2 changes: 1 addition & 1 deletion srtcore/channel.cpp
Expand Up @@ -183,7 +183,7 @@ void srt::CChannel::createSocket(int family)

if ((m_mcfg.iIpV6Only != -1) && (family == AF_INET6)) // (not an error if it fails)
{
const int res ATR_UNUSED =
const int res SRT_ATR_UNUSED =
::setsockopt(m_iSocket, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&m_mcfg.iIpV6Only, sizeof m_mcfg.iIpV6Only);
#if ENABLE_LOGGING
if (res == -1)
Expand Down
12 changes: 6 additions & 6 deletions srtcore/core.cpp
Expand Up @@ -2385,7 +2385,7 @@ int srt::CUDT::processSrtMsg_HSRSP(const uint32_t *srtdata, size_t bytelen, uint
// This function is called only when the URQ_CONCLUSION handshake has been received from the peer.
bool srt::CUDT::interpretSrtHandshake(const CHandShake& hs,
const CPacket& hspkt,
uint32_t* out_data,
uint32_t* out_data SRT_ATR_UNUSED,
size_t* pw_len)
{
// Initialize pw_len to 0 to handle the unencrypted case
Expand Down Expand Up @@ -2440,7 +2440,7 @@ bool srt::CUDT::interpretSrtHandshake(const CHandShake& hs,
uint32_t* p = reinterpret_cast<uint32_t*>(hspkt.m_pcData + CHandShake::m_iContentSize);
size_t size = hspkt.getLength() - CHandShake::m_iContentSize; // Due to previous cond check we grant it's >0

int hsreq_type_cmd ATR_UNUSED = SRT_CMD_NONE;
int hsreq_type_cmd SRT_ATR_UNUSED = SRT_CMD_NONE;

if (IsSet(ext_flags, CHandShake::HS_EXT_HSREQ))
{
Expand Down Expand Up @@ -2671,7 +2671,7 @@ bool srt::CUDT::interpretSrtHandshake(const CHandShake& hs,
m_config.sCongestion.set("live", 4);
}

bool have_group ATR_UNUSED = false;
bool have_group SRT_ATR_UNUSED = false;

if (IsSet(ext_flags, CHandShake::HS_EXT_CONFIG))
{
Expand Down Expand Up @@ -7715,7 +7715,7 @@ int srt::CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)
// IF ack %> m_iRcvLastAck
if (CSeqNo::seqcmp(ack, m_iRcvLastAck) > 0)
{
const int32_t first_seq ATR_UNUSED = ackDataUpTo(ack);
const int32_t first_seq SRT_ATR_UNUSED = ackDataUpTo(ack);
InvertedLock un_bufflock (m_RcvBufferLock);

#if ENABLE_EXPERIMENTAL_BONDING
Expand Down Expand Up @@ -8318,7 +8318,7 @@ void srt::CUDT::processCtrlAckAck(const CPacket& ctrlpkt, const time_point& tsAr
{
steady_clock::duration udrift(0);
steady_clock::time_point newtimebase;
const bool drift_updated ATR_UNUSED = m_pRcvBuffer->addRcvTsbPdDriftSample(ctrlpkt.getMsgTimeStamp(),
const bool drift_updated SRT_ATR_UNUSED = m_pRcvBuffer->addRcvTsbPdDriftSample(ctrlpkt.getMsgTimeStamp(),
rtt, (udrift), (newtimebase));
#if ENABLE_EXPERIMENTAL_BONDING
if (drift_updated && m_parent->m_GroupOf)
Expand Down Expand Up @@ -10795,7 +10795,7 @@ int srt::CUDT::checkNAKTimer(const steady_clock::time_point& currtime)
return debug_decision;
}

bool srt::CUDT::checkExpTimer(const steady_clock::time_point& currtime, int check_reason ATR_UNUSED)
bool srt::CUDT::checkExpTimer(const steady_clock::time_point& currtime, int check_reason SRT_ATR_UNUSED)
{
// VERY HEAVY LOGGING
#if ENABLE_HEAVY_LOGGING & 1
Expand Down
7 changes: 4 additions & 3 deletions srtcore/crypto.cpp
Expand Up @@ -43,7 +43,7 @@ using namespace srt_logging;
*/

// 10* HAICRYPT_DEF_KM_PRE_ANNOUNCE
const int SRT_CRYPT_KM_PRE_ANNOUNCE = 0x10000;
const int SRT_CRYPT_KM_PRE_ANNOUNCE SRT_ATR_UNUSED = 0x10000;

namespace srt_logging
{
Expand Down Expand Up @@ -662,6 +662,8 @@ std::string CCryptoControl::CONID() const
return os.str();
}

#ifdef SRT_ENABLE_ENCRYPTION

#if ENABLE_HEAVY_LOGGING
static std::string CryptoFlags(int flg)
{
Expand All @@ -679,9 +681,8 @@ static std::string CryptoFlags(int flg)
copy(f.begin(), f.end(), ostream_iterator<string>(os, "|"));
return os.str();
}
#endif
#endif // ENABLE_HEAVY_LOGGING

#ifdef SRT_ENABLE_ENCRYPTION
bool CCryptoControl::createCryptoCtx(size_t keylen, HaiCrypt_CryptoDir cdir, HaiCrypt_Handle& w_hCrypto)
{

Expand Down
4 changes: 2 additions & 2 deletions srtcore/epoll.cpp
Expand Up @@ -713,7 +713,7 @@ int CEPoll::wait(const int eid, set<SRTSOCKET>* readfds, set<SRTSOCKET>* writefd
throw CUDTException(MJ_AGAIN, MN_XMTIMEOUT, 0);
}

const bool wait_signaled ATR_UNUSED = CGlobEvent::waitForEvent();
const bool wait_signaled SRT_ATR_UNUSED = CGlobEvent::waitForEvent();
HLOGC(ealog.Debug, log << "CEPoll::wait: EVENT WAITING: "
<< (wait_signaled ? "TRIGGERED" : "CHECKPOINT"));
}
Expand Down Expand Up @@ -779,7 +779,7 @@ int CEPoll::swait(CEPollDesc& d, map<SRTSOCKET, int>& st, int64_t msTimeOut, boo
st[i->fd] = i->events;
IF_HEAVY_LOGGING(singles << "@" << i->fd << ":");
IF_HEAVY_LOGGING(PrintEpollEvent(singles, i->events, i->parent->edgeOnly()));
const bool edged ATR_UNUSED = d.checkEdge(i++); // NOTE: potentially deletes `i`
const bool edged SRT_ATR_UNUSED = d.checkEdge(i++); // NOTE: potentially deletes `i`
IF_HEAVY_LOGGING(singles << (edged ? "<^> " : " "));
}

Expand Down
2 changes: 1 addition & 1 deletion srtcore/fec.cpp
Expand Up @@ -2029,7 +2029,7 @@ void FECFilterBuiltin::RcvCheckDismissColumn(int32_t seq, int colgx, loss_seqs_t
any_dismiss = true;

const int32_t newbase = rcv.colq[numberCols()].base;
int32_t newbase_row ATR_UNUSED; // For logging only, but including FATAL.
int32_t newbase_row SRT_ATR_UNUSED; // For logging only, but including FATAL.
// Sanity check
// If sanity check failed OR if the number of existing row
// groups doesn't enclose those that need to be dismissed,
Expand Down
6 changes: 3 additions & 3 deletions srtcore/group.cpp
Expand Up @@ -3168,7 +3168,7 @@ CUDTGroup::BackupMemberState CUDTGroup::sendBackup_QualifyActiveState(const gli_
}

// [[using locked(this->m_GroupLock)]]
bool CUDTGroup::sendBackup_CheckSendStatus(const steady_clock::time_point& currtime ATR_UNUSED,
bool CUDTGroup::sendBackup_CheckSendStatus(const steady_clock::time_point& currtime SRT_ATR_UNUSED,
const int send_status,
const int32_t lastseq,
const int32_t pktseq,
Expand Down Expand Up @@ -3769,7 +3769,7 @@ void CUDTGroup::sendBackup_RetryWaitBlocked(SendBackupCtx& w_sendBackupCtx
// suffer linear search.

int nwaiting = 0;
int nactivated ATR_UNUSED = 0;
int nactivated SRT_ATR_UNUSED = 0;
int stat = -1;
for (gli_t d = m_Group.begin(); d != m_Group.end(); ++d)
{
Expand Down Expand Up @@ -4217,7 +4217,7 @@ int CUDTGroup::sendBackupRexmit(CUDT& core, SRT_MSGCTRL& w_mc)
// sequences already used by the link from which packets were
// copied to the backup buffer.
IF_HEAVY_LOGGING(int32_t old = core.schedSeqNo());
const bool su ATR_UNUSED = core.overrideSndSeqNo(curseq);
const bool su SRT_ATR_UNUSED = core.overrideSndSeqNo(curseq);
HLOGC(gslog.Debug,
log << "sendBackupRexmit: OVERRIDING seq %" << old << " with %" << curseq
<< (su ? " - succeeded" : " - FAILED!"));
Expand Down
4 changes: 2 additions & 2 deletions srtcore/logging.h
Expand Up @@ -422,7 +422,7 @@ inline void PrintArgs(std::ostream& serr, Arg1&& arg1, Args&&... args)
}

template <class... Args>
inline void LogDispatcher::PrintLogLine(const char* file ATR_UNUSED, int line ATR_UNUSED, const std::string& area ATR_UNUSED, Args&&... args ATR_UNUSED)
inline void LogDispatcher::PrintLogLine(const char* file SRT_ATR_UNUSED, int line SRT_ATR_UNUSED, const std::string& area SRT_ATR_UNUSED, Args&&... args SRT_ATR_UNUSED)
{
#ifdef ENABLE_LOGGING
std::ostringstream serr;
Expand All @@ -440,7 +440,7 @@ inline void LogDispatcher::PrintLogLine(const char* file ATR_UNUSED, int line AT
#else

template <class Arg>
inline void LogDispatcher::PrintLogLine(const char* file ATR_UNUSED, int line ATR_UNUSED, const std::string& area ATR_UNUSED, const Arg& arg ATR_UNUSED)
inline void LogDispatcher::PrintLogLine(const char* file SRT_ATR_UNUSED, int line SRT_ATR_UNUSED, const std::string& area SRT_ATR_UNUSED, const Arg& arg SRT_ATR_UNUSED)
{
#ifdef ENABLE_LOGGING
std::ostringstream serr;
Expand Down
3 changes: 2 additions & 1 deletion srtcore/sync.h
Expand Up @@ -51,6 +51,7 @@

#endif // ENABLE_STDCXX_SYNC

#include "srt.h"
#include "utilities.h"

class CUDTException; // defined in common.h
Expand Down Expand Up @@ -596,7 +597,7 @@ class CSync
cond.notify_all();
}

void signal_locked(UniqueLock& lk ATR_UNUSED)
void signal_locked(UniqueLock& lk SRT_ATR_UNUSED)
{
// EXPECTED: lk.mutex() is LOCKED.
m_cond->notify_one();
Expand Down
7 changes: 3 additions & 4 deletions srtcore/utilities.h
Expand Up @@ -18,7 +18,7 @@ written by

// ATTRIBUTES:
//
// ATR_UNUSED: declare an entity ALLOWED to be unused (prevents warnings)
// SRT_ATR_UNUSED: declare an entity ALLOWED to be unused (prevents warnings)
// ATR_DEPRECATED: declare an entity deprecated (compiler should warn when used)
// ATR_NOEXCEPT: The true `noexcept` from C++11, or nothing if compiling in pre-C++11 mode
// ATR_NOTHROW: In C++11: `noexcept`. In pre-C++11: `throw()`. Required for GNU libstdc++.
Expand All @@ -28,10 +28,8 @@ written by


#ifdef __GNUG__
#define ATR_UNUSED __attribute__((unused))
#define ATR_DEPRECATED __attribute__((deprecated))
#else
#define ATR_UNUSED
#define ATR_DEPRECATED
#endif
#if defined(__cplusplus) && __cplusplus > 199711L
Expand Down Expand Up @@ -719,7 +717,8 @@ struct CallbackHolder
// Casting function-to-function, however, should not. Unfortunately
// newer compilers disallow that, too (when a signature differs), but
// then they should better use the C++11 way, much more reliable and safer.
void* (*testfn)(void*) ATR_UNUSED = (void*(*)(void*))f;
void* (*testfn)(void*) = (void*(*)(void*))f;
(void)(testfn);
#endif
opaque = o;
fn = f;
Expand Down
2 changes: 1 addition & 1 deletion test/test_listen_callback.cpp
Expand Up @@ -112,7 +112,7 @@ TEST(Core, ListenCallback) {
(void)srt_cleanup();
}

int SrtTestListenCallback(void* opaq, SRTSOCKET ns, int hsversion, const struct sockaddr* peeraddr, const char* streamid)
int SrtTestListenCallback(void* opaq, SRTSOCKET ns SRT_ATR_UNUSED, int hsversion, const struct sockaddr* peeraddr, const char* streamid)
{
using namespace std;

Expand Down
2 changes: 1 addition & 1 deletion testing/testmedia.cpp
Expand Up @@ -2260,7 +2260,7 @@ MediaPacket SrtSource::Read(size_t chunk)
{
static size_t counter = 1;

bool have_group ATR_UNUSED = !m_group_nodes.empty();
bool have_group SRT_ATR_UNUSED = !m_group_nodes.empty();

bytevector data(chunk);
// EXPERIMENTAL
Expand Down

0 comments on commit 94322d4

Please sign in to comment.