From a7261be70c7017e314961ad401e616ddd2e8b752 Mon Sep 17 00:00:00 2001 From: anders_k Date: Tue, 11 Feb 2014 01:34:11 +0000 Subject: [PATCH] Fixed some warnings git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6443 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/ResourceEditor.cpp | 10 ++++----- Source/ResourceVersionInfo.cpp | 11 +++++----- Source/build.cpp | 24 ++++++++++----------- Source/exehead/Ui.c | 2 +- Source/manifest.h | 2 +- Source/script.cpp | 39 +++++++++++++--------------------- Source/strlist.cpp | 2 +- 7 files changed, 40 insertions(+), 50 deletions(-) diff --git a/Source/ResourceEditor.cpp b/Source/ResourceEditor.cpp index 8f4a9b74..ae0dc298 100644 --- a/Source/ResourceEditor.cpp +++ b/Source/ResourceEditor.cpp @@ -500,12 +500,12 @@ DWORD CResourceEditor::Save(BYTE* pbBuf, DWORD &dwSize) { seeker += dwRsrcSizeAligned; // Copy everything that comes after the resource section (other sections and tacked data) - DWORD dwLeft = m_iSize - (oldSeeker - m_pbPE); - if (dwLeft) - CopyMemory(seeker, oldSeeker, dwLeft); + size_t cbLeft = m_iSize - (oldSeeker - m_pbPE); + if (cbLeft) + CopyMemory(seeker, oldSeeker, cbLeft); - seeker += dwLeft; - oldSeeker += dwLeft; + seeker += cbLeft; + oldSeeker += cbLeft; /********************************************************** * To add checksum to the header use MapFileAndCheckSum diff --git a/Source/ResourceVersionInfo.cpp b/Source/ResourceVersionInfo.cpp index 351dd376..dd3a8c2b 100644 --- a/Source/ResourceVersionInfo.cpp +++ b/Source/ResourceVersionInfo.cpp @@ -131,9 +131,8 @@ void CResourceVersionInfo::SetProductVersion(int HighPart, int LowPart) int GetVersionHeader (LPSTR &p, WORD &wLength, WORD &wValueLength, WORD &wType) { WINWCHAR *szKey; - char * baseP; - - baseP = p; + char *baseP = p; + wLength = *(WORD*)p; p += sizeof(WORD); wValueLength = *(WORD*)p; @@ -142,9 +141,9 @@ int GetVersionHeader (LPSTR &p, WORD &wLength, WORD &wValueLength, WORD &wType) p += sizeof(WORD); szKey = (WINWCHAR*)p; p += (WinWStrLen(szKey) + 1) * sizeof (WINWCHAR); - while ( ((ULONG_PTR)p % 4) != 0 ) - p++; - return p - baseP; + while ( ((ULONG_PTR)p % 4) != 0 ) p++; + + return (int)(p - baseP); } DWORD ZEROS = 0; diff --git a/Source/build.cpp b/Source/build.cpp index 17d4bc51..29882a3d 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -532,7 +532,7 @@ char* convert_processed_string_to_ansi(char *out, const TCHAR *in, WORD codepage if (NS_IS_CODE(i)) // Note: this includes '\0' { // convert all character up to, and including this code - int cb = WideCharToMultiByte(codepage, 0, in, p-in, out, (p-in)*2, NULL, NULL); + int c = (int)(p-in), cb = WideCharToMultiByte(codepage, 0, in, c, out, c*2, NULL, NULL); if (!cb && i) return 0; out += cb; if (i == _T('\0')) @@ -566,8 +566,8 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP #endif if (np - p > 1) // multibyte TCHAR { - int l = np - p; - while (l--) + size_t len = np - p; + while (len--) { _TUCHAR i = (_TUCHAR)*p++; if (NS_IS_CODE(i)) { @@ -605,7 +605,7 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP while (pUserVarName > p) { - if (m_ShellConstants.get((TCHAR*)p, pUserVarName-p) >= 0) + if (m_ShellConstants.get((TCHAR*)p, BUGBUG64TRUNCATE(int, pUserVarName-p)) >= 0) break; // Woops it's a shell constant // Jim Park: The following line could be a source of bugs for @@ -616,7 +616,7 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP // TCHAR varname[NSIS_MAX_STRLEN]; // _tcsncpy(varname, p, pUserVarName-p); // int idxUserVar = m_UserVarNames.get(varname); - int idxUserVar = m_UserVarNames.get((TCHAR*)p, pUserVarName-p); + int idxUserVar = m_UserVarNames.get((TCHAR*)p, BUGBUG64TRUNCATE(int, pUserVarName-p)); if (idxUserVar >= 0) { // Well, using variables inside string formating doens't mean @@ -644,7 +644,7 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP while (pShellConstName > p) { // Look for the identifier in the shell constants list of strings. - int idxConst = m_ShellConstants.get((TCHAR*)p, pShellConstName - p); + int idxConst = m_ShellConstants.get((TCHAR*)p, BUGBUG64TRUNCATE(int, pShellConstName - p)); // If found... if (idxConst >= 0) @@ -2999,12 +2999,12 @@ int CEXEBuild::deflateToFile(FILE *fp, char *buf, int len) // len==0 to flush ERROR_MSG(_T("Error: deflateToFile: deflate() failed(%") NPRIs _T(" [%d])\n"), compressor->GetErrStr(ret), ret); return 1; } - int l=compressor->GetNextOut()-obuf; + size_t l=compressor->GetNextOut()-obuf; if (l) { - if (fwrite(obuf,1,l,fp) != (size_t)l) + if (fwrite(obuf,1,l,fp) != l) { - ERROR_MSG(_T("Error: deflateToFile fwrite(%d) failed\n"),l); + ERROR_MSG(_T("Error: deflateToFile fwrite(%lu) failed\n"),(unsigned long)l); return 1; } fflush(fp); @@ -3152,7 +3152,7 @@ int CEXEBuild::uninstall_generate() compressor->Compress(0); if (compressor->GetNextOut() - obuf > 0) { - udata.add(obuf, compressor->GetNextOut() - obuf); + udata.add(obuf, BUGBUG64TRUNCATE(int, compressor->GetNextOut() - obuf)); } } @@ -3169,7 +3169,7 @@ int CEXEBuild::uninstall_generate() compressor->SetNextOut(obuf, sizeof(obuf)); compressor->Compress(0); if (compressor->GetNextOut() - obuf > 0) - udata.add(obuf, compressor->GetNextOut() - obuf); + udata.add(obuf, BUGBUG64TRUNCATE(int, compressor->GetNextOut() - obuf)); } ubuild_datablock.release(); @@ -3183,7 +3183,7 @@ int CEXEBuild::uninstall_generate() compressor->SetNextOut(obuf, sizeof(obuf)); compressor->Compress(C_FINISH); if (compressor->GetNextOut() - obuf > 0) - udata.add(obuf, compressor->GetNextOut() - obuf); + udata.add(obuf, BUGBUG64TRUNCATE(int, compressor->GetNextOut() - obuf)); else break; } compressor->End(); diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 18c7191d..be314d83 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -986,7 +986,7 @@ static INT_PTR CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l { static TCHAR bt[NSIS_MAX_STRLEN]; BROWSEINFO bi = {0,}; - ITEMIDLIST *idlist; + LPITEMIDLIST idlist; bi.hwndOwner = hwndDlg; bi.pszDisplayName = g_tmp; bi.lpfn = BrowseCallbackProc; diff --git a/Source/manifest.h b/Source/manifest.h index 3bcb79bf..b631b6e6 100644 --- a/Source/manifest.h +++ b/Source/manifest.h @@ -78,7 +78,7 @@ namespace manifest m_list.deleteall(); append(_T("Win7")); append(_T("Win8")); - append(_T("Win8.1")); // In the default list because GetVersion(Ex) supposedly lies if this is not set in the manifest + append(_T("Win8.1")); // In the default list because GetVersion[Ex] lies if this is not set in the manifest m_isdefaultlist = true; } }; diff --git a/Source/script.cpp b/Source/script.cpp index 16491350..7a1bd704 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -2188,11 +2188,11 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) } else { - int v=_tcstoul(p,&p,16); - build_header.license_bg=((v&0xff)<<16)|(v&0xff00)|((v&0xff0000)>>16); - build_uninst.license_bg=build_header.license_bg; - SCRIPT_MSG(_T("LicenseBkColor: %06X\n"),v); - } + int v=_tcstoul(p,&p,16); + build_header.license_bg=((v&0xff)<<16)|(v&0xff00)|((v&0xff0000)>>16); + build_uninst.license_bg=build_header.license_bg; + SCRIPT_MSG(_T("LicenseBkColor: %06X\n"),v); + } } return PS_OK; #else//!NSIS_CONFIG_LICENSEPAGE @@ -2311,7 +2311,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) int k=line.gettoken_enum(1,rootkeys[0]); if (k == -1) k=line.gettoken_enum(1,rootkeys[1]); if (k == -1) PRINTHELP() - build_header.install_reg_rootkey=(INT_PTR)rootkey_tab[k]; + build_header.install_reg_rootkey=(INT)rootkey_tab[k]; if (!build_header.install_reg_rootkey) PRINTHELP() // SHCTX is invalid here build_header.install_reg_key_ptr = add_string(line.gettoken_str(2),0); if (line.gettoken_str(2)[0] == _T('\\')) @@ -2327,10 +2327,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) return PS_OK; case TOK_INSTPROGRESSFLAGS: { - int x; int smooth=0; build_header.flags&=~CH_FLAGS_PROGRESS_COLORED; - for (x = 1; x < line.getnumtokens(); x ++) + for (int x = 1; x < line.getnumtokens(); x ++) { if (!_tcsicmp(line.gettoken_str(x),_T("smooth"))) smooth=1; else if (!_tcsicmp(line.gettoken_str(x),_T("colored"))) build_header.flags|=CH_FLAGS_PROGRESS_COLORED; @@ -2344,14 +2343,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) CDialogTemplate dt(dlg,build_unicode,uDefCodePage); res_editor->FreeResource(dlg); DialogItemTemplate* progress = dt.GetItem(IDC_PROGRESS); - if (!progress) { - throw runtime_error("IDC_PROGRESS doesn't exist!"); - } + if (!progress) throw runtime_error("IDC_PROGRESS doesn't exist!"); - if (smooth) - progress->dwStyle |= PBS_SMOOTH; - else - progress->dwStyle &= ~PBS_SMOOTH; + if (smooth) progress->dwStyle |= PBS_SMOOTH; else progress->dwStyle &= ~PBS_SMOOTH; DWORD dwSize; dlg = dt.Save(dwSize); @@ -2596,10 +2590,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) int k=line.gettoken_enum(1,_T("on\0off\0")); if (k == -1) PRINTHELP() SCRIPT_MSG(_T("XPStyle: %") NPRIs _T("\n"), line.gettoken_str(1)); - if (!k) - manifest_comctl = manifest::comctl_xp; - else - manifest_comctl = manifest::comctl_old; + manifest_comctl = !k ? manifest::comctl_xp : manifest::comctl_old; } return PS_OK; case TOK_CHANGEUI: @@ -5471,7 +5462,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) int k=line.gettoken_enum(2,rootkeys[0]); if (k == -1) k=line.gettoken_enum(2,rootkeys[1]); if (ent.offsets[0] == -1 || k == -1) PRINTHELP() - ent.offsets[1]=(INT_PTR)rootkey_tab[k]; + ent.offsets[1]=(INT)rootkey_tab[k]; ent.offsets[2]=add_string(line.gettoken_str(3)); ent.offsets[3]=add_string(line.gettoken_str(4)); if (which_token == TOK_READREGDWORD) ent.offsets[4]=1; @@ -5503,7 +5494,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) if (k == -1) k=line.gettoken_enum(a,rootkeys[1]); if (k == -1) PRINTHELP() ent.which=EW_DELREG; - ent.offsets[1]=(INT_PTR)rootkey_tab[k]; + ent.offsets[1]=(INT)rootkey_tab[k]; ent.offsets[2]=add_string(line.gettoken_str(a+1)); ent.offsets[3]=(which_token==TOK_DELETEREGKEY)?0:add_string(line.gettoken_str(a+2)); if (line.gettoken_str(a+1)[0] == _T('\\')) @@ -5523,7 +5514,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) if (k == -1) k=line.gettoken_enum(1,rootkeys[1]); if (k == -1) PRINTHELP() ent.which=EW_WRITEREG; - ent.offsets[0]=(INT_PTR)rootkey_tab[k]; + ent.offsets[0]=(INT)rootkey_tab[k]; ent.offsets[1]=add_string(line.gettoken_str(2)); if (line.gettoken_str(2)[0] == _T('\\')) warning_fl(_T("%") NPRIs _T(": registry path name begins with \'\\\', may cause problems"),line.gettoken_str(0)); @@ -5593,7 +5584,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) int k=line.gettoken_enum(2,rootkeys[0]); if (k == -1) k=line.gettoken_enum(2,rootkeys[1]); if (ent.offsets[0] == -1 || k == -1) PRINTHELP() - ent.offsets[1]=(INT_PTR)rootkey_tab[k]; + ent.offsets[1]=(INT)rootkey_tab[k]; ent.offsets[2]=add_string(line.gettoken_str(3)); ent.offsets[3]=add_string(line.gettoken_str(4)); ent.offsets[4]=which_token == TOK_ENUMREGKEY; @@ -6801,7 +6792,7 @@ DefineList *CEXEBuild::searchParseString(const TCHAR *source_string, LineParser& { toklen = (int) _tcslen(tok); while (*source_string && (ignCase?_tcsnicmp(source_string,tok,toklen):_tcsncmp(source_string,tok,toklen))) source_string++; - maxlen = source_string - src_start; // Length of previous string + maxlen = (int)(source_string - src_start); // Length of previous string } if (defout && defout[0]) // We now know the start and length of the previous string, add it to the list { diff --git a/Source/strlist.cpp b/Source/strlist.cpp index ec5cfd94..52a4f38d 100644 --- a/Source/strlist.cpp +++ b/Source/strlist.cpp @@ -114,7 +114,7 @@ unsigned int ExeHeadStringList::find(const void *ptr, unsigned int cchF, WORD co if (processed) { char *pTmp = convert_processed_string_to_ansi(bufMB,find,codepage); - cbMB = pTmp ? pTmp - bufMB : 0; + cbMB = (int)(pTmp ? pTmp - bufMB : 0); } else {