From adaeb2c6eb0968f43db0df790ef33ef939c2d889 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Sat, 24 Apr 2021 13:43:04 -0700 Subject: [PATCH] Fix warnings Added explicit casts and class initializers. The problems were identified by the VS2019 compiler. --- app/ActionProgressDialog.h | 10 ++------- app/Clipboard.cpp | 2 +- app/DiskArchive.h | 10 +++++++-- app/PrefsDialog.h | 42 ++++++++++++++++++++++++++++++++++++-- app/UseSelectionDialog.h | 8 +++++++- diskimg/DiskImg.h | 8 +++++++- diskimg/OuterWrapper.cpp | 4 ++-- diskimg/Pascal.cpp | 6 +++--- diskimg/ProDOS.cpp | 12 +++++------ diskimg/Win32BlockIO.h | 10 +++++++-- reformat/Reformat.h | 15 +++++++++----- util/CancelDialog.h | 2 +- util/SelectFilesDialog.h | 3 ++- 13 files changed, 97 insertions(+), 35 deletions(-) diff --git a/app/ActionProgressDialog.h b/app/ActionProgressDialog.h index 028b9e9..ed4519a 100644 --- a/app/ActionProgressDialog.h +++ b/app/ActionProgressDialog.h @@ -28,14 +28,8 @@ public: kActionConvFile, } Action; - ActionProgressDialog(void) { - fAction = kActionUnknown; - //fpSelSet = NULL; - //fpOptionsDlg = NULL; - fCancel = false; - //fResult = 0; - } - virtual ~ActionProgressDialog(void) {} + ActionProgressDialog(void) : fAction(kActionUnknown), fCancel(false) { } + virtual ~ActionProgressDialog(void) { } BOOL Create(Action action, CWnd* pParentWnd = NULL) { fAction = action; diff --git a/app/Clipboard.cpp b/app/Clipboard.cpp index 70845cb..bc9ad10 100644 --- a/app/Clipboard.cpp +++ b/app/Clipboard.cpp @@ -459,7 +459,7 @@ CString MainWindow::CopyToCollection(GenericEntry* pEntry, void** pBuf, memset(&collEnt, 0x99, sizeof(collEnt)); collEnt.signature = kEntrySignature; collEnt.dataOffset = sizeof(collEnt); - collEnt.fileNameLen = (wcslen(pEntry->GetPathNameUNI()) +1) * sizeof(WCHAR); + collEnt.fileNameLen = (uint16_t)((wcslen(pEntry->GetPathNameUNI()) +1) * sizeof(WCHAR)); if (pEntry->GetRecordKind() == GenericEntry::kRecordKindDirectory) { collEnt.dataLen = collEnt.rsrcLen = collEnt.cmmtLen = 0; } else { diff --git a/app/DiskArchive.h b/app/DiskArchive.h index e3e1108..d83a3b8 100644 --- a/app/DiskArchive.h +++ b/app/DiskArchive.h @@ -64,8 +64,14 @@ private: */ class DiskArchive : public GenericArchive { public: - DiskArchive(void) : fpPrimaryDiskFS(NULL), fIsReadOnly(false), - fpAddDataHead(NULL), fpAddDataTail(NULL) + DiskArchive(void) : + fpPrimaryDiskFS(NULL), + fIsReadOnly(false), + fpAddDataHead(NULL), + fpAddDataTail(NULL), + fOverwriteExisting(false), + fOverwriteNoAsk(false), + fpXferTargetFS(NULL) {} virtual ~DiskArchive(void) { (void) Close(); } diff --git a/app/PrefsDialog.h b/app/PrefsDialog.h index 8917780..ffce0d2 100644 --- a/app/PrefsDialog.h +++ b/app/PrefsDialog.h @@ -23,11 +23,14 @@ public: PrefsGeneralPage(void) : CPropertyPage(IDD_PREF_GENERAL), fReady(false), + fColumn(), fMimicShrinkIt(FALSE), fBadMacSHK(FALSE), fReduceSHKErrorChecks(FALSE), fCoerceDOSFilenames(FALSE), fSpacesToUnder(FALSE), + fPasteJunkPaths(FALSE), + fBeepOnSuccess(FALSE), fDefaultsPushed(FALSE), fOurAssociations(NULL) {} @@ -82,6 +85,7 @@ public: fReady(false), fQueryImageFormat(FALSE), fOpenVolumeRO(FALSE), + fOpenVolumePhys0(FALSE), fProDOSAllowLower(FALSE), fProDOSUseSparse(FALSE) {} @@ -119,7 +123,9 @@ class PrefsCompressionPage : public CPropertyPage { public: PrefsCompressionPage(void) : - CPropertyPage(IDD_PREF_COMPRESSION), fReady(false) + CPropertyPage(IDD_PREF_COMPRESSION), + fReady(false), + fCompressType(-1) {} bool fReady; @@ -159,7 +165,39 @@ class PrefsFviewPage : public CPropertyPage { public: PrefsFviewPage(void) : - CPropertyPage(IDD_PREF_FVIEW), fReady(false) + CPropertyPage(IDD_PREF_FVIEW), + fReady(false), + fEOLConvRaw(FALSE), + fNoWrapText(FALSE), + fHighlightHexDump(FALSE), + fHighlightBASIC(FALSE), + fConvDisasmOneByteBrkCop(FALSE), + fConvMouseTextToASCII(FALSE), + fConvHiResBlackWhite(FALSE), + fConvDHRAlgorithm(-1), + fConvTextEOL_HA(FALSE), + fConvCPMText(FALSE), + fConvPascalText(FALSE), + fConvPascalCode(FALSE), + fConvApplesoft(FALSE), + fConvInteger(FALSE), + fConvBusiness(FALSE), + fConvGWP(FALSE), + fConvText8(FALSE), + fConvAWP(FALSE), + fConvADB(FALSE), + fConvASP(FALSE), + fConvSCAssem(FALSE), + fConvDisasm(FALSE), + fConvHiRes(FALSE), + fConvDHR(FALSE), + fConvSHR(FALSE), + fConvPrintShop(FALSE), + fConvMacPaint(FALSE), + fConvProDOSFolder(FALSE), + fConvResources(FALSE), + fRelaxGfxTypeCheck(FALSE), + fMaxViewFileSizeKB(0) {} bool fReady; diff --git a/app/UseSelectionDialog.h b/app/UseSelectionDialog.h index f13c9c1..07a744d 100644 --- a/app/UseSelectionDialog.h +++ b/app/UseSelectionDialog.h @@ -17,7 +17,13 @@ class UseSelectionDialog : public CDialog { public: UseSelectionDialog(int selCount, CWnd* pParentWnd = NULL, int rsrcID = IDD_USE_SELECTION) : - CDialog(rsrcID, pParentWnd), fSelectedCount(selCount) + CDialog(rsrcID, pParentWnd), + fSelectedCount(selCount), + fTitleID(-1), + fOkLabelID(-1), + fSelCountID(-1), + fSelCountsID(-1), + fAllID(-1) { // init values; these should be overridden before DoModal fFilesToAction = 0; diff --git a/diskimg/DiskImg.h b/diskimg/DiskImg.h index e57b28d..51c46aa 100644 --- a/diskimg/DiskImg.h +++ b/diskimg/DiskImg.h @@ -25,6 +25,7 @@ #include #include #include +#include #include //#define EXCISE_GPL_CODE @@ -1582,7 +1583,12 @@ private: */ class DISKIMG_API A2FileDescr { public: - A2FileDescr(A2File* pFile) : fpFile(pFile), fProgressUpdateFunc(NULL) {} + A2FileDescr(A2File* pFile) : + fpFile(pFile), + fProgressUpdateFunc(NULL), + fProgressUpdateMax(0), + fProgressUpdateState(NULL) + {} virtual ~A2FileDescr(void) { fpFile = NULL; /*paranoia*/ } virtual DIError Read(void* buf, size_t len, size_t* pActual = NULL) = 0; diff --git a/diskimg/OuterWrapper.cpp b/diskimg/OuterWrapper.cpp index ce6f3e5..b5609a2 100644 --- a/diskimg/OuterWrapper.cpp +++ b/diskimg/OuterWrapper.cpp @@ -1220,7 +1220,7 @@ void OuterZip::LocalFileHeader::SetFileName(const char* name) fFileNameLength = 0; if (name != NULL) { - fFileNameLength = strlen(name); + fFileNameLength = (uint16_t)strlen(name); fFileName = new uint8_t[fFileNameLength+1]; if (fFileName == NULL) { LOGW("Malloc failure in SetFileName %u", fFileNameLength); @@ -1388,7 +1388,7 @@ void OuterZip::CentralDirEntry::SetFileName(const char* name) fFileNameLength = 0; if (name != NULL) { - fFileNameLength = strlen(name); + fFileNameLength = (uint16_t)strlen(name); fFileName = new uint8_t[fFileNameLength+1]; if (fFileName == NULL) { LOGI("Malloc failure in SetFileName %u", fFileNameLength); diff --git a/diskimg/Pascal.cpp b/diskimg/Pascal.cpp index 1ebc080..9af6f9f 100644 --- a/diskimg/Pascal.cpp +++ b/diskimg/Pascal.cpp @@ -535,7 +535,7 @@ DIError DiskFSPascal::Format(DiskImg* pDiskImg, const char* volName) PutShortLE(&blkBuf[0x00], 0); // start block PutShortLE(&blkBuf[0x02], 6); // next block PutShortLE(&blkBuf[0x04], 0); // "file" type - blkBuf[0x06] = strlen(volName); + blkBuf[0x06] = (uint8_t)strlen(volName); memcpy(&blkBuf[0x07], volName, strlen(volName)); PutShortLE(&blkBuf[0x0e], (uint16_t) pDiskImg->GetNumBlocks()); PutShortLE(&blkBuf[0x10], 0); // num files @@ -1255,7 +1255,7 @@ DIError DiskFSPascal::RenameFile(A2File* pGenericFile, const char* newName) goto bail; } - pEntry[0x06] = strlen(normalName); + pEntry[0x06] = (uint8_t)strlen(normalName); memcpy(&pEntry[0x07], normalName, A2FilePascal::kMaxFileName); strcpy(pFile->fFileName, normalName); @@ -1339,7 +1339,7 @@ DIError DiskFSPascal::RenameVolume(const char* newName) if (dierr != kDIErrNone) goto bail; - fDirectory[0x06] = strlen(normalName); + fDirectory[0x06] = (uint8_t)strlen(normalName); memcpy(&fDirectory[0x07], normalName, fDirectory[0x06]); strcpy(fVolumeName, normalName); diff --git a/diskimg/ProDOS.cpp b/diskimg/ProDOS.cpp index 9c03194..4cdb988 100644 --- a/diskimg/ProDOS.cpp +++ b/diskimg/ProDOS.cpp @@ -1571,7 +1571,7 @@ DIError DiskFSProDOS::Format(DiskImg* pDiskImg, const char* volName) PutShortLE(&blkBuf[0x00], 0); PutShortLE(&blkBuf[0x02], kVolHeaderBlock+1); - blkBuf[0x04] = strlen(upperName) | (A2FileProDOS::kStorageVolumeDirHeader << 4); + blkBuf[0x04] = (uint8_t)(strlen(upperName) | (A2FileProDOS::kStorageVolumeDirHeader << 4)); strncpy((char*) &blkBuf[0x05], upperName, A2FileProDOS::kMaxFileName); PutLongLE(&blkBuf[0x16], A2FileProDOS::ConvertProDate(now)); PutShortLE(&blkBuf[0x1a], lcFlags); @@ -2014,7 +2014,7 @@ DIError DiskFSProDOS::CreateFile(const CreateParms* pParms, A2File** ppNewFile) * are lower case. (Some parts of the original may have been stomped * when the name was made unique, so we need to watch for that.) */ - dirEntryPtr[0x00] = (pParms->storageType << 4) | strlen(upperName); + dirEntryPtr[0x00] = (uint8_t)((pParms->storageType << 4) | strlen(upperName)); strncpy((char*) &dirEntryPtr[0x01], upperName, A2FileProDOS::kMaxFileName); if (pParms->fileType >= 0 && pParms->fileType <= 0xff) dirEntryPtr[0x10] = (uint8_t) pParms->fileType; @@ -2270,7 +2270,7 @@ DIError DiskFSProDOS::AllocInitialFileStorage(const CreateParms* pParms, /* fill in directory header fields */ // 0x00: prev, set to zero // 0x02: next, set to zero - blkBuf[0x04] = (A2FileProDOS::kStorageSubdirHeader << 4) | strlen(upperName); + blkBuf[0x04] = (uint8_t)((A2FileProDOS::kStorageSubdirHeader << 4) | strlen(upperName)); strncpy((char*) &blkBuf[0x05], upperName, A2FileProDOS::kMaxFileName); blkBuf[0x14] = 0x76; // 0x75 under old P8, 0x76 under GS/OS PutLongLE(&blkBuf[0x1c], A2FileProDOS::ConvertProDate(pParms->createWhen)); @@ -3511,7 +3511,7 @@ DIError DiskFSProDOS::RenameFile(A2File* pGenericFile, const char* newName) dierr = kDIErrBadDirectory; goto bail; } - ptr[0x00] = (ptr[0x00] & 0xf0) | strlen(upperName); + ptr[0x00] = (uint8_t)((ptr[0x00] & 0xf0) | strlen(upperName)); memcpy(&ptr[0x01], upperName, A2FileProDOS::kMaxFileName); PutShortLE(&ptr[0x1c], lcFlags); // version/min_version if (isAW) @@ -3526,7 +3526,7 @@ DIError DiskFSProDOS::RenameFile(A2File* pGenericFile, const char* newName) dierr = kDIErrBadDirectory; goto bail; } - ptr[0x00] = (ptr[0x00] & 0xf0) | strlen(upperName); + ptr[0x00] = (uint8_t)((ptr[0x00] & 0xf0) | strlen(upperName)); memcpy(&ptr[0x01], upperName, A2FileProDOS::kMaxFileName); PutShortLE(&ptr[0x1c], lcFlags); // version/min_version } @@ -3777,7 +3777,7 @@ DIError DiskFSProDOS::RenameVolume(const char* newName) dierr = kDIErrBadDirectory; goto bail; } - ptr[0x00] = (ptr[0x00] & 0xf0) | strlen(upperName); + ptr[0x00] = (uint8_t)((ptr[0x00] & 0xf0) | strlen(upperName)); memcpy(&ptr[0x01], upperName, A2FileProDOS::kMaxFileName); PutShortLE(&ptr[0x16], lcFlags); // reserved fields diff --git a/diskimg/Win32BlockIO.h b/diskimg/Win32BlockIO.h index 0bb1844..7d5d3de 100644 --- a/diskimg/Win32BlockIO.h +++ b/diskimg/Win32BlockIO.h @@ -119,7 +119,9 @@ private: */ class Win32VolumeAccess { public: - Win32VolumeAccess(void) : fpBlockAccess(NULL) + Win32VolumeAccess(void) : + fTotalBlocks(-1), + fpBlockAccess(NULL) {} virtual ~Win32VolumeAccess(void) { if (fpBlockAccess != NULL) { @@ -305,7 +307,11 @@ private: */ class PhysicalBlockAccess : public BlockAccess { public: - PhysicalBlockAccess(void) : fHandle(NULL), fInt13Unit(-1) {} + PhysicalBlockAccess(void) : + fHandle(NULL), + fInt13Unit(-1), + fFloppyKind(kFloppyUnknown) + {} virtual ~PhysicalBlockAccess(void) {} virtual DIError Open(const WCHAR* deviceName, bool readOnly); diff --git a/reformat/Reformat.h b/reformat/Reformat.h index 0516abc..d3d26e9 100644 --- a/reformat/Reformat.h +++ b/reformat/Reformat.h @@ -200,7 +200,16 @@ public: /* * Construct/destruct our object. */ - ReformatHolder(void) { + ReformatHolder(void) : + fApplies(), + fFileType(0), + fAuxType(0), + fSourceFormat(kSourceFormatGeneric), + fNameExt(NULL), + fSourceBuf(), + fSourceLen(), + fErrorBuf() + { int i; for (int part = 0; part < kPartMAX; part++) { if (part == kPartUnknown) @@ -216,10 +225,6 @@ public: } for (i = 0; i < kOptMAX; i++) fOption[i] = 0; - - fFileType = fAuxType = 0; - fSourceFormat = kSourceFormatGeneric; - fNameExt = NULL; } ~ReformatHolder(void) { LOGI("In ~ReformatHolder"); diff --git a/util/CancelDialog.h b/util/CancelDialog.h index 24791d3..0a3932d 100644 --- a/util/CancelDialog.h +++ b/util/CancelDialog.h @@ -23,7 +23,7 @@ */ class CancelDialog : public ModelessDialog { public: - CancelDialog(void) {} + CancelDialog(void) : fpCancelFlag(NULL) {} virtual ~CancelDialog(void) {} BOOL Create(bool* pCancelFlag, int dialogID, CWnd* pParentWnd = NULL) { diff --git a/util/SelectFilesDialog.h b/util/SelectFilesDialog.h index 2e4876d..157cb23 100644 --- a/util/SelectFilesDialog.h +++ b/util/SelectFilesDialog.h @@ -46,7 +46,8 @@ class SelectFilesDialog : public CFileDialog { public: SelectFilesDialog(const WCHAR* rctmpl, bool showHelp, CWnd* pParentWnd = NULL) : CFileDialog(true, NULL, NULL, OFN_HIDEREADONLY, NULL, pParentWnd, - 0, FALSE /*disable Vista style*/) + 0, FALSE /*disable Vista style*/), + fPrevWndProc(NULL) { // Set flags. We specify ALLOWMULTISELECT but no filename buffer; // we want the multi-select behavior but we don't want to return