Minor fixes

Fix release build.

Eliminate a few warnings.
This commit is contained in:
Andy McFadden 2014-11-18 14:30:51 -08:00
parent f6647b9978
commit 9a67e7b1d3
6 changed files with 29 additions and 19 deletions

View File

@ -448,7 +448,7 @@ ContentList::MakeMacTypeString(unsigned long val, WCHAR* buf)
/* sanitize */ /* sanitize */
while (*buf != '\0') { while (*buf != '\0') {
*buf = DiskImg::MacToASCII(*buf); *buf = DiskImg::MacToASCII((unsigned char)*buf);
buf++; buf++;
} }
} }
@ -536,7 +536,7 @@ ContentList::OnGetDispInfo(NMHDR* pnmh, LRESULT* pResult)
switch (plvdi->item.iSubItem) { switch (plvdi->item.iSubItem) {
case 0: // pathname case 0: // pathname
if (wcslen(pEntry->GetDisplayName()) > plvdi->item.cchTextMax) { if ((int) wcslen(pEntry->GetDisplayName()) > plvdi->item.cchTextMax) {
// looks like current limit is 264 chars, which we could hit // looks like current limit is 264 chars, which we could hit
wcsncpy(plvdi->item.pszText, pEntry->GetDisplayName(), wcsncpy(plvdi->item.pszText, pEntry->GetDisplayName(),
plvdi->item.cchTextMax); plvdi->item.cchTextMax);
@ -640,6 +640,16 @@ CompareLONGLONG(LONGLONG u1, LONGLONG u2)
else else
return 0; return 0;
} }
static inline int
CompareTime(time_t t1, time_t t2)
{
if (t1 < t2)
return -1;
else if (t1 > t2)
return 1;
else
return 0;
}
/* /*
* Static comparison function for list sorting. * Static comparison function for list sorting.
@ -687,7 +697,7 @@ ContentList::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
} }
break; break;
case 3: // mod date case 3: // mod date
result = CompareUnsignedLong(pEntry1->GetModWhen(), result = CompareTime(pEntry1->GetModWhen(),
pEntry2->GetModWhen()); pEntry2->GetModWhen());
break; break;
case 4: // format case 4: // format

View File

@ -2612,7 +2612,8 @@ DiskArchive::TestPathName(const GenericEntry* pGenericEntry,
{ {
const DiskEntry* pEntry = (DiskEntry*) pGenericEntry; const DiskEntry* pEntry = (DiskEntry*) pGenericEntry;
DiskImg::FSFormat format; DiskImg::FSFormat format;
CStringA pathName, errMsg, newNameA; CString errMsg, pathName;
CStringA newNameA;
DiskFS* pDiskFS; DiskFS* pDiskFS;
if (basePath.IsEmpty()) { if (basePath.IsEmpty()) {
@ -2631,7 +2632,7 @@ DiskArchive::TestPathName(const GenericEntry* pGenericEntry,
CStringA pathNameA(pathName); CStringA pathNameA(pathName);
existingFile = pDiskFS->GetFileByName(pathNameA); existingFile = pDiskFS->GetFileByName(pathNameA);
if (existingFile != NULL && existingFile != pEntry->GetA2File()) { if (existingFile != NULL && existingFile != pEntry->GetA2File()) {
errMsg = "A file with that name already exists."; errMsg = L"A file with that name already exists.";
goto bail; goto bail;
} }

View File

@ -93,7 +93,7 @@ RenameEntryDialog::DoDataExchange(CDataExchange* pDX)
if (fFssepStr.IsEmpty()) if (fFssepStr.IsEmpty())
fFssep = '\0'; fFssep = '\0';
else else
fFssep = fFssepStr.GetAt(0); // could be '\0', that's okay fFssep = (char) fFssepStr.GetAt(0); // could be '\0', that's okay
} }
return; return;

View File

@ -72,7 +72,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>..\prebuilt\nufxlib2.lib;..\prebuilt\zdll.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<SuppressStartupBanner>false</SuppressStartupBanner> <SuppressStartupBanner>false</SuppressStartupBanner>
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile> <ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>

View File

@ -12,11 +12,6 @@ DebugLog::DebugLog(const WCHAR* logFile)
: fLogFp(NULL) : fLogFp(NULL)
{ {
fPid = getpid(); fPid = getpid();
#ifdef _DEBUG
fDoCrtDebug = true;
#else
fDoCrtDebug = false;
#endif
if (logFile == NULL) { if (logFile == NULL) {
return; return;
@ -33,8 +28,10 @@ DebugLog::DebugLog(const WCHAR* logFile)
} }
fLogFp = _wfopen(logFile, L"a"); fLogFp = _wfopen(logFile, L"a");
if (fLogFp == NULL) { if (fLogFp == NULL) {
#ifdef _DEBUG
_CrtDbgReport(_CRT_WARN, __FILE__, __LINE__, NULL, _CrtDbgReport(_CRT_WARN, __FILE__, __LINE__, NULL,
"Unable to open %ls: %d\n", logFile, errno); "Unable to open %ls: %d\n", logFile, errno);
#endif
} else { } else {
// disable buffering so we don't lose anything if app crashes // disable buffering so we don't lose anything if app crashes
setvbuf(fLogFp, NULL, _IONBF, 0); setvbuf(fLogFp, NULL, _IONBF, 0);
@ -57,9 +54,12 @@ DebugLog::~DebugLog() {
void DebugLog::Log(LogSeverity severity, const char* file, int line, void DebugLog::Log(LogSeverity severity, const char* file, int line,
const char* format, ...) const char* format, ...)
{ {
if (fLogFp == NULL && !fDoCrtDebug) { #ifndef _DEBUG
if (fLogFp == NULL) {
// nothing to do, don't waste time formatting the string
return; return;
} }
#endif
static const char kSeverityChars[] = "?VDIWE"; static const char kSeverityChars[] = "?VDIWE";
if (severity < 0 || severity > sizeof(kSeverityChars) - 1) { if (severity < 0 || severity > sizeof(kSeverityChars) - 1) {
@ -84,10 +84,10 @@ void DebugLog::Log(LogSeverity severity, const char* file, int line,
tmbuf.tm_min, tmbuf.tm_sec, kSeverityChars[severity], tmbuf.tm_min, tmbuf.tm_sec, kSeverityChars[severity],
textBuf); textBuf);
} }
if (fDoCrtDebug) { #ifdef _DEBUG
if (_CrtDbgReport(_CRT_WARN, file, line, NULL, "%s\n", textBuf) == 1) { if (_CrtDbgReport(_CRT_WARN, file, line, NULL, "%s\n", textBuf) == 1) {
// "retry" button causes a debugger break // "retry" button causes a debugger break
_CrtDbgBreak(); _CrtDbgBreak();
}
} }
#endif
} }

View File

@ -50,7 +50,6 @@ private:
FILE* fLogFp; FILE* fLogFp;
int fPid; int fPid;
bool fDoCrtDebug;
}; };
extern DebugLog* gDebugLog; // declare and allocate in app extern DebugLog* gDebugLog; // declare and allocate in app