diff --git a/BinRpc.cpp b/BinRpc.cpp index 64055865..b2025339 100644 --- a/BinRpc.cpp +++ b/BinRpc.cpp @@ -253,7 +253,7 @@ void SetDownloadRateBinCommand::Execute() return; } - g_pOptions->SetDownloadRate(ntohl(SetDownloadRequest.m_iDownloadRate) / 1024.0); + g_pOptions->SetDownloadRate(ntohl(SetDownloadRequest.m_iDownloadRate) / 1024.0f); SendBoolResponse(true, "Rate-Command completed successfully"); } @@ -520,7 +520,7 @@ void LogBinCommand::Execute() SNZBLogResponseEntry* pLogAnswer = (SNZBLogResponseEntry*) bufptr; pLogAnswer->m_iID = htonl(pMessage->GetID()); pLogAnswer->m_iKind = htonl(pMessage->GetKind()); - pLogAnswer->m_tTime = htonl(pMessage->GetTime()); + pLogAnswer->m_tTime = htonl((int)pMessage->GetTime()); pLogAnswer->m_iTextLen = htonl(strlen(pMessage->GetText()) + 1); bufptr += sizeof(SNZBLogResponseEntry); strcpy(bufptr, pMessage->GetText()); @@ -667,8 +667,8 @@ void PostQueueBinCommand::Execute() pPostQueueAnswer->m_iStage = htonl(pPostInfo->GetStage()); pPostQueueAnswer->m_iStageProgress = htonl(pPostInfo->GetStageProgress()); pPostQueueAnswer->m_iFileProgress = htonl(pPostInfo->GetFileProgress()); - pPostQueueAnswer->m_iTotalTimeSec = htonl(pPostInfo->GetStartTime() ? tCurTime - pPostInfo->GetStartTime() : 0); - pPostQueueAnswer->m_iStageTimeSec = htonl(pPostInfo->GetStageTime() ? tCurTime - pPostInfo->GetStageTime() : 0); + pPostQueueAnswer->m_iTotalTimeSec = htonl((int)(pPostInfo->GetStartTime() ? tCurTime - pPostInfo->GetStartTime() : 0)); + pPostQueueAnswer->m_iStageTimeSec = htonl((int)(pPostInfo->GetStageTime() ? tCurTime - pPostInfo->GetStageTime() : 0)); pPostQueueAnswer->m_iNZBFilenameLen = htonl(strlen(pPostInfo->GetNZBFilename()) + 1); pPostQueueAnswer->m_iParFilename = htonl(strlen(pPostInfo->GetParFilename()) + 1); pPostQueueAnswer->m_iInfoNameLen = htonl(strlen(pPostInfo->GetInfoName()) + 1); diff --git a/ColoredFrontend.cpp b/ColoredFrontend.cpp index 9033736b..4e58c3a7 100644 --- a/ColoredFrontend.cpp +++ b/ColoredFrontend.cpp @@ -79,9 +79,9 @@ void ColoredFrontend::PrintStatus() if (fCurrentDownloadSpeed > 0.0 && !m_bPause) { long long remain_sec = m_lRemainingSize / ((long long)(fCurrentDownloadSpeed * 1024)); - int h = remain_sec / 3600; - int m = (remain_sec % 3600) / 60; - int s = remain_sec % 60; + int h = (int)(remain_sec / 3600); + int m = (int)((remain_sec % 3600) / 60); + int s = (int)(remain_sec % 60); sprintf(timeString, " (~ %.2d:%.2d:%.2d)", h, m, s); } diff --git a/Connection.cpp b/Connection.cpp index 6b438748..891f1bba 100644 --- a/Connection.cpp +++ b/Connection.cpp @@ -414,7 +414,7 @@ char* Connection::DoReadLine(char* pBuffer, int iSize, int* pBytesRead) char* p = (char*)memchr(szBufPtr, '\n', iBufAvail); if (p) { - len = p - szBufPtr + 1; + len = (int)(p - szBufPtr + 1); } else { diff --git a/Decoder.cpp b/Decoder.cpp index d6e63e6c..341b724b 100644 --- a/Decoder.cpp +++ b/Decoder.cpp @@ -253,9 +253,9 @@ BreakLoop: if (m_bCrcCheck) { - m_lCalculatedCRC = crc32m(m_lCalculatedCRC, (unsigned char *)buffer, optr - buffer); + m_lCalculatedCRC = crc32m(m_lCalculatedCRC, (unsigned char *)buffer, (unsigned int)(optr - buffer)); } - return optr - buffer; + return (unsigned int)(optr - buffer); } else { @@ -458,7 +458,7 @@ unsigned int UDecoder::DecodeBuffer(char* buffer, int len) } } - return optr - buffer; + return (unsigned int)(optr - buffer); } return 0; diff --git a/Frontend.cpp b/Frontend.cpp index 3d77e21d..b9e6154e 100644 --- a/Frontend.cpp +++ b/Frontend.cpp @@ -352,8 +352,8 @@ bool Frontend::RequestFileList() { m_bPause = ntohl(ListResponse.m_bServerPaused); m_lRemainingSize = Util::JoinInt64(ntohl(ListResponse.m_iRemainingSizeHi), ntohl(ListResponse.m_iRemainingSizeLo)); - m_fCurrentDownloadSpeed = ntohl(ListResponse.m_iDownloadRate) / 1024.0; - m_fDownloadLimit = ntohl(ListResponse.m_iDownloadLimit) / 1024.0; + m_fCurrentDownloadSpeed = ntohl(ListResponse.m_iDownloadRate) / 1024.0f; + m_fDownloadLimit = ntohl(ListResponse.m_iDownloadLimit) / 1024.0f; m_iThreadCount = ntohl(ListResponse.m_iThreadCount); m_iPostJobCount = ntohl(ListResponse.m_iPostJobCount); m_iUpTimeSec = ntohl(ListResponse.m_iUpTimeSec); diff --git a/NCursesFrontend.cpp b/NCursesFrontend.cpp index 5efd7a15..7348b03e 100644 --- a/NCursesFrontend.cpp +++ b/NCursesFrontend.cpp @@ -580,9 +580,9 @@ void NCursesFrontend::PrintStatus() if (fCurrentDownloadSpeed > 0.0 && !m_bPause) { long long remain_sec = (long long)(m_lRemainingSize / (fCurrentDownloadSpeed * 1024)); - int h = remain_sec / 3600; - int m = (remain_sec % 3600) / 60; - int s = remain_sec % 60; + int h = (int)(remain_sec / 3600); + int m = (int)((remain_sec % 3600) / 60); + int s = (int)(remain_sec % 60); sprintf(timeString, " (~ %.2d:%.2d:%.2d)", h, m, s); } diff --git a/NZBFile.cpp b/NZBFile.cpp index 133eded0..9b423cea 100644 --- a/NZBFile.cpp +++ b/NZBFile.cpp @@ -178,7 +178,7 @@ void NZBFile::ParseSubject(FileInfo* pFileInfo) if (sep) { // end of token - int len = p - start; + int len = (int)(p - start); if (len > 0) { char* token = (char*)malloc(len + 1); diff --git a/Options.cpp b/Options.cpp index 842c04bb..8f071349 100644 --- a/Options.cpp +++ b/Options.cpp @@ -1112,7 +1112,7 @@ bool Options::SetOptionString(const char * option) { char optname[1001]; char optvalue[1001]; - int maxlen = eq - option < 1000 ? eq - option : 1000; + int maxlen = (int)(eq - option < 1000 ? eq - option : 1000); strncpy(optname, option, maxlen); optname[maxlen] = '\0'; strncpy(optvalue, eq + 1, 1000); @@ -1209,7 +1209,7 @@ void Options::ParseFileIDList(int argc, char* argv[], int optind) if (p) { char buf[101]; - int maxlen = p - optarg < 100 ? p - optarg : 100; + int maxlen = (int)(p - optarg < 100 ? p - optarg : 100); strncpy(buf, optarg, maxlen); buf[maxlen] = '\0'; iEditQueueIDFrom = atoi(buf); diff --git a/QueueCoordinator.cpp b/QueueCoordinator.cpp index 3c5a187a..915ce227 100644 --- a/QueueCoordinator.cpp +++ b/QueueCoordinator.cpp @@ -324,7 +324,7 @@ float QueueCoordinator::CalcCurrentDownloadSpeed() iTotal += m_iSpeedBytes[i]; } - float fSpeed = iTotal / 1024.0 / SPEEDMETER_SECONDS; + float fSpeed = iTotal / 1024.0f / SPEEDMETER_SECONDS; return fSpeed; } @@ -340,7 +340,7 @@ float QueueCoordinator::CalcCurrentDownloadSpeed() */ void QueueCoordinator::AddSpeedReading(int iBytes) { - int iIndex = time(NULL); + int iIndex = (int)time(NULL); if (iIndex - m_iSpeedBytesIndex > SPEEDMETER_SECONDS) { @@ -771,7 +771,7 @@ void QueueCoordinator::CalcStat(int* iUpTimeSec, int* iDnTimeSec, long long* iAl m_mutexStat.Lock(); if (m_tStartServer > 0) { - *iUpTimeSec = time(NULL) - m_tStartServer; + *iUpTimeSec = (int)(time(NULL) - m_tStartServer); } else { @@ -780,11 +780,11 @@ void QueueCoordinator::CalcStat(int* iUpTimeSec, int* iDnTimeSec, long long* iAl *bStandBy = m_bStandBy; if (m_bStandBy) { - *iDnTimeSec = m_tPausedFrom - m_tStartDownload; + *iDnTimeSec = (int)(m_tPausedFrom - m_tStartDownload); } else { - *iDnTimeSec = time(NULL) - m_tStartDownload; + *iDnTimeSec = (int)(time(NULL) - m_tStartDownload); } *iAllBytes = m_iAllBytes; m_mutexStat.Unlock(); diff --git a/ServerPool.cpp b/ServerPool.cpp index c456b07c..692749bf 100644 --- a/ServerPool.cpp +++ b/ServerPool.cpp @@ -211,7 +211,7 @@ void ServerPool::CloseUnusedConnections() PooledConnection* pConnection = *it; if (!pConnection->GetInUse() && pConnection->GetStatus() == Connection::csConnected) { - int tdiff = curtime - pConnection->GetFreeTime(); + int tdiff = (int)(curtime - pConnection->GetFreeTime()); if (tdiff > CONNECTION_HOLD_SECODNS) { debug("Closing unused connection to %s", pConnection->GetNewsServer()->GetHost()); diff --git a/Util.cpp b/Util.cpp index f28b182f..62dcfca3 100644 --- a/Util.cpp +++ b/Util.cpp @@ -394,7 +394,7 @@ float Util::Int64ToFloat(long long Int64) { unsigned long Hi = (unsigned long)(Int64 >> 32); unsigned long Lo = (unsigned long)Int64; - return ((unsigned long)(1 << 30)) * 4.0 * Hi + Lo; + return ((unsigned long)(1 << 30)) * 4.0f * Hi + Lo; } float Util::EqualTime(_timeval* t1, _timeval* t2) @@ -418,7 +418,7 @@ bool Util::EmptyTime(_timeval* t) float Util::DiffTime(_timeval* t1, _timeval* t2) { #ifdef WIN32 - return ((t1->time - t2->time) + (t1->millitm - t2->millitm) / 1000.0); + return ((t1->time - t2->time) + (t1->millitm - t2->millitm) / 1000.0f); #else return (float)((t1->tv_sec - t2->tv_sec) + (t1->tv_usec - t2->tv_usec) / 1000000.0); #endif @@ -687,7 +687,7 @@ const char* Util::XmlFindTag(const char* szXml, const char* szTag, int* pValueLe if (!pend) return NULL; int iTagLen = strlen(szOpenTag); - *pValueLength = pend - pstart - iTagLen; + *pValueLength = (int)(pend - pstart - iTagLen); return pstart + iTagLen; } @@ -985,7 +985,7 @@ const char* Util::JsonNextValue(const char* szJsonText, int* pValueLength) ch = *++pend; } - *pValueLength = pend - pstart; + *pValueLength = (int)(pend - pstart); return pstart; } diff --git a/XmlRpc.cpp b/XmlRpc.cpp index e2d634e7..822065b8 100644 --- a/XmlRpc.cpp +++ b/XmlRpc.cpp @@ -205,12 +205,12 @@ void XmlRpcProcessor::Dispatch() { szRequest = m_szUrl + 1; char* pstart = strchr(szRequest, '/'); - if (pstart) + if (pstart) { char* pend = strchr(pstart + 1, '?'); if (pend) { - int iLen = pend - pstart - 1 < (int)sizeof(szMethodName) - 1 ? pend - pstart - 1 : (int)sizeof(szMethodName) - 1; + int iLen = (int)(pend - pstart - 1 < (int)sizeof(szMethodName) - 1 ? pend - pstart - 1 : (int)sizeof(szMethodName) - 1); strncpy(szMethodName, pstart + 1, iLen); szMethodName[iLen] = '\0'; szRequest = pend + 1; @@ -746,7 +746,7 @@ void SetDownloadRateXmlCommand::Execute() return; } - g_pOptions->SetDownloadRate(iRate); + g_pOptions->SetDownloadRate((float)iRate); BuildBoolResponse(true); } @@ -794,7 +794,7 @@ void StatusXmlCommand::Execute() int iDownloadRate = (int)(g_pQueueCoordinator->CalcCurrentDownloadSpeed() * 1024); long long iRemainingSize = g_pQueueCoordinator->CalcRemainingSize(); Util::SplitInt64(iRemainingSize, &iRemainingSizeHi, &iRemainingSizeLo); - int iRemainingMBytes = iRemainingSize / 1024 / 1024; + int iRemainingMBytes = (int)(iRemainingSize / 1024 / 1024); int iDownloadLimit = (int)(g_pOptions->GetDownloadRate() * 1024); bool bServerPaused = g_pOptions->GetPause(); int iThreadCount = Thread::GetThreadCount() - 1; // not counting itself @@ -806,9 +806,9 @@ void StatusXmlCommand::Execute() long long iAllBytes; bool bServerStandBy; g_pQueueCoordinator->CalcStat(&iUpTimeSec, &iDownloadTimeSec, &iAllBytes, &bServerStandBy); - int iDownloadedMBytes = iAllBytes / 1024 / 1024; + int iDownloadedMBytes = (int)(iAllBytes / 1024 / 1024); Util::SplitInt64(iAllBytes, &iDownloadedSizeHi, &iDownloadedSizeLo); - int iAverageDownloadRate = iDownloadTimeSec > 0 ? iAllBytes / iDownloadTimeSec : 0; + int iAverageDownloadRate = (int)(iDownloadTimeSec > 0 ? iAllBytes / iDownloadTimeSec : 0); char szContent[2048]; snprintf(szContent, 2048, IsJson() ? JSON_RESPONSE_STATUS_BODY : XML_RESPONSE_STATUS_BODY, @@ -1060,11 +1060,11 @@ void ListGroupsXmlCommand::Execute() unsigned long iPausedSizeLo, iPausedSizeHi, iPausedSizeMB; char szNZBNicename[1024]; Util::SplitInt64(pGroupInfo->GetNZBInfo()->GetSize(), &iFileSizeHi, &iFileSizeLo); - iFileSizeMB = pGroupInfo->GetNZBInfo()->GetSize() / 1024 / 1024; + iFileSizeMB = (int)(pGroupInfo->GetNZBInfo()->GetSize() / 1024 / 1024); Util::SplitInt64(pGroupInfo->GetRemainingSize(), &iRemainingSizeHi, &iRemainingSizeLo); - iRemainingSizeMB = pGroupInfo->GetRemainingSize() / 1024 / 1024; + iRemainingSizeMB = (int)(pGroupInfo->GetRemainingSize() / 1024 / 1024); Util::SplitInt64(pGroupInfo->GetPausedSize(), &iPausedSizeHi, &iPausedSizeLo); - iPausedSizeMB = pGroupInfo->GetPausedSize() / 1024 / 1024; + iPausedSizeMB = (int)(pGroupInfo->GetPausedSize() / 1024 / 1024); pGroupInfo->GetNZBInfo()->GetNiceNZBName(szNZBNicename, sizeof(szNZBNicename)); char* xmlNZBNicename = EncodeStr(szNZBNicename); diff --git a/nzbget.h b/nzbget.h index 8a6c43f0..b0f2a258 100644 --- a/nzbget.h +++ b/nzbget.h @@ -41,9 +41,8 @@ #define strcasecmp(a, b) _stricmp(a, b) #define strncasecmp(a, b, c) _strnicmp(a, b, c) -#pragma warning(disable:4800) // 'type' : forcing value to bool 'true' or 'false' (performance warning) +#pragma warning(disable:4800) // 'type' : forcing value to bool 'true' or 'false' (performance warning) #pragma warning(disable:4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data -#pragma warning(disable:4244) // 'argument' : conversion from 'type1' to 'type2', possible loss of data #define __S_ISTYPE(mode, mask) (((mode) & _S_IFMT) == (mask)) #define S_ISDIR(mode) __S_ISTYPE((mode), _S_IFDIR)