Fix more warnings and #197

This commit is contained in:
Alexey Sokolov
2012-08-17 00:56:53 +07:00
parent 395ae4fc9f
commit 892727ba2c
6 changed files with 16 additions and 18 deletions

View File

@@ -31,7 +31,7 @@ public:
void SendPacket();
virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort);
CFile* OpenFile(bool bWrite = true);
bool Seek(unsigned int uPos);
bool Seek(unsigned long int uPos);
// Setters
void SetRemoteIP(const CString& s) { m_sRemoteIP = s; }
@@ -58,8 +58,8 @@ protected:
CString m_sLocalFile;
CString m_sSendBuf;
unsigned short m_uRemotePort;
unsigned long m_uFileSize;
unsigned long m_uBytesSoFar;
unsigned long long m_uFileSize;
unsigned long long m_uBytesSoFar;
bool m_bSend;
bool m_bNoDelFile;
CFile* m_pFile;
@@ -309,7 +309,7 @@ void CDCCSock::ReadData(const char* data, size_t len) {
} else {
m_pFile->Write(data, len);
m_uBytesSoFar += len;
uint32_t uSoFar = htonl(m_uBytesSoFar);
uint32_t uSoFar = htonl((uint32_t)m_uBytesSoFar);
Write((char*) &uSoFar, sizeof(uSoFar));
if (m_uBytesSoFar >= m_uFileSize) {
@@ -447,14 +447,14 @@ CFile* CDCCSock::OpenFile(bool bWrite) {
// The DCC specs only allow file transfers with files smaller
// than 4GiB (see ReadData()).
unsigned long long uFileSize = m_pFile->GetSize();
if (uFileSize > (unsigned long long) 0xffffffff) {
if (uFileSize > (unsigned long long) 0xffffffffULL) {
delete m_pFile;
m_pFile = NULL;
m_pModule->PutModule("DCC -> [" + m_sRemoteNick + "] - File too large (>4 GiB) [" + m_sLocalFile + "]");
return NULL;
}
m_uFileSize = (unsigned long) uFileSize;
m_uFileSize = uFileSize;
}
m_sFileName = m_pFile->GetShortName();
@@ -462,7 +462,7 @@ CFile* CDCCSock::OpenFile(bool bWrite) {
return m_pFile;
}
bool CDCCSock::Seek(unsigned int uPos) {
bool CDCCSock::Seek(unsigned long int uPos) {
if (m_pFile) {
if (m_pFile->Seek(uPos)) {
m_uBytesSoFar = uPos;

View File

@@ -443,7 +443,7 @@ private:
CString sOuterKey, sInnerKey;
CString::size_type iKeyLength = sRealKey.length();
for (unsigned int i = 0; i < 64; i++) {
int r = (i < iKeyLength ? sRealKey[i] : 0);
char r = (i < iKeyLength ? sRealKey[i] : '\0');
sOuterKey += r ^ 0x5c;
sInnerKey += r ^ 0x36;
}

View File

@@ -222,8 +222,7 @@ public:
}
/* Prime number */
unsigned int size = ntohs((((unsigned int)data[1]) << 8) | data[0]);
size = ntohs(*(unsigned int*)data);
unsigned int size = ntohs(*(uint16_t*)data);
data += 2;
length -= 2;
@@ -243,8 +242,7 @@ public:
return false;
}
size = ntohs((((unsigned int)data[1]) << 8) | data[0]);
size = ntohs(*(unsigned int*)data);
size = ntohs(*(uint16_t*)data);
data += 2;
length -= 2;
@@ -258,8 +256,7 @@ public:
data += size;
/* Server public key */
size = ntohs((((unsigned int)data[1]) << 8) | data[0]);
size = ntohs(*(unsigned int*)data);
size = ntohs(*(uint16_t*)data);
data += 2;
length -= 2;
@@ -289,6 +286,7 @@ public:
}
/* Encrypt our sasl password with blowfish */
// TODO for passwords with length 8, 16, 24, 32, etc. this will have 8 additional zero bytes at the end... But it works when treated as null-terminated string anyway, and if it works I don't want to touch it right now.
CString::size_type password_length = GetNV("password").size() + (8 - (GetNV("password").size() % 8));
unsigned char *encrypted_password = (unsigned char *)malloc(password_length);
char *plaintext_password = (char *)malloc(password_length);
@@ -315,7 +313,7 @@ public:
out_ptr = response;
/* Add our key to the response */
*((unsigned int *)out_ptr) = htons(BN_num_bytes(dh->pub_key));
*((uint16_t *)out_ptr) = htons((uint16_t)BN_num_bytes(dh->pub_key));
out_ptr += 2;
BN_bn2bin(dh->pub_key, (unsigned char *)out_ptr);
out_ptr += BN_num_bytes(dh->pub_key);

View File

@@ -412,7 +412,7 @@ ssize_t CFile::Write(const char *pszBuffer, size_t iBytes) {
}
ssize_t res = write(m_iFD, pszBuffer, iBytes);
if (res != iBytes)
if (-1 == res)
m_bHadError = true;
return res;
}

View File

@@ -108,7 +108,7 @@ static void seedPRNG() {
// This is in [0:1e6], which means that roughly 20 bits are
// actually used, let's try to shuffle the high bits.
seed ^= (tv.tv_usec << 10) | tv.tv_usec;
seed ^= uint32_t((tv.tv_usec << 10) | tv.tv_usec);
} else
seed = (unsigned int)time(NULL);

View File

@@ -582,7 +582,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
CUtils::GetInput("Listen Host", sListenHost, sListenHost, "Blank for all ips");
CUtils::PrintAction("Verifying the listener");
CListener* pListener = new CListener(uListenPort, sListenHost, bListenSSL,
CListener* pListener = new CListener((unsigned short int)uListenPort, sListenHost, bListenSSL,
b6 ? ADDR_ALL : ADDR_IPV4ONLY, CListener::ACCEPT_ALL);
if (!pListener->Listen()) {
CUtils::PrintStatus(false, FormatBindError());