diff options
28 files changed, 106 insertions, 147 deletions
diff --git a/plugins/CountryFlags/src/icons.cpp b/plugins/CountryFlags/src/icons.cpp index 93354139ae..6471ab79db 100644 --- a/plugins/CountryFlags/src/icons.cpp +++ b/plugins/CountryFlags/src/icons.cpp @@ -208,7 +208,6 @@ static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam,LPARAM lParam) DrawIconEx(hdc,0,0,hUpperIcon,bm.bmWidth,bm.bmHeight,0,NULL,DI_NOMIRROR|DI_MASK);
SelectObject(hdc,hbmPrev);
}
- DeleteObject(hrgn);
}
DeleteDC(hdc);
}
diff --git a/plugins/CountryFlags/src/ip2country.cpp b/plugins/CountryFlags/src/ip2country.cpp index ceaaefbb3b..803e8baa72 100644 --- a/plugins/CountryFlags/src/ip2country.cpp +++ b/plugins/CountryFlags/src/ip2country.cpp @@ -110,8 +110,6 @@ INT_PTR ServiceIpToCountry(WPARAM wParam,LPARAM lParam) if (wParam>=dwFrom) /* only search if wParam valid */
while (low<=high) {
i=low+((high-low)/2);
- /* never happens */
- if (i<0) DebugBreak();
/* analyze record */
id=GetDataRecord(data,i,&dwFrom,&dwTo);
if (dwFrom<=wParam && dwTo>=wParam) { LeaveRecordCache(); return id; }
diff --git a/plugins/Exchange/src/MirandaExchange.cpp b/plugins/Exchange/src/MirandaExchange.cpp index 9c2dabe005..9f9b77881d 100644 --- a/plugins/Exchange/src/MirandaExchange.cpp +++ b/plugins/Exchange/src/MirandaExchange.cpp @@ -556,7 +556,7 @@ HRESULT CMirandaExchange::CreateProfile( LPTSTR szProfileName ) if ( !(FAILED(hr)) || (pMsgSvcAdmin) )
{
- hr = pMsgSvcAdmin->CreateMsgService((LPTSTR)"MSEMS", (LPTSTR)""/*"Microsoft Exchange Server"*/, NULL, 0);
+ hr = pMsgSvcAdmin->CreateMsgService(_T("MSEMS"), _T("")/*"Microsoft Exchange Server"*/, NULL, 0);
if (!FAILED(hr))
{
@@ -601,10 +601,7 @@ HRESULT CMirandaExchange::CreateProfile( LPTSTR szProfileName ) (LPMAPIUID) pRows->aRow->lpProps[iSvcUID].Value.bin.lpb,
0, NULL, 2, spval);
- if (NULL!=szUniqName)
- {
- delete[] szUniqName;
- }
+ delete[] szUniqName;
}
}
}
@@ -741,16 +738,13 @@ HRESULT CMirandaExchange::MarkAsRead( LPTSTR szEntryID ) HexToBin(szEntryID, ulC, lpData);
- HRESULT hr = CallOpenEntry( m_lpMDB, NULL, NULL, m_lpMAPISession, ulC, (LPENTRYID) lpData, MAPI_BEST_ACCESS, NULL, (LPUNKNOWN*)&lpMessage);
- if (NULL != lpData)
- {
- delete lpData;
- }
+ CallOpenEntry( m_lpMDB, NULL, NULL, m_lpMAPISession, ulC, (LPENTRYID) lpData, MAPI_BEST_ACCESS, NULL, (LPUNKNOWN*)&lpMessage);
+ delete lpData;
if ( NULL != lpMessage)
{
- hr = lpMessage->SetReadFlag( 0 );
- hr = lpMessage->SaveChanges(FORCE_SAVE);
+ lpMessage->SetReadFlag( 0 );
+ lpMessage->SaveChanges(FORCE_SAVE);
lpMessage->Release();
lpMessage = NULL;
diff --git a/plugins/Exchange/src/emails.cpp b/plugins/Exchange/src/emails.cpp index 25261a4ea2..96b85764a5 100644 --- a/plugins/Exchange/src/emails.cpp +++ b/plugins/Exchange/src/emails.cpp @@ -161,7 +161,7 @@ int CExchangeServer::IsServerAvailable() // if connected then close smtp connection by sending a quit message
bAvailable = 1;
char message[] = "quit\n";
- send(sServer, message, strlen(message), 0);
+ send(sServer, message, (int)strlen(message), 0);
}
res = closesocket(sServer); //close the socket
return bAvailable;
@@ -307,8 +307,8 @@ int ShowPopupMessage(TCHAR *title, TCHAR *message, int cUnreadEmails) popup.colorBack = NULL;
popup.colorText = NULL;
popup.lchIcon = hiMailIcon;
- _tcsncpy(popup.lptzContactName, title, MAX_CONTACTNAME);
- _tcsncpy(popup.lptzText, message, MAX_SECONDLINE);
+ _tcsncpy_s(popup.lptzContactName, MAX_CONTACTNAME, title, _TRUNCATE);
+ _tcsncpy_s(popup.lptzText, MAX_SECONDLINE, message, _TRUNCATE);
popup.PluginWindowProc = DlgProcPopup;
popup.PluginData = (int *) cUnreadEmails;
return PUAddPopupT(&popup);
diff --git a/plugins/Exchange/src/utils.cpp b/plugins/Exchange/src/utils.cpp index 2d89cd267e..21b3643df2 100644 --- a/plugins/Exchange/src/utils.cpp +++ b/plugins/Exchange/src/utils.cpp @@ -71,9 +71,8 @@ int Info(char *title, char *format, ...) va_start(vararg, format);
tBytes = mir_vsnprintf(str, sizeof(str), format, vararg);
if (tBytes > 0)
- {
- str[tBytes] = 0;
- }
+ str[tBytes] = 0;
+
va_end(vararg);
return MessageBoxA(0, str, title, MB_OK | MB_ICONINFORMATION);
}
@@ -83,7 +82,6 @@ int Info(char *title, char *format, ...) char *BinToHex(int size, PBYTE data)
{
char *szresult = NULL;
- char buffer[32] = {0}; //should be more than enough
int maxSize = size * 2 + HEX_SIZE + 1;
szresult = (char *) new char[ maxSize ];
mir_snprintf(szresult, maxSize, "%0*X", HEX_SIZE, size);
@@ -98,16 +96,13 @@ void HexToBin(TCHAR *inData, ULONG &size, LPBYTE &outData) _tcsncpy(buffer + 2, inData, HEX_SIZE);
_stscanf(buffer, _T("%x"), &size);
outData = (unsigned char*)new char[size*2];
- UINT i;
- //size = i;
+
TCHAR *tmp = inData + HEX_SIZE;
buffer[4] = '\0'; //mark the end of the string
- for (i = 0; i < size; i++)
- {
- _tcsncpy(buffer + 2, &tmp[i * 2], 2);
- _stscanf(buffer, _T("%x"), &outData[i]);
- }
- i = size;
+ for (UINT i = 0; i < size; i++) {
+ _tcsncpy(buffer + 2, &tmp[i * 2], 2);
+ _stscanf(buffer, _T("%x"), &outData[i]);
+ }
}
int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult, int size)
@@ -116,22 +111,21 @@ int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult, int res = 1;
int len;
dbv.type = DBVT_ASCIIZ;
- if (db_get_ts(NULL, ModuleName, szSettingName, &dbv) == 0)
- {
- res = 0;
- int tmp = _tcslen(dbv.ptszVal);
- len = (tmp < size - 1) ? tmp : size - 1;
- _tcsncpy(szResult, dbv.ptszVal, len);
- szResult[len] = '\0';
- mir_free(dbv.ptszVal);
- }
- else{
- res = 1;
- int tmp = _tcslen(szError);
- len = (tmp < size - 1) ? tmp : size - 1;
- _tcsncpy(szResult, szError, len);
- szResult[len] = '\0';
- }
+ if (db_get_ts(NULL, ModuleName, szSettingName, &dbv) == 0) {
+ res = 0;
+ int tmp = _tcslen(dbv.ptszVal);
+ len = (tmp < size - 1) ? tmp : size - 1;
+ _tcsncpy(szResult, dbv.ptszVal, len);
+ szResult[len] = '\0';
+ mir_free(dbv.ptszVal);
+ }
+ else {
+ res = 1;
+ int tmp = _tcslen(szError);
+ len = (tmp < size - 1) ? tmp : size - 1;
+ _tcsncpy(szResult, szError, len);
+ szResult[len] = '\0';
+ }
return res;
}
@@ -155,9 +149,8 @@ void AnchorMoveWindow(HWND window, const WINDOWPOS *parentPos, int anchors) RECT rChild;
if (parentPos->flags & SWP_NOSIZE)
- {
- return;
- }
+ return;
+
GetWindowRect(parentPos->hwnd, &rParent);
rChild = AnchorCalcPos(window, &rParent, parentPos, anchors);
MoveWindow(window, rChild.left, rChild.top, rChild.right - rChild.left, rChild.bottom - rChild.top, FALSE);
@@ -174,13 +167,10 @@ RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, int cx = rParent->right - rParent->left;
int cy = rParent->bottom - rParent->top;
if ((cx == parentPos->cx) && (cy == parentPos->cy))
- {
- return rChild;
- }
+ return rChild;
+
if (parentPos->flags & SWP_NOSIZE)
- {
- return rChild;
- }
+ return rChild;
rTmp.left = parentPos->x - rParent->left;
rTmp.right = (parentPos->x + parentPos->cx) - rParent->right;
@@ -194,21 +184,17 @@ RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, rChild.bottom += cy;
//expanded the window accordingly, now we need to enforce the anchors
if ((anchors & ANCHOR_LEFT) && (!(anchors & ANCHOR_RIGHT)))
- {
- rChild.right -= cx;
- }
+ rChild.right -= cx;
+
if ((anchors & ANCHOR_TOP) && (!(anchors & ANCHOR_BOTTOM)))
- {
- rChild.bottom -= cy;
- }
+ rChild.bottom -= cy;
+
if ((anchors & ANCHOR_RIGHT) && (!(anchors & ANCHOR_LEFT)))
- {
- rChild.left += cx;
- }
+ rChild.left += cx;
+
if ((anchors & ANCHOR_BOTTOM) && (!(anchors & ANCHOR_TOP)))
- {
- rChild.top += cy;
- }
+ rChild.top += cy;
+
return rChild;
}
@@ -219,9 +205,8 @@ DWORD WINAPI CheckEmailWorkerThread(LPVOID data) int bForceAttempt = (int) data;
if (!exchangeServer.IsConnected())
- {
- exchangeServer.Connect(bForceAttempt);
- }
+ exchangeServer.Connect(bForceAttempt);
+
exchangeServer.Check(bForceAttempt);
LeaveCriticalSection(&csCheck);
@@ -245,6 +230,4 @@ void _popupUtil(char* szMsg) _tcscpy(ppd.lptzContactName, _T("Exchange notifier"));
_tcscpy(ppd.lptzText, mir_a2t(szMsg));
PUAddPopupT(&ppd); //show a popup to tell the user what we're doing.
-
-
}
diff --git a/plugins/FTPFileYM/src/ftpfile.cpp b/plugins/FTPFileYM/src/ftpfile.cpp index 225a1c6d82..1240f4aa89 100644 --- a/plugins/FTPFileYM/src/ftpfile.cpp +++ b/plugins/FTPFileYM/src/ftpfile.cpp @@ -442,7 +442,7 @@ int Shutdown(WPARAM wParam, LPARAM lParam) {
deleteTimer.deinit();
- if (manDlg) delete manDlg;
+ delete manDlg;
if (uDlg) SendMessage(uDlg->hwnd, WM_CLOSE, 0, 0);
UploadJob::jobDone.release();
diff --git a/plugins/FTPFileYM/src/job_packer.cpp b/plugins/FTPFileYM/src/job_packer.cpp index cdfa799493..8002d2b0ed 100644 --- a/plugins/FTPFileYM/src/job_packer.cpp +++ b/plugins/FTPFileYM/src/job_packer.cpp @@ -52,7 +52,7 @@ void PackerJob::getZipFilePath() }
}
- if (_tcslen(stzFileName) == 0)
+ if (stzFileName[0] == '\0')
_tcscpy(stzFileName, _T("archive"));
GetTempPath(SIZEOF(buff), buff);
diff --git a/plugins/FileAsMessage/src/dialog.cpp b/plugins/FileAsMessage/src/dialog.cpp index 2c2f86ce84..ba9e2ec7c2 100644 --- a/plugins/FileAsMessage/src/dialog.cpp +++ b/plugins/FileAsMessage/src/dialog.cpp @@ -447,7 +447,7 @@ void FILEECHO::incomeRequest(char *param) if(p == NULL) return; *p++ = 0;
CallService(MS_FILE_GETRECEIVEDFILESFOLDER, (WPARAM)hContact, (LPARAM)buf);
strncat(buf, param, sizeof(buf));
- if(filename) free(filename);
+ free(filename);
filename = strdup(buf);
// p == &c
if(*p == 0) return; asBinary = (*p++) != '0';
@@ -1005,6 +1005,7 @@ LRESULT CALLBACK ProgressWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa INT_PTR CALLBACK DialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
struct FILEECHO *dat = (struct FILEECHO*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
+ HWND hwndStatus = NULL;
switch( uMsg )
{
case WM_INITDIALOG:
@@ -1014,7 +1015,7 @@ INT_PTR CALLBACK DialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam dat->updateTitle();
- CreateStatusWindow(WS_CHILD|WS_VISIBLE, "", hDlg, IDC_STATUS);
+ hwndStatus = CreateStatusWindow(WS_CHILD|WS_VISIBLE, "", hDlg, IDC_STATUS);
SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG)dat);
WindowList_Add(hFileList, hDlg, dat->hContact);
SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcons[ICON_MAIN]);
@@ -1058,8 +1059,7 @@ INT_PTR CALLBACK DialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam char *szProto = GetContactProto(dat->hContact);
if (szProto)
{
- int dwStatus;
- dwStatus = db_get_w(dat->hContact,szProto,"Status",ID_STATUS_OFFLINE);
+ int dwStatus = db_get_w(dat->hContact,szProto,"Status",ID_STATUS_OFFLINE);
if(dat->inSend && dwStatus != dat->contactStatus)
{
if(dat->contactStatus == ID_STATUS_OFFLINE)
@@ -1085,6 +1085,7 @@ INT_PTR CALLBACK DialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam }
case WM_DESTROY:
WindowList_Remove(hFileList, hDlg);
+ DestroyWindow(hwndStatus);
delete dat;
return TRUE;
@@ -1103,7 +1104,7 @@ INT_PTR CALLBACK DialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam if(dat->iState & (STATE_IDLE|STATE_FINISHED|STATE_CANCELLED|STATE_PRERECV))
{
int len = GetWindowTextLength(GetDlgItem(hDlg, IDC_FILENAME))+1;
- if(dat->filename) free(dat->filename);
+ free(dat->filename);
dat->filename = (char*)malloc(len);
GetDlgItemText(hDlg, IDC_FILENAME, dat->filename, len);
if(dat->inSend)
diff --git a/plugins/FlashAvatars/src/cflash.cpp b/plugins/FlashAvatars/src/cflash.cpp index ba7716273b..5d8c0a70e8 100644 --- a/plugins/FlashAvatars/src/cflash.cpp +++ b/plugins/FlashAvatars/src/cflash.cpp @@ -106,7 +106,7 @@ static bool DownloadFlashFile(char *url, const TCHAR* save_file, int recurse_cou HANDLE hSaveFile = CreateFile(save_file, GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if(hSaveFile != INVALID_HANDLE_VALUE) {
unsigned long bytes_written = 0;
- if(WriteFile(hSaveFile, resp->pData, resp->dataLength, &bytes_written, NULL) == TRUE) {
+ if(WriteFile(hSaveFile, resp->pData, resp->dataLength, &bytes_written, NULL)) {
CloseHandle(hSaveFile);
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
resp = 0;
diff --git a/plugins/FloatingContacts/src/bitmap_funcs.cpp b/plugins/FloatingContacts/src/bitmap_funcs.cpp index 36fb31a185..b6dc796822 100644 --- a/plugins/FloatingContacts/src/bitmap_funcs.cpp +++ b/plugins/FloatingContacts/src/bitmap_funcs.cpp @@ -65,8 +65,7 @@ MyBitmap::MyBitmap(const char *fn, const char *fnAlpha) MyBitmap::~MyBitmap()
{
- if (bitsSave)
- delete [] bitsSave;
+ delete [] bitsSave;
free();
}
@@ -125,8 +124,7 @@ void MyBitmap::makeOpaqueRect(int x1, int y1, int x2, int y2) void MyBitmap::saveAlpha(int x, int y, int w, int h)
{
- if (bitsSave)
- delete [] bitsSave;
+ delete [] bitsSave;
GdiFlush();
@@ -670,7 +668,6 @@ void MyBitmap::Blur(int w, int h) src = buf_src;
tmp = buf_tmp;
- dst = buf_dst;
float mul = 1.f/((w*2+1)*(h*2+1));
for (y = 0;y<height;y++)
diff --git a/plugins/FloatingContacts/src/main.cpp b/plugins/FloatingContacts/src/main.cpp index ec0e266b33..9e2892a204 100644 --- a/plugins/FloatingContacts/src/main.cpp +++ b/plugins/FloatingContacts/src/main.cpp @@ -655,7 +655,7 @@ void RegHotkey(HANDLE hContact, HWND hwnd) strncpy(szBuf, dbv.pszVal, MAX_PATH - 1);
db_free( &dbv );
- if ( 0 != strlen( szBuf )) {
+ if (szBuf[0] != '\0') {
UINT nModifiers = 0;
char chKey = 0;
char szMod[2][20] = {0};
diff --git a/plugins/FloatingContacts/src/thumbs.cpp b/plugins/FloatingContacts/src/thumbs.cpp index ae14979ff0..ecbe70c6bb 100644 --- a/plugins/FloatingContacts/src/thumbs.cpp +++ b/plugins/FloatingContacts/src/thumbs.cpp @@ -774,17 +774,15 @@ ThumbInfo *ThumbList::AddThumb(HWND hwnd, TCHAR *ptszName, HANDLE hContact) return NULL;
ThumbInfo *pThumb = new ThumbInfo;
- if (pThumb != NULL) {
- _tcsncpy( pThumb->ptszName, ptszName, USERNAME_LEN - 1);
- pThumb->hContact = hContact;
- pThumb->hwnd = hwnd;
-
- pThumb->dockOpt.hwndLeft = NULL;
- pThumb->dockOpt.hwndRight = NULL;
+ _tcsncpy( pThumb->ptszName, ptszName, USERNAME_LEN - 1);
+ pThumb->hContact = hContact;
+ pThumb->hwnd = hwnd;
- pThumb->fTipActive = FALSE;
- RegHotkey(hContact, hwnd);
- }
+ pThumb->dockOpt.hwndLeft = NULL;
+ pThumb->dockOpt.hwndRight = NULL;
+
+ pThumb->fTipActive = FALSE;
+ RegHotkey(hContact, hwnd);
insert(pThumb);
return pThumb;
diff --git a/plugins/Folders/src/utils.cpp b/plugins/Folders/src/utils.cpp index 93d572cf78..e21a820325 100644 --- a/plugins/Folders/src/utils.cpp +++ b/plugins/Folders/src/utils.cpp @@ -127,8 +127,8 @@ wchar_t *StrReplace(wchar_t *source, const wchar_t *what, const wchar_t *withWha char *StrTrim(char *szText, const char *szTrimChars)
{
- size_t i = strlen(szText) - 1;
- while ((i >= 0) && (strchr(szTrimChars, szText[i])))
+ int i = (int)strlen(szText) - 1;
+ while (i >= 0 && strchr(szTrimChars, szText[i]))
szText[i--] = '\0';
i = 0;
@@ -143,8 +143,8 @@ char *StrTrim(char *szText, const char *szTrimChars) wchar_t *StrTrim(wchar_t *szText, const wchar_t *szTrimChars)
{
- size_t i = wcslen(szText) - 1;
- while ((i >= 0) && (wcschr(szTrimChars, szText[i])))
+ int i = (int)wcslen(szText) - 1;
+ while (i >= 0 && wcschr(szTrimChars, szText[i]))
szText[i--] = '\0';
i = 0;
diff --git a/plugins/HTTPServer/src/IndexHTML.cpp b/plugins/HTTPServer/src/IndexHTML.cpp index 651b74c867..f1f15fbc44 100644 --- a/plugins/HTTPServer/src/IndexHTML.cpp +++ b/plugins/HTTPServer/src/IndexHTML.cpp @@ -328,7 +328,7 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, if (pszTemp)
strcpy(szName, pszTemp + 1);
- if (strlen(szName) == 0)
+ if (szName[0] == '\0')
strcpy(szName, "my Miranda Webserver");
do {
diff --git a/protocols/EmLanProto/src/mlan.cpp b/protocols/EmLanProto/src/mlan.cpp index 11367d265a..1b84fb79c7 100644 --- a/protocols/EmLanProto/src/mlan.cpp +++ b/protocols/EmLanProto/src/mlan.cpp @@ -321,7 +321,7 @@ void CMLan::OnRecvPacket(u_char* mes, int len, in_addr from) db_set_w(hContact,PROTONAME, "Status", cont->m_status);
if (db_get_dw(hContact,PROTONAME, "RemoteVersion", 0)!=cont->m_ver)
db_set_dw(hContact,PROTONAME, "RemoteVersion", cont->m_ver);
- if (old_status = ID_STATUS_OFFLINE)
+ if (old_status == ID_STATUS_OFFLINE)
{
u_int rip = cont->m_addr.S_un.S_addr;
int tip = (rip<<24)|((rip&0xff00)<<8)|((rip&0xff0000)>>8)|(rip>>24);
@@ -428,7 +428,7 @@ void CMLan::RecvMessageUrl(CCSDATA* ccs) ZeroMemory(&dbei,sizeof(dbei));
- if (ccs->szProtoService == PSR_MESSAGE)
+ if (!lstrcmpA(ccs->szProtoService, PSR_MESSAGE))
dbei.eventType = EVENTTYPE_MESSAGE;
else
dbei.eventType = EVENTTYPE_URL;
@@ -438,7 +438,7 @@ void CMLan::RecvMessageUrl(CCSDATA* ccs) dbei.timestamp = pre->timestamp;
dbei.flags = pre->flags&PREF_CREATEREAD?DBEF_READ:0;
dbei.cbBlob = lstrlen(pre->szMessage)+1;
- if (ccs->szProtoService==PSR_URL)
+ if (!lstrcmpA(ccs->szProtoService, PSR_URL))
{
dbei.cbBlob += 2+lstrlen(pre->szMessage+dbei.cbBlob+1);
}
diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp index 48bfd898ba..ab9011b8b4 100644 --- a/protocols/FacebookRM/src/avatars.cpp +++ b/protocols/FacebookRM/src/avatars.cpp @@ -40,7 +40,6 @@ bool FacebookProto::GetDbAvatarInfo(PROTO_AVATAR_INFORMATIONT &ai, std::string * std::tstring filename = GetAvatarFolder() + L'\\' + dbv.ptszVal + (TCHAR*)_A2T(ext.c_str());
db_free(&dbv);
- ai.hContact = ai.hContact;
_tcsncpy_s(ai.filename, SIZEOF(ai.filename), filename.c_str(), _TRUNCATE);
ai.format = ProtoGetAvatarFormat(ai.filename);
return true;
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 85547d09bb..fb2f712265 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -583,7 +583,7 @@ NETLIBHTTPHEADER* facebook_client::get_request_headers(int request_type, int* he std::string facebook_client::get_newsfeed_type()
{
BYTE feed_type = parent->getByte(FACEBOOK_KEY_FEED_TYPE, 0);
- if (feed_type < 0 || feed_type >= SIZEOF(feed_types))
+ if (feed_type >= SIZEOF(feed_types))
feed_type = 0;
return feed_types[feed_type].id;
}
@@ -591,7 +591,7 @@ std::string facebook_client::get_newsfeed_type() std::string facebook_client::get_server_type()
{
BYTE server_type = parent->getByte(FACEBOOK_KEY_SERVER_TYPE, 0);
- if (server_type < 0 || server_type >= SIZEOF(server_types))
+ if (server_type >= SIZEOF(server_types))
server_type = 0;
return server_types[server_type].id;
}
@@ -599,7 +599,7 @@ std::string facebook_client::get_server_type() std::string facebook_client::get_privacy_type()
{
BYTE privacy_type = parent->getByte(FACEBOOK_KEY_PRIVACY_TYPE, 0);
- if (privacy_type < 0 || privacy_type >= SIZEOF(privacy_types))
+ if (privacy_type >= SIZEOF(privacy_types))
privacy_type = 0;
return privacy_types[privacy_type].id;
}
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp index fbc388bf26..e946928c4f 100644 --- a/protocols/FacebookRM/src/dialogs.cpp +++ b/protocols/FacebookRM/src/dialogs.cpp @@ -408,7 +408,7 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp proto->setString(FACEBOOK_KEY_PASS, str);
GetDlgItemText(hwnd,IDC_GROUP,tstr,sizeof(tstr));
- if (lstrlen(tstr) > 0)
+ if (tstr[0] != '\0')
{
proto->setTString(FACEBOOK_KEY_DEF_GROUP, tstr);
Clist_CreateGroup( 0, tstr);
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 9abb95c088..4611d3119b 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -515,7 +515,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa }
}
- HANDLE hChatContact;
+ HANDLE hChatContact = NULL;
// RM TODO: better use check if chatroom exists/is in db/is online... no?
/// e.g. HANDLE hChatContact = proto->ChatIDToHContact(thread_id); ?
@@ -593,7 +593,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa if (time_ == NULL)
continue;
JSONNODE *time = json_get(time_, "time");
- if (time == NULL || text == NULL || url == NULL || alert_id == NULL || time == NULL)
+ if (time == NULL || text == NULL || url == NULL || alert_id == NULL)
continue;
unsigned __int64 timestamp = json_as_float(time);
@@ -659,7 +659,6 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa JSONNODE *time_ = json_get(it, "actor");
JSONNODE *story_ = json_get(it, "story_xhp");
- std::string id = json_as_pstring(actor_);
time_t time = json_as_float(time_);
std::string text = json_as_pstring(story_);
text = utils::text::slashu_to_utf8(text);
@@ -711,7 +710,6 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa JSONNODE *alert_ids = json_get(it, "alert_ids");
for (unsigned int n = 0; n < json_size(alert_ids); n++) {
JSONNODE *idItr = json_at(alert_ids, n);
- std::string alert_id = json_as_pstring(idItr);
// PUDeletePopup(hWndPopup);
}
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index 866bc8cf00..e4731c0111 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -357,7 +357,7 @@ void FacebookProto::ProcessUnreadMessage(void *p) for (std::map<std::string, facebook_chatroom*>::iterator it = chatrooms.begin(); it != chatrooms.end(); ) {
facebook_chatroom *room = it->second;
- HANDLE hChatContact;
+ HANDLE hChatContact = NULL;
if (GetChatUsers(room->thread_id.c_str()) == NULL) {
AddChat(room->thread_id.c_str(), room->chat_name.c_str());
hChatContact = ChatIDToHContact(room->thread_id);
@@ -366,7 +366,7 @@ void FacebookProto::ProcessUnreadMessage(void *p) for (std::map<std::string, std::string>::iterator jt = room->participants.begin(); jt != room->participants.end(); ) {
AddChatContact(room->thread_id.c_str(), jt->first.c_str(), jt->second.c_str());
- jt++;
+ ++jt;
}
}
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 834f096c3d..86ab425c2d 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -63,12 +63,9 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) : // Create standard network connection
TCHAR descr[512];
- char module[512];
NETLIBUSER nlu = {sizeof(nlu)};
nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR;
nlu.szSettingsModule = m_szModuleName;
- mir_snprintf(module, SIZEOF(module), "%s", m_szModuleName);
- nlu.szSettingsModule = module;
mir_sntprintf(descr, SIZEOF(descr), TranslateT("%s server connection"), m_tszUserName);
nlu.ptszDescriptiveName = descr;
m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
@@ -726,8 +723,7 @@ LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa {
// After close, free
popup_data *data = (popup_data *)PUGetPluginData(hwnd);
- if (data != NULL)
- delete data;
+ delete data;
} return FALSE;
default:
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index ad7933052f..0845a550be 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -97,7 +97,7 @@ int GGPROTO::gc_destroy() for(l = chats; l; l = l->next)
{
GGGC *chat = (GGGC *)l->data;
- if (chat->recipients) free(chat->recipients);
+ free(chat->recipients);
}
list_destroy(chats, 1); chats = NULL;
return 1;
@@ -606,7 +606,7 @@ INT_PTR GGPROTO::gc_clearignored(WPARAM wParam, LPARAM lParam) l = l->next;
if (chat->ignore)
{
- if (chat->recipients) free(chat->recipients);
+ free(chat->recipients);
list_remove(&chats, chat, 1);
cleared = TRUE;
}
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index 88efe07a86..abcd765e88 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -139,12 +139,10 @@ static int gg_img_releasepicture(void *img) {
if (!img)
return FALSE;
- if (((GGIMAGEENTRY *)img)->lpszFileName)
- free(((GGIMAGEENTRY *)img)->lpszFileName);
+ free(((GGIMAGEENTRY *)img)->lpszFileName);
if (((GGIMAGEENTRY *)img)->hBitmap)
DeleteObject(((GGIMAGEENTRY *)img)->hBitmap);
- if (((GGIMAGEENTRY *)img)->lpData)
- free(((GGIMAGEENTRY *)img)->lpData);
+ free(((GGIMAGEENTRY *)img)->lpData);
free(img);
return TRUE;
@@ -1067,10 +1065,8 @@ void* GGPROTO::img_loadpicture(gg_event* e, TCHAR *szFileName) debugLogA("img_loadpicture(): MS_IMG_LOAD(MEM) failed.");
if (dat)
{
- if (dat->lpData)
- free(dat->lpData);
- if (dat->lpszFileName)
- free(dat->lpszFileName);
+ free(dat->lpData);
+ free(dat->lpszFileName);
free(dat);
}
return NULL;
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp index 523d077111..1ac699ffcd 100644 --- a/protocols/Gadu-Gadu/src/import.cpp +++ b/protocols/Gadu-Gadu/src/import.cpp @@ -237,14 +237,14 @@ void GGPROTO::parsecontacts(char *contacts) }
// Release stuff
- if (strFirstName) free(strFirstName);
- if (strLastName) free(strLastName);
- if (strNickname) free(strNickname);
- if (strNick) free(strNick);
- if (strPhone) free(strPhone);
- if (strGroup) free(strGroup);
- if (strUin) free(strUin);
- if (strMail) free(strMail);
+ free(strFirstName);
+ free(strLastName);
+ free(strNickname);
+ free(strNick);
+ free(strPhone);
+ free(strGroup);
+ free(strUin);
+ free(strMail);
}
}
diff --git a/protocols/Gadu-Gadu/src/libgadu/common.c b/protocols/Gadu-Gadu/src/libgadu/common.c index b9b41c0547..f1db6c4b7f 100644 --- a/protocols/Gadu-Gadu/src/libgadu/common.c +++ b/protocols/Gadu-Gadu/src/libgadu/common.c @@ -366,7 +366,7 @@ char *gg_read_line(SOCKET sock, char *buf, int length) *
* \ingroup helper
*/
-#ifdef GG_CONFIG_MIRANDA +#ifdef GG_CONFIG_MIRANDA
SOCKET gg_connect_internal(void *addr, int port, int async, SOCKET *gg_sock)
#else
SOCKET gg_connect(void *addr, int port, int async)
@@ -398,8 +398,8 @@ SOCKET gg_connect(void *addr, int port, int async) return -1;
}
-#ifdef GG_CONFIG_MIRANDA - if (gg_sock) *gg_sock = sock; +#ifdef GG_CONFIG_MIRANDA
+ if (gg_sock) *gg_sock = sock;
#endif
if (async) {
@@ -435,7 +435,7 @@ SOCKET gg_connect(void *addr, int port, int async) return sock;
}
-#ifdef GG_CONFIG_MIRANDA +#ifdef GG_CONFIG_MIRANDA
SOCKET gg_connect(void *addr, int port, int async)
{
return gg_connect_internal(addr, port, async, 0);
@@ -541,7 +541,7 @@ int gg_http_hash(const char *format, ...) char *arg, buf[16];
if (format[j] == 'u') {
- snprintf(buf, sizeof(buf), "%d", va_arg(ap, uin_t));
+ mir_snprintf(buf, sizeof(buf), "%d", va_arg(ap, uin_t));
arg = buf;
} else {
if (!(arg = va_arg(ap, char*)))
diff --git a/protocols/Gadu-Gadu/src/libgadu/dcc7.c b/protocols/Gadu-Gadu/src/libgadu/dcc7.c index f3813e6e83..fcfefa0500 100644 --- a/protocols/Gadu-Gadu/src/libgadu/dcc7.c +++ b/protocols/Gadu-Gadu/src/libgadu/dcc7.c @@ -330,7 +330,7 @@ static int gg_dcc7_listen_and_send_info(struct gg_dcc7 *dcc) // we MUST fill hash to recive from server request for server connection
//snprintf((char*) pkt.hash, sizeof(pkt.hash), "0");
count = dcc->local_addr + external_port * rand();
- snprintf((char*) pkt.hash, sizeof(pkt.hash), "%d", count);
+ mir_snprintf(pkt.hash, sizeof(pkt.hash), "%d", count);
return gg_send_packet(dcc->sess, GG_DCC7_INFO, &pkt, sizeof(pkt), NULL);
}
diff --git a/protocols/Gadu-Gadu/src/libgadu/pubdir.c b/protocols/Gadu-Gadu/src/libgadu/pubdir.c index f9d656dfe3..c74ff4f309 100644 --- a/protocols/Gadu-Gadu/src/libgadu/pubdir.c +++ b/protocols/Gadu-Gadu/src/libgadu/pubdir.c @@ -735,7 +735,7 @@ int gg_token_watch_fd(struct gg_http *h) gg_debug(GG_DEBUG_MISC, "=> token body \"%s\"\n", h->body);
- if (h->body && (!(url = malloc(strlen(h->body))) || !(tokenid = malloc(strlen(h->body))))) {
+ if (h->body && (!(url = (char*)malloc(strlen(h->body) + 1)) || !(tokenid = (char*)malloc(strlen(h->body) + 1)))) {
gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for results\n");
free(url);
return -1;
diff --git a/protocols/Gadu-Gadu/src/ownerinfo.cpp b/protocols/Gadu-Gadu/src/ownerinfo.cpp index a8f56eb856..25bb183156 100644 --- a/protocols/Gadu-Gadu/src/ownerinfo.cpp +++ b/protocols/Gadu-Gadu/src/ownerinfo.cpp @@ -39,7 +39,7 @@ void __cdecl GGPROTO::remindpasswordthread(void *param) debugLogA("remindpasswordthread(): Started.");
if (!rp || !rp->email || !rp->uin || !strlen(rp->email))
{
- if (rp) free(rp);
+ free(rp);
#ifdef DEBUGMODE
debugLogA("remindpasswordthread(): End. err1");
#endif
@@ -68,7 +68,7 @@ void __cdecl GGPROTO::remindpasswordthread(void *param) MessageBox(NULL, TranslateT("Password was sent to your e-mail."), m_tszUserName, MB_OK | MB_ICONINFORMATION);
}
- if (rp) free(rp);
+ free(rp);
#ifdef DEBUGMODE
debugLogA("remindpasswordthread(): End.");
#endif
|