From eff69cce86bea794218837d8f28f963e2ae1797b Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Sun, 9 May 2021 18:17:49 -0700 Subject: [PATCH] Fix a few compiler warnings Mostly uninitialized class members. Should not cause a change in behavior. --- app/CiderPress.rc | 2 +- app/DiskArchive.cpp | 4 +- app/DiskEditDialog.h | 34 +++-- app/EOLScanDialog.h | 7 +- app/Main.h | 6 +- app/Tools.cpp | 6 +- diskimg/DiskImg.cpp | 4 + diskimg/DiskImg.h | 12 +- diskimg/DiskImgDetail.h | 292 ++++++++++++++++++++++++++-------------- diskimg/FAT.cpp | 1 + diskimg/GenericFD.h | 17 ++- diskimg/TwoImg.h | 22 ++- reformat/Asm.h | 13 +- util/Util.cpp | 3 +- 14 files changed, 284 insertions(+), 139 deletions(-) diff --git a/app/CiderPress.rc b/app/CiderPress.rc index 4289d2b..ee0e0b8 100644 --- a/app/CiderPress.rc +++ b/app/CiderPress.rc @@ -227,7 +227,7 @@ BEGIN PUSHBUTTON "Enter registration code",IDC_ABOUT_ENTER_REG,157,132,86,14 CONTROL IDB_FSLOGO,IDC_STATIC,"Static",SS_BITMAP,7,6,64,59 LTEXT "CiderPress v%d.%d.%d%ls%ls",IDC_CIDERPRESS_VERS_TEXT,77,7,167,9 - LTEXT "Copyright © 2017 by CiderPress project authors.\rAll Rights Reserved.",IDC_STATIC,77,20,167,19 + LTEXT "Copyright © 2021 by CiderPress project authors.\rAll Rights Reserved.",IDC_STATIC,77,20,167,19 ICON IDR_MAINFRAME,IDC_STATIC,77,45,20,20 ICON IDI_FILE_NUFX,IDC_STATIC,106,45,20,20 ICON IDI_FILE_BINARY2,IDC_STATIC,136,45,20,20 diff --git a/app/DiskArchive.cpp b/app/DiskArchive.cpp index f314ece..601df0d 100644 --- a/app/DiskArchive.cpp +++ b/app/DiskArchive.cpp @@ -1798,8 +1798,8 @@ bail: DIError DiskArchive::AddForksToDisk(DiskFS* pDiskFS, const DiskFS::CreateParms* pParms, - const unsigned char* dataBuf, long dataLen, - const unsigned char* rsrcBuf, long rsrcLen) const + const uint8_t* dataBuf, long dataLen, + const uint8_t* rsrcBuf, long rsrcLen) const { DIError dierr = kDIErrNone; const int kFileTypeBIN = 0x06; diff --git a/app/DiskEditDialog.h b/app/DiskEditDialog.h index 0e00f74..517ee46 100644 --- a/app/DiskEditDialog.h +++ b/app/DiskEditDialog.h @@ -186,11 +186,11 @@ private: class SectorEditDialog : public DiskEditDialog { public: SectorEditDialog(CWnd* pParentWnd = NULL) : - DiskEditDialog(IDD_DISKEDIT, pParentWnd) - { - fTrack = 0; - fSector = 0; - } + DiskEditDialog(IDD_DISKEDIT, pParentWnd), + fTrack(0), + fSector(0), + fSectorData() + { } virtual ~SectorEditDialog() {} virtual int LoadData(void) override; // load the current track/sector @@ -234,11 +234,15 @@ protected: class SectorFileEditDialog : public SectorEditDialog { public: SectorFileEditDialog(SectorEditDialog* pSectEdit, CWnd* pParentWnd = NULL): - SectorEditDialog(pParentWnd) + SectorEditDialog(pParentWnd), + fOpenRsrcFork(false), + fpFile(NULL), + fpOpenFile(NULL), + fSectorIdx(0), + fLength(0) { DiskEditDialog::Setup(pSectEdit->GetDiskFS(), pSectEdit->GetFileName()); - fSectorIdx = 0; } virtual ~SectorFileEditDialog() {} @@ -326,7 +330,12 @@ protected: class BlockFileEditDialog : public BlockEditDialog { public: BlockFileEditDialog(BlockEditDialog* pBlockEdit, CWnd* pParentWnd = NULL) : - BlockEditDialog(pParentWnd) + BlockEditDialog(pParentWnd), + fOpenRsrcFork(false), + fpFile(NULL), + fpOpenFile(NULL), + fBlockIdx(0), + fLength(0) { DiskEditDialog::Setup(pBlockEdit->GetDiskFS(), pBlockEdit->GetFileName()); @@ -379,10 +388,11 @@ private: class NibbleEditDialog : public DiskEditDialog { public: NibbleEditDialog(CWnd* pParentWnd = NULL) : - DiskEditDialog(IDD_DISKEDIT, pParentWnd) - { - fTrack = 0; - } + DiskEditDialog(IDD_DISKEDIT, pParentWnd), + fTrack(0), + fNibbleData(), + fNibbleDataLen(0) + { } virtual ~NibbleEditDialog() {} virtual int LoadData(void) override; // load the current track/sector diff --git a/app/EOLScanDialog.h b/app/EOLScanDialog.h index 8484287..d73c924 100644 --- a/app/EOLScanDialog.h +++ b/app/EOLScanDialog.h @@ -17,7 +17,12 @@ class EOLScanDialog : public CDialog { public: EOLScanDialog(CWnd* pParentWnd = NULL) : - CDialog(IDD_EOLSCAN, pParentWnd) + CDialog(IDD_EOLSCAN, pParentWnd), + fCountChars(0), + fCountCR(0), + fCountLF(0), + fCountCRLF(0), + fCountHighASCII(0) {} virtual ~EOLScanDialog(void) {} diff --git a/app/Main.h b/app/Main.h index ac43139..3dd9e72 100644 --- a/app/Main.h +++ b/app/Main.h @@ -71,8 +71,8 @@ public: void ApplyNow(PrefsSheet*); // get the text of the next file in the selection list - int GetPrevFileText(ReformatHolder* pHolder, CString* pTitle); - int GetNextFileText(ReformatHolder* pHolder, CString* pTitle); + //int GetPrevFileText(ReformatHolder* pHolder, CString* pTitle); + //int GetNextFileText(ReformatHolder* pHolder, CString* pTitle); // update the progress meter void SetProgressBegin(void); @@ -607,7 +607,7 @@ private: */ void HandleView(void); - void DeleteFileOnExit(const WCHAR* name); + //void DeleteFileOnExit(const WCHAR* name); /* * Close and re-open the current archive. diff --git a/app/Tools.cpp b/app/Tools.cpp index 2e6aaef..d62479f 100644 --- a/app/Tools.cpp +++ b/app/Tools.cpp @@ -1787,7 +1787,7 @@ long MainWindow::SSTGetBufOffset(int track) return offset; } -long MainWindow::SSTCountBadBytes(const unsigned char* sctBuf, int count) +long MainWindow::SSTCountBadBytes(const uint8_t* sctBuf, int count) { long badCount = 0; unsigned char uch; @@ -1802,7 +1802,7 @@ long MainWindow::SSTCountBadBytes(const unsigned char* sctBuf, int count) return badCount; } -void MainWindow::SSTProcessTrackData(unsigned char* trackBuf) +void MainWindow::SSTProcessTrackData(uint8_t* trackBuf) { unsigned char* trackPtr; int track; @@ -1812,7 +1812,7 @@ void MainWindow::SSTProcessTrackData(unsigned char* trackBuf) { bool inRun; int start, longestStart; - int count7f, longest = -1; + int count7f = 0, longest = -1; int i; inRun = false; diff --git a/diskimg/DiskImg.cpp b/diskimg/DiskImg.cpp index 2404a8d..1654ea7 100644 --- a/diskimg/DiskImg.cpp +++ b/diskimg/DiskImg.cpp @@ -211,6 +211,10 @@ DiskImg::DiskImg(void) fNumBlocks = -1; fpScanProgressCallback = NULL; + fScanProgressCookie = NULL; + fScanCount = 0; + fScanMsg[0] = '\0'; + fScanLastMsgWhen = 0; /* * Create a working copy of the nibble descr table. We want to leave diff --git a/diskimg/DiskImg.h b/diskimg/DiskImg.h index 51c46aa..bcd614e 100644 --- a/diskimg/DiskImg.h +++ b/diskimg/DiskImg.h @@ -1472,13 +1472,15 @@ public: * The filename returned is defined to be null-terminated Mac OS Roman. * For most filesystems this is automatic, as filenames are restricted * to ASCII, but for DOS 3.3 it requires stripping high bits. It also - * means that embedded nulls in HFS filenames (which are discouraged but - * allowed) will be lost. + * means that embedded nulls will be lost. (Some HFS references indicate + * that '\0' is allowed, but I think people assume that because the API + * uses a string with an explicit length. Looking at "Inside Mac: Files" + * chapter 2, page 2-71, HFS filenames are stored in a fixed 31-byte + * field that is padded with zeroes, so embedded nulls are impossible.) * - * The original unmodified filename is availale through GetRawFileName, + * The original unmodified filename is available through GetRawFileName, * which can be optionally passed a size_t pointer to get the size - * of the raw file name, which is helpful for getting a HFS filename with - * embedded nulls. + * of the raw file name, in case it has embedded nulls. * * We do guarantee that the contents of subdirectories are grouped * together. This makes it much easier to construct a hierarchy out of diff --git a/diskimg/DiskImgDetail.h b/diskimg/DiskImgDetail.h index ca33017..bf9ae62 100644 --- a/diskimg/DiskImgDetail.h +++ b/diskimg/DiskImgDetail.h @@ -630,7 +630,7 @@ private: class WrapperFDI : public ImageWrapper { public: - WrapperFDI(void) {} + WrapperFDI(void) : fHeaderBuf(), fImageTracks(0), fStorageName(NULL) {} virtual ~WrapperFDI(void) {} static DIError Test(GenericFD* pGFD, di_off_t wrappedLength); @@ -1213,10 +1213,21 @@ class A2FileDOS; */ class DISKIMG_API DiskFSDOS33 : public DiskFS { public: - DiskFSDOS33(void) : DiskFS() { - fVTOCLoaded = false; - fDiskIsGood = false; - } + DiskFSDOS33(void) : + DiskFS(), + fFirstCatTrack(0), + fFirstCatSector(0), + fVTOCVolumeNumber(0), + fVTOCNumTracks(0), + fVTOCNumSectors(0), + fDiskVolumeNum(0), + fDiskVolumeName(), + fDiskVolumeID(), + fVTOC(), + fVTOCLoaded(false), + fCatalogSectors(), + fDiskIsGood(false) + {} virtual ~DiskFSDOS33(void) {} static DIError TestFS(DiskImg* pImg, DiskImg::SectorOrder* pOrder, @@ -1259,7 +1270,7 @@ public: // utility function static void LowerASCII(uint8_t* buf, long len); - static void ReplaceFssep(char* str, char replacement); + //static void ReplaceFssep(char* str, char replacement); enum { kMinTracks = 17, // need to put the catalog track here @@ -1360,12 +1371,17 @@ private: */ class DISKIMG_API A2FDDOS : public A2FileDescr { public: - A2FDDOS(A2File* pFile) : A2FileDescr(pFile) { - fTSList = NULL; - fIndexList = NULL; - fOffset = 0; - fModified = false; - } + A2FDDOS(A2File* pFile) : + A2FileDescr(pFile), + fTSList(NULL), + fTSCount(0), + fIndexList(NULL), + fIndexCount(0), + fOffset(0), + fOpenEOF(0), + fOpenSectorsUsed(0), + fModified(false) + {} virtual ~A2FDDOS(void) { delete[] fTSList; delete[] fIndexList; @@ -1538,8 +1554,19 @@ class A2FileProDOS; */ class DISKIMG_API DiskFSProDOS : public DiskFS { public: - DiskFSProDOS(void) : fBitMapPointer(0), fTotalBlocks(0), fBlockUseMap(NULL) - {} + DiskFSProDOS(void) : + fVolumeName(), + fVolumeID(), + fAccess(0), + fCreateWhen(0), + fModWhen(0), + fBitMapPointer(0), + fTotalBlocks(0), + fVolDirFileCount(0), + fBlockUseMap(NULL), + fDiskIsGood(false), + fEarlyDamage(false) + {} virtual ~DiskFSProDOS(void) { if (fBlockUseMap != NULL) { assert(false); // unexpected @@ -1700,8 +1727,16 @@ private: */ class DISKIMG_API A2FDProDOS : public A2FileDescr { public: - A2FDProDOS(A2File* pFile) : A2FileDescr(pFile), fModified(false), - fBlockList(NULL), fOffset(0) + A2FDProDOS(A2File* pFile) : + A2FileDescr(pFile), + fModified(false), + fBlockCount(0), + fBlockList(NULL), + fOpenEOF(0), + fOpenBlocksUsed(0), + fOpenStorageType(0), + fOpenRsrcFork(false), + fOffset(0) {} virtual ~A2FDProDOS(void) { delete[] fBlockList; @@ -1745,14 +1780,16 @@ private: */ class DISKIMG_API A2FileProDOS : public A2File { public: - A2FileProDOS(DiskFS* pDiskFS) : A2File(pDiskFS) { - fPathName = NULL; - fSparseDataEof = fSparseRsrcEof = -1; - fpOpenFile = NULL; - fParentDirBlock = 0; - fParentDirIdx = -1; - fpParent = NULL; - } + A2FileProDOS(DiskFS* pDiskFS) : + A2File(pDiskFS), + fParentDirBlock(0), + fParentDirIdx(0), + fSparseDataEof(0), + fSparseRsrcEof(0), + fPathName(NULL), + fpOpenFile(NULL), + fpParent(NULL) + {} virtual ~A2FileProDOS(void) { delete fpOpenFile; delete[] fPathName; @@ -1952,7 +1989,21 @@ class A2FilePascal; class DISKIMG_API DiskFSPascal : public DiskFS { public: - DiskFSPascal(void) : fDirectory(NULL) {} + DiskFSPascal(void) : + fStartBlock(0), + fNextBlock(0), + fVolumeName(), + fVolumeID(), + fTotalBlocks(0), + fNumFiles(0), + fAccessWhen(0), + fDateSetWhen(0), + fStuff1(0), + fStuff2(0), + fDiskIsGood(false), + fEarlyDamage(false), + fDirectory(NULL) + {} virtual ~DiskFSPascal(void) { if (fDirectory != NULL) { assert(false); // unexpected @@ -2054,9 +2105,13 @@ private: */ class DISKIMG_API A2FDPascal : public A2FileDescr { public: - A2FDPascal(A2File* pFile) : A2FileDescr(pFile) { - fOffset = 0; - } + A2FDPascal(A2File* pFile) : + A2FileDescr(pFile), + fOffset(0), + fOpenEOF(0), + fOpenBlocksUsed(0), + fModified(0) + {} virtual ~A2FDPascal(void) { /* nothing to clean up */ } @@ -2088,9 +2143,17 @@ private: */ class DISKIMG_API A2FilePascal : public A2File { public: - A2FilePascal(DiskFS* pDiskFS) : A2File(pDiskFS) { - fpOpenFile = NULL; - } + A2FilePascal(DiskFS* pDiskFS) : + A2File(pDiskFS), + fStartBlock(0), + fNextBlock(0), + fFileType(A2FilePascal::FileType::kTypeUntyped), + fFileName(), + fBytesRemaining(0), + fModWhen(0), + fLength(0), + fpOpenFile(NULL) + {} virtual ~A2FilePascal(void) { /* this comes back and calls CloseDescr */ if (fpOpenFile != NULL) @@ -2188,7 +2251,7 @@ private: class A2FileCPM; class DISKIMG_API DiskFSCPM : public DiskFS { public: - DiskFSCPM(void) : fDiskIsGood(false) {} + DiskFSCPM(void) : fDirEntry(), fDiskIsGood(false) {} virtual ~DiskFSCPM(void) {} static DIError TestFS(DiskImg* pImg, DiskImg::SectorOrder* pOrder, @@ -2272,10 +2335,12 @@ private: */ class DISKIMG_API A2FDCPM : public A2FileDescr { public: - A2FDCPM(A2File* pFile) : A2FileDescr(pFile) { - //fOpen = false; - fBlockList = NULL; - } + A2FDCPM(A2File* pFile) : + A2FileDescr(pFile), + fOffset(0), + fBlockCount(0), + fBlockList(NULL) + {} virtual ~A2FDCPM(void) { delete fBlockList; fBlockList = NULL; @@ -2311,7 +2376,13 @@ public: typedef DiskFSCPM::DirEntry DirEntry; A2FileCPM(DiskFS* pDiskFS, DirEntry* pDirEntry) : - A2File(pDiskFS), fpDirEntry(pDirEntry) + A2File(pDiskFS), + fFileName(), + fReadOnly(false), + fLength(0), + fDirIdx(0), + fpDirEntry(pDirEntry), + fpOpenFile(NULL) { fDirIdx = -1; fpOpenFile = NULL; @@ -2392,7 +2463,7 @@ private: class A2FileRDOS; class DISKIMG_API DiskFSRDOS : public DiskFS { public: - DiskFSRDOS(void) {} + DiskFSRDOS(void) : fVolumeName(), fOurSectPerTrack(0) {} virtual ~DiskFSRDOS(void) {} static DIError TestFS(DiskImg* pImg, DiskImg::SectorOrder* pOrder, @@ -2471,10 +2542,17 @@ private: */ class DISKIMG_API A2FileRDOS : public A2File { public: - A2FileRDOS(DiskFS* pDiskFS) : A2File(pDiskFS) { - //fOpen = false; - fpOpenFile = NULL; - } + A2FileRDOS(DiskFS* pDiskFS) : + A2File(pDiskFS), + fFileName(), + fRawFileName(), + fFileType(A2FileRDOS::FileType::kTypeUnknown), + fNumSectors(0), + fLoadAddr(0), + fLength(0), + fStartSector(0), + fpOpenFile(NULL) + {} virtual ~A2FileRDOS(void) { delete fpOpenFile; } @@ -2547,9 +2625,19 @@ private: class A2FileHFS; class DISKIMG_API DiskFSHFS : public DiskFS { public: - DiskFSHFS(void) { - fLocalTimeOffset = -1; - fDiskIsGood = true; + DiskFSHFS(void) : + fVolumeName(), + fVolumeID(), + fTotalBlocks(0), + fAllocationBlockSize(0), + fNumAllocationBlocks(0), + fCreatedDateTime(0), + fModifiedDateTime(0), + fNumFiles(0), + fNumDirectories(0), + fLocalTimeOffset(-1), + fDiskIsGood(true) + { #ifndef EXCISE_GPL_CODE fHfsVol = NULL; #endif @@ -2722,12 +2810,25 @@ private: */ class DISKIMG_API A2FileHFS : public A2File { public: - A2FileHFS(DiskFS* pDiskFS) : A2File(pDiskFS) { - fPathName = NULL; - fpOpenFile = NULL; + A2FileHFS(DiskFS* pDiskFS) : + A2File(pDiskFS), + fIsDir(false), + fIsVolumeDir(false), + fType(0), + fCreator(0), + fFileName(), + fPathName(NULL), + fDataLength(0), + fRsrcLength(0), + fCreateWhen(0), + fModWhen(0), + fAccess(0), + fpOpenFile(NULL) + { #ifdef EXCISE_GPL_CODE fFakeFileBuf = NULL; #else + fpParent = NULL; //fOrigPathName = NULL; #endif } @@ -2833,10 +2934,19 @@ class A2FileGutenberg; */ class DISKIMG_API DiskFSGutenberg : public DiskFS { public: - DiskFSGutenberg(void) : DiskFS() { - fVTOCLoaded = false; - fDiskIsGood = false; - } + DiskFSGutenberg(void) : DiskFS(), + fFirstCatTrack(0), + fFirstCatSector(0), + fVTOCVolumeNumber(0), + fVTOCNumTracks(0), + fVTOCNumSectors(0), + fDiskVolumeName(), + fDiskVolumeID(), + fVTOC(), + fVTOCLoaded(false), + fCatalogSectors(), + fDiskIsGood(false) + {} virtual ~DiskFSGutenberg(void) {} static DIError TestFS(DiskImg* pImg, DiskImg::SectorOrder* pOrder, @@ -2857,12 +2967,12 @@ public: virtual DIError GetFreeSpaceCount(long* pTotalUnits, long* pFreeUnits, int* pUnitSize) const override; - static bool IsValidFileName(const char* name); - static bool IsValidVolumeName(const char* name); + //static bool IsValidFileName(const char* name); + //static bool IsValidVolumeName(const char* name); // utility function static void LowerASCII(uint8_t* buf, long len); - static void ReplaceFssep(char* str, char replacement); + //static void ReplaceFssep(char* str, char replacement); enum { kMinTracks = 17, // need to put the catalog track here @@ -2880,43 +2990,13 @@ public: private: DIError Initialize(InitMode initMode); - DIError ReadVTOC(void); - void UpdateVolumeNum(void); - void DumpVTOC(void); - void SetSectorUsage(long track, long sector, - VolumeUsage::ChunkPurpose purpose); - void FixVolumeUsageMap(void); DIError ReadCatalog(void); DIError ProcessCatalogSector(int catTrack, int catSect, const uint8_t* sctBuf); DIError GetFileLengths(void); - DIError ComputeLength(A2FileGutenberg* pFile, const TrackSector* tsList, - int tsCount); - DIError TrimLastSectorUp(A2FileGutenberg* pFile, TrackSector lastTS); - void MarkFileUsage(A2FileGutenberg* pFile, TrackSector* tsList, int tsCount, - TrackSector* indexList, int indexCount); - DIError MakeFileNameUnique(char* fileName); - DIError GetFreeCatalogEntry(TrackSector* pCatSect, int* pCatEntry, - uint8_t* sctBuf, A2FileGutenberg** ppPrevEntry); - void CreateDirEntry(uint8_t* sctBuf, int catEntry, - const char* fileName, TrackSector* pTSSect, uint8_t fileType, - int access); - void FreeTrackSectors(TrackSector* pList, int count); bool CheckDiskIsGood(void); - DIError WriteDOSTracks(int sectPerTrack); - - DIError ScanVolBitmap(void); - DIError LoadVolBitmap(void); - DIError SaveVolBitmap(void); - void FreeVolBitmap(void); - DIError AllocSector(TrackSector* pTS); - DIError CreateEmptyBlockMap(bool withDOS); - bool GetSectorUseEntry(long track, int sector) const; - void SetSectorUseEntry(long track, int sector, bool inUse); - inline uint32_t GetVTOCEntry(const uint8_t* pVTOC, long track) const; - // Largest interesting volume is 400K (50 tracks, 32 sectors), but // we may be looking at it in 16-sector mode, so max tracks is 100. enum { @@ -2936,7 +3016,7 @@ private: /* private data */ char fDiskVolumeName[10]; // char fDiskVolumeID[11+12+1]; // sizeof "Gutenberg: " + 12 + null - uint8_t fVTOC[kSectorSize]; + uint8_t fVTOC[kSectorSize]; bool fVTOCLoaded; /* @@ -2955,12 +3035,15 @@ private: */ class DISKIMG_API A2FDGutenberg : public A2FileDescr { public: - A2FDGutenberg(A2File* pFile) : A2FileDescr(pFile) { - fOffset = 0; - fModified = false; - } - virtual ~A2FDGutenberg(void) { - } + A2FDGutenberg(A2File* pFile) : + A2FileDescr(pFile), + fTSCount(0), + fOffset(0), + fOpenEOF(0), + fOpenSectorsUsed(0), + fModified(false) + {} + virtual ~A2FDGutenberg(void) {} friend class A2FileGutenberg; @@ -3060,16 +3143,11 @@ public: void FixFilename(void); - static FileType ConvertFileType(long prodosType, di_off_t fileLen); - static bool IsValidType(long prodosType); static void MakeDOSName(char* buf, const char* name); static void TrimTrailingSpaces(char* filename); private: - DIError ExtractTSPairs(const uint8_t* sctBuf, TrackSector* tsList, - int* pLastNonZero); - - A2FDGutenberg* fpOpenFile; + A2FDGutenberg* fpOpenFile; }; @@ -3088,7 +3166,11 @@ private: class A2FileFAT; class DISKIMG_API DiskFSFAT : public DiskFS { public: - DiskFSFAT(void) {} + DiskFSFAT(void) : + fVolumeName(), + fVolumeID(), + fTotalBlocks(0) + {} virtual ~DiskFSFAT(void) {} static DIError TestFS(DiskImg* pImg, DiskImg::SectorOrder* pOrder, @@ -3173,11 +3255,13 @@ private: */ class DISKIMG_API A2FileFAT : public A2File { public: - A2FileFAT(DiskFS* pDiskFS) : A2File(pDiskFS) { - fFakeFileBuf = NULL; - //fFakeFileLen = -1; - fpOpenFile = NULL; - } + A2FileFAT(DiskFS* pDiskFS) : + A2File(pDiskFS), + fFileName(), + fLength(0), + fFakeFileBuf(NULL), + fpOpenFile(NULL) + {} virtual ~A2FileFAT(void) { delete fpOpenFile; delete[] fFakeFileBuf; diff --git a/diskimg/FAT.cpp b/diskimg/FAT.cpp index 7b7e27c..7fd9cf1 100644 --- a/diskimg/FAT.cpp +++ b/diskimg/FAT.cpp @@ -337,6 +337,7 @@ void DiskFSFAT::CreateFakeFile(void) fVolumeName, capacity, (double) capacity / 2048.0); + buf[sizeof(buf) - 1] = '\0'; pFile = new A2FileFAT(this); pFile->SetFakeFile(buf, strlen(buf)); diff --git a/diskimg/GenericFD.h b/diskimg/GenericFD.h index c52d4cc..a5c4f6c 100644 --- a/diskimg/GenericFD.h +++ b/diskimg/GenericFD.h @@ -175,8 +175,12 @@ private: #ifdef _WIN32 class GFDWinVolume : public GenericFD { public: - GFDWinVolume(void) : fPathName(NULL), fCurrentOffset(0), fVolumeEOF(-1) - {} + GFDWinVolume(void) : + fPathName(NULL), + fCurrentOffset(0), + fVolumeEOF(-1), + fBlockSize(0) + {} virtual ~GFDWinVolume(void) { delete[] fPathName; } virtual DIError Open(const char* deviceName, bool readOnly); @@ -203,7 +207,14 @@ private: class GFDBuffer : public GenericFD { public: - GFDBuffer(void) : fBuffer(NULL) {} + GFDBuffer(void) : + fBuffer(NULL), + fLength(0), + fAllocLength(0), + fDoDelete(false), + fDoExpand(false), + fCurrentOffset(0) + {} virtual ~GFDBuffer(void) { Close(); } // If "doDelete" is set, the buffer will be freed with delete[] when diff --git a/diskimg/TwoImg.h b/diskimg/TwoImg.h index 0956299..c554ddf 100644 --- a/diskimg/TwoImg.h +++ b/diskimg/TwoImg.h @@ -30,7 +30,27 @@ namespace DiskImgLib { */ class DISKIMG_API TwoImgHeader { public: - TwoImgHeader(void) : fDOSVolumeNum(-1), fComment(NULL), fCreatorChunk(NULL) + TwoImgHeader(void) : + fMagic(0), + fCreator(0), + fHeaderLen(0), + fVersion(0), + fImageFormat(0), + fFlags(0), + fNumBlocks(0), + fDataOffset(0), + fDataLen(0), + fCmtOffset(0), + fCmtLen(0), + fCreatorOffset(0), + fCreatorLen(0), + fSpare(), + + fDOSVolumeNum(-1), + fMagicStr(), + fCreatorStr(), + fComment(NULL), + fCreatorChunk(NULL) {} virtual ~TwoImgHeader(void) { delete[] fComment; diff --git a/reformat/Asm.h b/reformat/Asm.h index dc5bb21..588569d 100644 --- a/reformat/Asm.h +++ b/reformat/Asm.h @@ -20,7 +20,7 @@ */ class ReformatAsm : public ReformatText { public: - ReformatAsm(void) {} + ReformatAsm(void) : fOutBuf(), fOutBufIndex(0) {} virtual ~ReformatAsm(void) {} void OutputStart(void) { @@ -129,7 +129,7 @@ private: */ class ReformatLISA3 : public ReformatAsm { public: - ReformatLISA3(void) : fSymTab(NULL) {} + ReformatLISA3(void) : fSymTab(NULL), fSymCount(0) {} virtual ~ReformatLISA3(void) {} virtual void Examine(ReformatHolder* pHolder) override; @@ -197,7 +197,14 @@ private: */ class ReformatLISA4 : public ReformatAsm { public: - ReformatLISA4(void) : fSymTab(NULL) {} + ReformatLISA4(void) : + fSymTab(NULL), + fSymCount(0), + fOpTab(0), + fAdTab(0), + fComTab(0), + fCpuType(0) + {} virtual ~ReformatLISA4(void) { delete[] fSymTab; } virtual void Examine(ReformatHolder* pHolder) override; diff --git a/util/Util.cpp b/util/Util.cpp index b1f74dc..3b01a6a 100644 --- a/util/Util.cpp +++ b/util/Util.cpp @@ -362,7 +362,7 @@ void CreateSimpleFont(CFont* pFont, CWnd* pWnd, const WCHAR* typeFace, void GetWin32ErrorString(DWORD err, CString* pStr) { DWORD count; - LPVOID lpMsgBuf; + LPVOID lpMsgBuf = NULL; count = FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | @@ -486,6 +486,7 @@ void LogHexDump(const void* vbuf, long len) cp = outBuf + strlen(outBuf); } + ASSERT(cp != NULL); sprintf(cp, "%02x ", *buf++); cp += 3; }