Fixed some warnings

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6443 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2014-02-11 01:34:11 +00:00
parent 07183c43a9
commit a7261be70c
7 changed files with 40 additions and 50 deletions

View file

@ -500,12 +500,12 @@ DWORD CResourceEditor::Save(BYTE* pbBuf, DWORD &dwSize) {
seeker += dwRsrcSizeAligned; seeker += dwRsrcSizeAligned;
// Copy everything that comes after the resource section (other sections and tacked data) // Copy everything that comes after the resource section (other sections and tacked data)
DWORD dwLeft = m_iSize - (oldSeeker - m_pbPE); size_t cbLeft = m_iSize - (oldSeeker - m_pbPE);
if (dwLeft) if (cbLeft)
CopyMemory(seeker, oldSeeker, dwLeft); CopyMemory(seeker, oldSeeker, cbLeft);
seeker += dwLeft; seeker += cbLeft;
oldSeeker += dwLeft; oldSeeker += cbLeft;
/********************************************************** /**********************************************************
* To add checksum to the header use MapFileAndCheckSum * To add checksum to the header use MapFileAndCheckSum

View file

@ -131,9 +131,8 @@ void CResourceVersionInfo::SetProductVersion(int HighPart, int LowPart)
int GetVersionHeader (LPSTR &p, WORD &wLength, WORD &wValueLength, WORD &wType) int GetVersionHeader (LPSTR &p, WORD &wLength, WORD &wValueLength, WORD &wType)
{ {
WINWCHAR *szKey; WINWCHAR *szKey;
char * baseP; char *baseP = p;
baseP = p;
wLength = *(WORD*)p; wLength = *(WORD*)p;
p += sizeof(WORD); p += sizeof(WORD);
wValueLength = *(WORD*)p; wValueLength = *(WORD*)p;
@ -142,9 +141,9 @@ int GetVersionHeader (LPSTR &p, WORD &wLength, WORD &wValueLength, WORD &wType)
p += sizeof(WORD); p += sizeof(WORD);
szKey = (WINWCHAR*)p; szKey = (WINWCHAR*)p;
p += (WinWStrLen(szKey) + 1) * sizeof (WINWCHAR); p += (WinWStrLen(szKey) + 1) * sizeof (WINWCHAR);
while ( ((ULONG_PTR)p % 4) != 0 ) while ( ((ULONG_PTR)p % 4) != 0 ) p++;
p++;
return p - baseP; return (int)(p - baseP);
} }
DWORD ZEROS = 0; DWORD ZEROS = 0;

View file

@ -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' if (NS_IS_CODE(i)) // Note: this includes '\0'
{ {
// convert all character up to, and including this code // 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; if (!cb && i) return 0;
out += cb; out += cb;
if (i == _T('\0')) if (i == _T('\0'))
@ -566,8 +566,8 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP
#endif #endif
if (np - p > 1) // multibyte TCHAR if (np - p > 1) // multibyte TCHAR
{ {
int l = np - p; size_t len = np - p;
while (l--) while (len--)
{ {
_TUCHAR i = (_TUCHAR)*p++; _TUCHAR i = (_TUCHAR)*p++;
if (NS_IS_CODE(i)) { if (NS_IS_CODE(i)) {
@ -605,7 +605,7 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP
while (pUserVarName > p) 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 break; // Woops it's a shell constant
// Jim Park: The following line could be a source of bugs for // 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]; // TCHAR varname[NSIS_MAX_STRLEN];
// _tcsncpy(varname, p, pUserVarName-p); // _tcsncpy(varname, p, pUserVarName-p);
// int idxUserVar = m_UserVarNames.get(varname); // 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) if (idxUserVar >= 0)
{ {
// Well, using variables inside string formating doens't mean // 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) while (pShellConstName > p)
{ {
// Look for the identifier in the shell constants list of strings. // 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 found...
if (idxConst >= 0) 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); ERROR_MSG(_T("Error: deflateToFile: deflate() failed(%") NPRIs _T(" [%d])\n"), compressor->GetErrStr(ret), ret);
return 1; return 1;
} }
int l=compressor->GetNextOut()-obuf; size_t l=compressor->GetNextOut()-obuf;
if (l) 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; return 1;
} }
fflush(fp); fflush(fp);
@ -3152,7 +3152,7 @@ int CEXEBuild::uninstall_generate()
compressor->Compress(0); compressor->Compress(0);
if (compressor->GetNextOut() - obuf > 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->SetNextOut(obuf, sizeof(obuf));
compressor->Compress(0); compressor->Compress(0);
if (compressor->GetNextOut() - obuf > 0) if (compressor->GetNextOut() - obuf > 0)
udata.add(obuf, compressor->GetNextOut() - obuf); udata.add(obuf, BUGBUG64TRUNCATE(int, compressor->GetNextOut() - obuf));
} }
ubuild_datablock.release(); ubuild_datablock.release();
@ -3183,7 +3183,7 @@ int CEXEBuild::uninstall_generate()
compressor->SetNextOut(obuf, sizeof(obuf)); compressor->SetNextOut(obuf, sizeof(obuf));
compressor->Compress(C_FINISH); compressor->Compress(C_FINISH);
if (compressor->GetNextOut() - obuf > 0) if (compressor->GetNextOut() - obuf > 0)
udata.add(obuf, compressor->GetNextOut() - obuf); udata.add(obuf, BUGBUG64TRUNCATE(int, compressor->GetNextOut() - obuf));
else break; else break;
} }
compressor->End(); compressor->End();

View file

@ -986,7 +986,7 @@ static INT_PTR CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
{ {
static TCHAR bt[NSIS_MAX_STRLEN]; static TCHAR bt[NSIS_MAX_STRLEN];
BROWSEINFO bi = {0,}; BROWSEINFO bi = {0,};
ITEMIDLIST *idlist; LPITEMIDLIST idlist;
bi.hwndOwner = hwndDlg; bi.hwndOwner = hwndDlg;
bi.pszDisplayName = g_tmp; bi.pszDisplayName = g_tmp;
bi.lpfn = BrowseCallbackProc; bi.lpfn = BrowseCallbackProc;

View file

@ -78,7 +78,7 @@ namespace manifest
m_list.deleteall(); m_list.deleteall();
append(_T("Win7")); append(_T("Win7"));
append(_T("Win8")); 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; m_isdefaultlist = true;
} }
}; };

View file

@ -2311,7 +2311,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
int k=line.gettoken_enum(1,rootkeys[0]); int k=line.gettoken_enum(1,rootkeys[0]);
if (k == -1) k=line.gettoken_enum(1,rootkeys[1]); if (k == -1) k=line.gettoken_enum(1,rootkeys[1]);
if (k == -1) PRINTHELP() 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 if (!build_header.install_reg_rootkey) PRINTHELP() // SHCTX is invalid here
build_header.install_reg_key_ptr = add_string(line.gettoken_str(2),0); build_header.install_reg_key_ptr = add_string(line.gettoken_str(2),0);
if (line.gettoken_str(2)[0] == _T('\\')) if (line.gettoken_str(2)[0] == _T('\\'))
@ -2327,10 +2327,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
return PS_OK; return PS_OK;
case TOK_INSTPROGRESSFLAGS: case TOK_INSTPROGRESSFLAGS:
{ {
int x;
int smooth=0; int smooth=0;
build_header.flags&=~CH_FLAGS_PROGRESS_COLORED; 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; 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; 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); CDialogTemplate dt(dlg,build_unicode,uDefCodePage);
res_editor->FreeResource(dlg); res_editor->FreeResource(dlg);
DialogItemTemplate* progress = dt.GetItem(IDC_PROGRESS); DialogItemTemplate* progress = dt.GetItem(IDC_PROGRESS);
if (!progress) { if (!progress) throw runtime_error("IDC_PROGRESS doesn't exist!");
throw runtime_error("IDC_PROGRESS doesn't exist!");
}
if (smooth) if (smooth) progress->dwStyle |= PBS_SMOOTH; else progress->dwStyle &= ~PBS_SMOOTH;
progress->dwStyle |= PBS_SMOOTH;
else
progress->dwStyle &= ~PBS_SMOOTH;
DWORD dwSize; DWORD dwSize;
dlg = dt.Save(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")); int k=line.gettoken_enum(1,_T("on\0off\0"));
if (k == -1) PRINTHELP() if (k == -1) PRINTHELP()
SCRIPT_MSG(_T("XPStyle: %") NPRIs _T("\n"), line.gettoken_str(1)); SCRIPT_MSG(_T("XPStyle: %") NPRIs _T("\n"), line.gettoken_str(1));
if (!k) manifest_comctl = !k ? manifest::comctl_xp : manifest::comctl_old;
manifest_comctl = manifest::comctl_xp;
else
manifest_comctl = manifest::comctl_old;
} }
return PS_OK; return PS_OK;
case TOK_CHANGEUI: case TOK_CHANGEUI:
@ -5471,7 +5462,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
int k=line.gettoken_enum(2,rootkeys[0]); int k=line.gettoken_enum(2,rootkeys[0]);
if (k == -1) k=line.gettoken_enum(2,rootkeys[1]); if (k == -1) k=line.gettoken_enum(2,rootkeys[1]);
if (ent.offsets[0] == -1 || k == -1) PRINTHELP() 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[2]=add_string(line.gettoken_str(3));
ent.offsets[3]=add_string(line.gettoken_str(4)); ent.offsets[3]=add_string(line.gettoken_str(4));
if (which_token == TOK_READREGDWORD) ent.offsets[4]=1; 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) k=line.gettoken_enum(a,rootkeys[1]);
if (k == -1) PRINTHELP() if (k == -1) PRINTHELP()
ent.which=EW_DELREG; 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[2]=add_string(line.gettoken_str(a+1));
ent.offsets[3]=(which_token==TOK_DELETEREGKEY)?0:add_string(line.gettoken_str(a+2)); ent.offsets[3]=(which_token==TOK_DELETEREGKEY)?0:add_string(line.gettoken_str(a+2));
if (line.gettoken_str(a+1)[0] == _T('\\')) 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) k=line.gettoken_enum(1,rootkeys[1]);
if (k == -1) PRINTHELP() if (k == -1) PRINTHELP()
ent.which=EW_WRITEREG; 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)); ent.offsets[1]=add_string(line.gettoken_str(2));
if (line.gettoken_str(2)[0] == _T('\\')) if (line.gettoken_str(2)[0] == _T('\\'))
warning_fl(_T("%") NPRIs _T(": registry path name begins with \'\\\', may cause problems"),line.gettoken_str(0)); 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]); int k=line.gettoken_enum(2,rootkeys[0]);
if (k == -1) k=line.gettoken_enum(2,rootkeys[1]); if (k == -1) k=line.gettoken_enum(2,rootkeys[1]);
if (ent.offsets[0] == -1 || k == -1) PRINTHELP() 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[2]=add_string(line.gettoken_str(3));
ent.offsets[3]=add_string(line.gettoken_str(4)); ent.offsets[3]=add_string(line.gettoken_str(4));
ent.offsets[4]=which_token == TOK_ENUMREGKEY; ent.offsets[4]=which_token == TOK_ENUMREGKEY;
@ -6801,7 +6792,7 @@ DefineList *CEXEBuild::searchParseString(const TCHAR *source_string, LineParser&
{ {
toklen = (int) _tcslen(tok); toklen = (int) _tcslen(tok);
while (*source_string && (ignCase?_tcsnicmp(source_string,tok,toklen):_tcsncmp(source_string,tok,toklen))) source_string++; 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 if (defout && defout[0]) // We now know the start and length of the previous string, add it to the list
{ {

View file

@ -114,7 +114,7 @@ unsigned int ExeHeadStringList::find(const void *ptr, unsigned int cchF, WORD co
if (processed) if (processed)
{ {
char *pTmp = convert_processed_string_to_ansi(bufMB,find,codepage); char *pTmp = convert_processed_string_to_ansi(bufMB,find,codepage);
cbMB = pTmp ? pTmp - bufMB : 0; cbMB = (int)(pTmp ? pTmp - bufMB : 0);
} }
else else
{ {