diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-04 19:26:46 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-04 19:26:46 +0000 |
commit | fba57c10d9f9552c9c31c20283147348789ef650 (patch) | |
tree | 165c4c7ed8fad3c092bf455abf99af4a7a058383 /plugins | |
parent | 73504917190e8d183212ec62ad1668d3e72901a7 (diff) |
some code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@7499 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/CountryFlags/src/icons.cpp | 1 | ||||
-rw-r--r-- | plugins/CountryFlags/src/ip2country.cpp | 2 | ||||
-rw-r--r-- | plugins/Exchange/src/MirandaExchange.cpp | 18 | ||||
-rw-r--r-- | plugins/Exchange/src/emails.cpp | 6 | ||||
-rw-r--r-- | plugins/Exchange/src/utils.cpp | 91 | ||||
-rw-r--r-- | plugins/FTPFileYM/src/ftpfile.cpp | 2 | ||||
-rw-r--r-- | plugins/FTPFileYM/src/job_packer.cpp | 2 | ||||
-rw-r--r-- | plugins/FileAsMessage/src/dialog.cpp | 11 | ||||
-rw-r--r-- | plugins/FlashAvatars/src/cflash.cpp | 2 | ||||
-rw-r--r-- | plugins/FloatingContacts/src/bitmap_funcs.cpp | 7 | ||||
-rw-r--r-- | plugins/FloatingContacts/src/main.cpp | 2 | ||||
-rw-r--r-- | plugins/FloatingContacts/src/thumbs.cpp | 18 | ||||
-rw-r--r-- | plugins/Folders/src/utils.cpp | 8 | ||||
-rw-r--r-- | plugins/HTTPServer/src/IndexHTML.cpp | 2 |
14 files changed, 71 insertions, 101 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 {
|