Skip to content

Commit

Permalink
Merge pull request #3259 from softins/const-ref
Browse files Browse the repository at this point in the history
Add some missing const refs to CHostAddress params
  • Loading branch information
softins authored May 25, 2024
2 parents 6f57737 + 05c6e01 commit bb1639a
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ void CChannel::PutProtocolData ( const int iRecCounter, const int iRecID, const
}
}

EPutDataStat CChannel::PutAudioData ( const CVector<uint8_t>& vecbyData, const int iNumBytes, CHostAddress RecHostAddr )
EPutDataStat CChannel::PutAudioData ( const CVector<uint8_t>& vecbyData, const int iNumBytes, const CHostAddress& RecHostAddr )
{
// init return state
EPutDataStat eRet = PS_GEN_ERROR;
Expand Down
4 changes: 2 additions & 2 deletions src/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CChannel : public QObject

void PutProtocolData ( const int iRecCounter, const int iRecID, const CVector<uint8_t>& vecbyMesBodyData, const CHostAddress& RecHostAddr );

EPutDataStat PutAudioData ( const CVector<uint8_t>& vecbyData, const int iNumBytes, CHostAddress RecHostAddr );
EPutDataStat PutAudioData ( const CVector<uint8_t>& vecbyData, const int iNumBytes, const CHostAddress& RecHostAddr );

EGetDataStat GetData ( CVector<uint8_t>& vecbyData, const int iNumBytes );

Expand All @@ -83,7 +83,7 @@ class CChannel : public QObject
void SetEnable ( const bool bNEnStat );
bool IsEnabled() { return bIsEnabled; }

void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; }
void SetAddress ( const CHostAddress& NAddr ) { InetAddr = NAddr; }
const CHostAddress& GetAddress() const { return InetAddr; }

void ResetInfo()
Expand Down
2 changes: 1 addition & 1 deletion src/recorder/jamrecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ using namespace recorder;
* Creates a file for the raw PCM data and sets up a QDataStream to which to write received frames.
* The data is stored Little Endian.
*/
CJamClient::CJamClient ( const qint64 frame, const int _numChannels, const QString name, const CHostAddress address, const QDir recordBaseDir ) :
CJamClient::CJamClient ( const qint64 frame, const int _numChannels, const QString name, const CHostAddress& address, const QDir recordBaseDir ) :
startFrame ( frame ),
numChannels ( static_cast<uint16_t> ( _numChannels ) ),
name ( name ),
Expand Down
2 changes: 1 addition & 1 deletion src/recorder/jamrecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class CJamClient : public QObject
Q_OBJECT

public:
CJamClient ( const qint64 frame, const int numChannels, const QString name, const CHostAddress address, const QDir recordBaseDir );
CJamClient ( const qint64 frame, const int numChannels, const QString name, const CHostAddress& address, const QDir recordBaseDir );

void Frame ( const QString name, const CVector<int16_t>& pcm, int iServerFrameSizeSamples );

Expand Down
2 changes: 1 addition & 1 deletion src/serverlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ void CServerListManager::RetrieveAll ( const CHostAddress& InetAddr )
}
}

int CServerListManager::IndexOf ( CHostAddress haSearchTerm )
int CServerListManager::IndexOf ( const CHostAddress& haSearchTerm )
{
// Called with lock set.

Expand Down
2 changes: 1 addition & 1 deletion src/serverlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class CServerListManager : public QObject
void Register();
void SetRegistered ( bool bIsRegister );

int IndexOf ( CHostAddress haSearchTerm );
int IndexOf ( const CHostAddress& haSearchTerm );
bool Load();
void Save();
void SetSvrRegStatus ( ESvrRegStatus eNSvrRegStatus );
Expand Down
4 changes: 3 additions & 1 deletion src/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ void CSocket::OnDataReceived()
use the signal/slot mechanism (i.e. we use messages for that).
*/

CHostAddress RecHostAddr;

// read block from network interface and query address of sender
uSockAddr UdpSocketAddr;
#ifdef _WIN32
Expand All @@ -381,6 +383,7 @@ void CSocket::OnDataReceived()
return;
}

// convert address of client
if ( UdpSocketAddr.sa.sa_family == AF_INET6 )
{
if ( IN6_IS_ADDR_V4MAPPED ( &( UdpSocketAddr.sa6.sin6_addr ) ) )
Expand All @@ -396,7 +399,6 @@ void CSocket::OnDataReceived()
}
else
{
// convert address of client
RecHostAddr.InetAddr.setAddress ( ntohl ( UdpSocketAddr.sa4.sin_addr.s_addr ) );
RecHostAddr.iPort = ntohs ( UdpSocketAddr.sa4.sin_port );
}
Expand Down
3 changes: 0 additions & 3 deletions src/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ class CSocket : public QObject
QMutex Mutex;

CVector<uint8_t> vecbyRecBuf;
CHostAddress RecHostAddr;
QHostAddress SenderAddress;
quint16 SenderPort;

CChannel* pChannel; // for client
CServer* pServer; // for server
Expand Down
2 changes: 1 addition & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ class CHostAddress

CHostAddress() : InetAddr ( static_cast<quint32> ( 0 ) ), iPort ( 0 ) {}

CHostAddress ( const QHostAddress NInetAddr, const quint16 iNPort ) : InetAddr ( NInetAddr ), iPort ( iNPort ) {}
CHostAddress ( const QHostAddress& NInetAddr, const quint16 iNPort ) : InetAddr ( NInetAddr ), iPort ( iNPort ) {}

CHostAddress ( const CHostAddress& NHAddr ) : InetAddr ( NHAddr.InetAddr ), iPort ( NHAddr.iPort ) {}

Expand Down

0 comments on commit bb1639a

Please sign in to comment.