Fix static analysis warnings

Fix warnings for the following:
-include directive not at top of file
-ambiguous indentation for scope of if statement
-not passing expensive object by const reference
-initializing in constructor when using class initialization or initialization
list possible
-member function that doesn't mutate its object not declared const
This commit is contained in:
Allofich 2023-03-30 01:06:54 +09:00
parent 99f92c5340
commit 496dfa6267
8 changed files with 107 additions and 114 deletions

View File

@ -779,10 +779,10 @@ struct DOS_Block {
DOS_Version version = {};
uint16_t firstMCB = 0;
uint16_t errorcode = 0;
uint16_t psp();//{return DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).GetPSP();};
void psp(uint16_t _seg);//{ DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).SetPSP(_seg);};
RealPt dta();//{return DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).GetDTA();};
void dta(RealPt _dta);//{DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).SetDTA(_dta);};
uint16_t psp() const;//{return DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).GetPSP();};
void psp(uint16_t _seg) const;//{ DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).SetPSP(_seg);};
RealPt dta() const;//{return DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).GetDTA();};
void dta(RealPt _dta) const;//{DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).SetDTA(_dta);};
uint8_t return_code = 0, return_mode = 0;
uint8_t current_drive = 0;

View File

@ -192,7 +192,7 @@ public:
uint32_t GetSeekPos(void);
FILE * fhandle;
private:
bool read_only_medium;
bool read_only_medium = false;
enum { NONE,READ,WRITE } last_action;
};

View File

@ -257,7 +257,7 @@ DOS_InfoBlock dos_infoblock;
extern int bootdrive;
extern bool force_sfn, dos_kernel_disabled;
uint16_t DOS_Block::psp() {
uint16_t DOS_Block::psp() const {
if (dos_kernel_disabled) {
LOG_MSG("BUG: DOS kernel is disabled (booting a guest OS), and yet somebody is still asking for DOS's current PSP segment\n");
return 0x0000;
@ -266,7 +266,7 @@ uint16_t DOS_Block::psp() {
return DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).GetPSP();
}
void DOS_Block::psp(uint16_t _seg) {
void DOS_Block::psp(uint16_t _seg) const {
if (dos_kernel_disabled) {
LOG_MSG("BUG: DOS kernel is disabled (booting a guest OS), and yet somebody is still attempting to change DOS's current PSP segment\n");
return;
@ -275,7 +275,7 @@ void DOS_Block::psp(uint16_t _seg) {
DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).SetPSP(_seg);
}
RealPt DOS_Block::dta() {
RealPt DOS_Block::dta() const {
if (dos_kernel_disabled) {
LOG_MSG("BUG: DOS kernel is disabled (booting a guest OS), and yet somebody is still asking for DOS's DTA (disk transfer address)\n");
return 0;
@ -284,7 +284,7 @@ RealPt DOS_Block::dta() {
return DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).GetDTA();
}
void DOS_Block::dta(RealPt _dta) {
void DOS_Block::dta(RealPt _dta) const {
if (dos_kernel_disabled) {
LOG_MSG("BUG: DOS kernel is disabled (booting a guest OS), and yet somebody is still attempting to change DOS's DTA (disk transfer address)\n");
return;

View File

@ -60,6 +60,7 @@
#include "mouse.h"
#include "../ints/int10.h"
#include "../output/output_opengl.h"
#include "paging.h"
#if !defined(HX_DOS)
#include "../libs/tinyfiledialogs/tinyfiledialogs.c"
#endif
@ -73,7 +74,6 @@ host_cnv_char_t *CodePageGuestToHost(const char *s);
#if !defined(S_ISREG)
# define S_ISREG(x) ((x & S_IFREG) == S_IFREG)
#endif
#include "../dos/cdrom.h"
#include <ShlObj.h>
#else
#include <libgen.h>
@ -110,7 +110,7 @@ extern int toSetCodePage(DOS_Shell *shell, int newCP, int opt);
void MSG_Init(), JFONT_Init(), InitFontHandle(), ShutFontHandle(), DOSBox_SetSysMenu(), Load_Language(std::string name);
void DOS_EnableDriveMenu(char drv), GFX_SetTitle(int32_t cycles, int frameskip, Bits timing, bool paused), UpdateSDLDrawTexture();
void runBoot(const char *str), runMount(const char *str), runImgmount(const char *str), runRescan(const char *str), show_prompt(), ttf_reset(void);
void getdrivezpath(std::string &path, std::string dirname), drivezRegister(std::string path, std::string dir, bool usecp), UpdateDefaultPrinterFont(void);
void getdrivezpath(std::string &path, std::string const& dirname), drivezRegister(std::string const& path, std::string const& dir, bool usecp), UpdateDefaultPrinterFont(void);
std::string GetDOSBoxXPath(bool withexe=false);
FILE *testLoadLangFile(const char *fname);
@ -480,8 +480,8 @@ void MenuMountDrive(char drive, const char drive2[DOS_PATHLENGTH]) {
Drives[drive-'A']=newdrive;
DOS_EnableDriveMenu(drive);
mem_writeb(Real2Phys(dos.tables.mediaid)+(drive-'A')*2,mediaid);
if(type==DRIVE_CDROM) LOG_MSG("GUI: Drive %c is mounted as CD-ROM %c:\\",drive,drive);
else LOG_MSG("GUI: Drive %c is mounted as local directory %c:\\",drive,drive);
if(type == DRIVE_CDROM) LOG_MSG("GUI: Drive %c is mounted as CD-ROM %c:\\", drive, drive);
else LOG_MSG("GUI: Drive %c is mounted as local directory %c:\\", drive, drive);
if(drive == drive2[0] && strlen(drive2) == 3) {
// automatic mount
} else {
@ -691,10 +691,10 @@ void MenuBrowseImageFile(char drive, bool arc, bool boot, bool multiple) {
strcat(mountstring,temp_str);
if (!multiple) strcat(mountstring,"\"");
strcat(mountstring,files.size()?files.c_str():fname.c_str());
if (!multiple) strcat(mountstring,"\"");
if (mountiro[drive-'A']) strcat(mountstring," -ro");
if (boot) strcat(mountstring," -u");
if (arc) {
if(!multiple) strcat(mountstring, "\"");
if(mountiro[drive - 'A']) strcat(mountstring, " -ro");
if(boot) strcat(mountstring, " -u");
if(arc) {
strcat(mountstring," -q");
runMount(mountstring);
} else {
@ -1157,7 +1157,7 @@ public:
uint16_t numc=type=="cdrom"?1:32;
uint32_t total_size_cyl=32765;
uint32_t tmp=(uint32_t)freesize*1024*1024/(type=="cdrom"?2048*1:512*32);
if (tmp>65534) numc=type=="cdrom"?(tmp+65535)/65536:64;
if(tmp > 65534) numc = type == "cdrom" ? (tmp + 65535) / 65536 : 64;
uint32_t free_size_cyl=(uint32_t)freesize*1024*1024/(numc*(type=="cdrom"?2048:512));
if (free_size_cyl>65534) free_size_cyl=65534;
if (total_size_cyl<free_size_cyl) total_size_cyl=free_size_cyl+10;
@ -1207,9 +1207,9 @@ public:
if (cmd->FindExist("-u",true)) {
bool curdrv = toupper(i_drive)-'A' == DOS_GetDefaultDrive();
const char *msg=UnmountHelper(i_drive);
if (!quiet) WriteOut(msg, toupper(i_drive));
if (!cmd->FindCommand(2,temp_line)||!temp_line.size()) return;
if (curdrv && toupper(i_drive)-'A' != DOS_GetDefaultDrive()) removed = true;
if(!quiet) WriteOut(msg, toupper(i_drive));
if(!cmd->FindCommand(2, temp_line) || !temp_line.size()) return;
if(curdrv && toupper(i_drive) - 'A' != DOS_GetDefaultDrive()) removed = true;
}
drive = static_cast<char>(i_drive);
if (type == "overlay") {
@ -1301,7 +1301,7 @@ public:
/* Removing trailing backslash if not root dir so stat will succeed */
if(temp_line.size() > 3 && temp_line[temp_line.size()-1]=='\\') temp_line.erase(temp_line.size()-1,1);
if(temp_line.size() == 2 && toupper(temp_line[0])>='A' && toupper(temp_line[0])<='Z' && temp_line[1]==':') temp_line.append("\\");
if(temp_line.size() > 4 && temp_line[0]=='\\' && temp_line[1]=='\\' && temp_line[2]!='\\' && std::count(temp_line.begin()+3, temp_line.end(), '\\')==1) temp_line.append("\\");
if(temp_line.size() > 4 && temp_line[0] == '\\' && temp_line[1] == '\\' && temp_line[2] != '\\' && std::count(temp_line.begin() + 3, temp_line.end(), '\\') == 1) temp_line.append("\\");
notrycp = true;
const host_cnv_char_t* host_name = CodePageGuestToHost(temp_line.c_str());
notrycp = false;
@ -1446,17 +1446,17 @@ public:
else
newdrive = new cdromDrive(drive,temp_line.c_str(),sizes[0],bit8size,sizes[2],sizes[3],mediaid,error,options);
// Check Mscdex, if it worked out...
if (!quiet)
switch (error) {
case 0 : WriteOut(MSG_Get("MSCDEX_SUCCESS")); break;
case 1 : WriteOut(MSG_Get("MSCDEX_ERROR_MULTIPLE_CDROMS")); break;
case 2 : WriteOut(MSG_Get("MSCDEX_ERROR_NOT_SUPPORTED")); break;
case 3 : WriteOut(MSG_Get("MSCDEX_ERROR_PATH")); break;
case 4 : WriteOut(MSG_Get("MSCDEX_TOO_MANY_DRIVES")); break;
case 5 : WriteOut(MSG_Get("MSCDEX_LIMITED_SUPPORT")); break;
case 10 : WriteOut(MSG_Get("PROGRAM_MOUNT_PHYSFS_ERROR"));WriteOut(MSG_Get("PROGRAM_MOUNT_IMGMOUNT"));break;
default : WriteOut(MSG_Get("MSCDEX_UNKNOWN_ERROR")); break;
}
if(!quiet)
switch(error) {
case 0: WriteOut(MSG_Get("MSCDEX_SUCCESS")); break;
case 1: WriteOut(MSG_Get("MSCDEX_ERROR_MULTIPLE_CDROMS")); break;
case 2: WriteOut(MSG_Get("MSCDEX_ERROR_NOT_SUPPORTED")); break;
case 3: WriteOut(MSG_Get("MSCDEX_ERROR_PATH")); break;
case 4: WriteOut(MSG_Get("MSCDEX_TOO_MANY_DRIVES")); break;
case 5: WriteOut(MSG_Get("MSCDEX_LIMITED_SUPPORT")); break;
case 10: WriteOut(MSG_Get("PROGRAM_MOUNT_PHYSFS_ERROR")); WriteOut(MSG_Get("PROGRAM_MOUNT_IMGMOUNT")); break;
default: WriteOut(MSG_Get("MSCDEX_UNKNOWN_ERROR")); break;
}
if (error && error!=5) {
delete newdrive;
return;
@ -1492,8 +1492,8 @@ public:
}
localDrive* ldp = dynamic_cast<localDrive*>(Drives[drive-'A']);
cdromDrive* cdp = dynamic_cast<cdromDrive*>(Drives[drive-'A']);
if (!ldp || cdp || pcdp) {
if (!quiet) WriteOut(MSG_Get("PROGRAM_MOUNT_OVERLAY_INCOMPAT_BASE"));
if(!ldp || cdp || pcdp) {
if(!quiet) WriteOut(MSG_Get("PROGRAM_MOUNT_OVERLAY_INCOMPAT_BASE"));
return;
}
std::string base = ldp->getBasedir();
@ -1631,9 +1631,6 @@ unsigned char PC98_ITF_ROM[0x8000];
bool PC98_ITF_ROM_init = false;
unsigned char PC98_BANK_Select = 0x12;
#include "mem.h"
#include "paging.h"
class PC98ITFPageHandler : public PageHandler {
public:
PC98ITFPageHandler() : PageHandler(PFLAG_READABLE|PFLAG_HASROM) {}
@ -2082,8 +2079,8 @@ public:
}
}
if (!bootbyDrive)
while(i<cmd->GetCount()) {
if(!bootbyDrive)
while(i < cmd->GetCount()) {
if(cmd->FindCommand((unsigned int)(i+1), temp_line)) {
if ((temp_line == "/?") || (temp_line == "-?")) {
printError();
@ -3056,7 +3053,7 @@ const uint8_t freedos_mbr[] = {
class IMGMAKE : public Program {
public:
#ifdef WIN32
bool OpenDisk(HANDLE* f, OVERLAPPED* o, uint8_t* name) {
bool OpenDisk(HANDLE* f, OVERLAPPED* o, uint8_t* name) const {
o->hEvent = INVALID_HANDLE_VALUE;
*f = CreateFile( (LPCSTR)name, GENERIC_READ | GENERIC_WRITE,
0, // exclusive access
@ -3081,12 +3078,12 @@ public:
return true;
}
void CloseDisk(HANDLE f, OVERLAPPED* o) {
void CloseDisk(HANDLE f, OVERLAPPED* o) const {
if(f != INVALID_HANDLE_VALUE) CloseHandle(f);
if(o->hEvent != INVALID_HANDLE_VALUE) CloseHandle(o->hEvent);
}
bool StartReadDisk(HANDLE f, OVERLAPPED* o, uint8_t* buffer, Bitu offset, Bitu size) {
bool StartReadDisk(HANDLE f, OVERLAPPED* o, uint8_t* buffer, Bitu offset, Bitu size) const {
o->Offset = (DWORD)offset;
if (!ReadFile(f, buffer, (DWORD)size, NULL, o) &&
(GetLastError()==ERROR_IO_PENDING)) return true;
@ -3094,7 +3091,7 @@ public:
}
// 0=still waiting, 1=catastrophic failure, 2=success, 3=sector not found, 4=crc error
Bitu CheckDiskReadComplete(HANDLE f, OVERLAPPED* o) {
Bitu CheckDiskReadComplete(HANDLE f, OVERLAPPED* o) const {
DWORD numret;
BOOL b = GetOverlappedResult( f, o, &numret,false);
if(b) return 2;
@ -4452,7 +4449,7 @@ public:
void DisplayMenuCursorEnd(void) { WriteOut("\033[0m\n"); }
void DisplayMenuNone(void) { WriteOut("\033[44m\033[K\033[0m\n"); }
bool CON_IN(uint8_t * data) {
bool CON_IN(uint8_t * data) const {
uint8_t c;
uint16_t n=1;
@ -4508,7 +4505,11 @@ public:
return;
}
if(cmd->FindExist("usage",false)) {DisplayUsage(); if (attr) DOS_SetAnsiAttr(attr); return; }
if(cmd->FindExist("usage", false)) {
DisplayUsage();
if(attr) DOS_SetAnsiAttr(attr);
return;
}
uint8_t c;uint16_t n=1;
#define CURSOR(option) \
@ -4953,7 +4954,7 @@ public:
//look for -el-torito parameter and remove it from the command line
cmd->FindString("-el-torito",el_torito,true);
if (el_torito == "") cmd->FindString("-bootcd",el_torito,true);
if(el_torito == "") cmd->FindString("-bootcd", el_torito, true);
if (el_torito != "") {
//get el-torito floppy from cdrom mounted at drive letter el_torito_cd_drive
el_torito_cd_drive = toupper(el_torito[0]);
@ -6023,12 +6024,12 @@ private:
return true;
}
void AddToDriveManager(const char drive, DOS_Drive* imgDisk, const uint8_t mediaid) {
void AddToDriveManager(const char drive, DOS_Drive* imgDisk, const uint8_t mediaid) const {
std::vector<DOS_Drive*> imgDisks = { imgDisk };
AddToDriveManager(drive, imgDisks, mediaid);
}
void AddToDriveManager(const char drive, const std::vector<DOS_Drive*> &imgDisks, const uint8_t mediaid) {
void AddToDriveManager(const char drive, const std::vector<DOS_Drive*> &imgDisks, const uint8_t mediaid) const {
std::vector<DOS_Drive*>::size_type ct;
// Update DriveManager
@ -6193,7 +6194,7 @@ private:
}
}
bool DetectMFMsectorPartition(uint8_t buf[], uint32_t fcsize, Bitu sizes[]) {
bool DetectMFMsectorPartition(uint8_t buf[], uint32_t fcsize, Bitu sizes[]) const {
// This is used for plain MFM sector format as created by IMGMAKE
// It tries to find the first partition. Addressing is in CHS format.
/* Offset | Length | Description
@ -6256,7 +6257,7 @@ private:
return false;
}
bool DetectBximagePartition(uint32_t fcsize, Bitu sizes[]) {
bool DetectBximagePartition(uint32_t fcsize, Bitu sizes[]) const {
// Try bximage disk geometry
uint32_t cylinders = fcsize / (16 * 63);
// Int13 only supports up to 1023 cylinders
@ -6284,17 +6285,17 @@ private:
int error = -1;
DOS_Drive* newDrive = new isoDrive(drive, wpcolon&&paths[i].length()>1&&paths[i].c_str()[0]==':'?paths[i].c_str()+1:paths[i].c_str(), mediaid, error, options);
isoDisks.push_back(newDrive);
if (!qmount)
switch (error) {
case 0: break;
case 1: WriteOut(MSG_Get("MSCDEX_ERROR_MULTIPLE_CDROMS")); break;
case 2: WriteOut(MSG_Get("MSCDEX_ERROR_NOT_SUPPORTED")); break;
case 3: WriteOut(MSG_Get("MSCDEX_ERROR_OPEN")); break;
case 4: WriteOut(MSG_Get("MSCDEX_TOO_MANY_DRIVES")); break;
case 5: WriteOut(MSG_Get("MSCDEX_LIMITED_SUPPORT")); break;
case 6: WriteOut(MSG_Get("MSCDEX_INVALID_FILEFORMAT")); break;
default: WriteOut(MSG_Get("MSCDEX_UNKNOWN_ERROR")); break;
}
if(!qmount)
switch(error) {
case 0: break;
case 1: WriteOut(MSG_Get("MSCDEX_ERROR_MULTIPLE_CDROMS")); break;
case 2: WriteOut(MSG_Get("MSCDEX_ERROR_NOT_SUPPORTED")); break;
case 3: WriteOut(MSG_Get("MSCDEX_ERROR_OPEN")); break;
case 4: WriteOut(MSG_Get("MSCDEX_TOO_MANY_DRIVES")); break;
case 5: WriteOut(MSG_Get("MSCDEX_LIMITED_SUPPORT")); break;
case 6: WriteOut(MSG_Get("MSCDEX_INVALID_FILEFORMAT")); break;
default: WriteOut(MSG_Get("MSCDEX_UNKNOWN_ERROR")); break;
}
// error: clean up and leave
if (error) {
for (ct = 0; ct < isoDisks.size(); ct++) {
@ -6620,9 +6621,9 @@ private:
void PrintStatus() {
WriteOut("Status for device CON:\n----------------------\nColumns=%d\nLines=%d\n", COLS, LINES);
#if defined(USE_TTF)
if (!ttf.inUse)
if(!ttf.inUse)
#endif
WriteOut("\nCode page operation not supported on this device\n");
WriteOut("\nCode page operation not supported on this device\n");
}
int LINES = 25, COLS = 80;
};

View File

@ -115,7 +115,7 @@ void UDFTagId::parse(const unsigned int sz,const unsigned char *b) {
}
}
bool UDFTagId::tagChecksumOK(const unsigned int sz,const unsigned char *b) {
bool UDFTagId::tagChecksumOK(const unsigned int sz,const unsigned char *b) const {
uint8_t chksum = 0;
if (sz < 16)
@ -132,7 +132,7 @@ bool UDFTagId::tagChecksumOK(const unsigned int sz,const unsigned char *b) {
return true;
}
bool UDFTagId::dataChecksumOK(const unsigned int sz,const unsigned char *b) {
bool UDFTagId::dataChecksumOK(const unsigned int sz,const unsigned char *b) const {
if (DescriptorCRCLength != 0) {
if ((DescriptorCRCLength+16u) > sz)
return false;
@ -696,8 +696,7 @@ UDFlong_ad::UDFlong_ad() {
UDFextent::UDFextent() {
}
UDFextent::UDFextent(const struct UDFextent_ad &s) {
ex = s;
UDFextent::UDFextent(const struct UDFextent_ad &s) : ex(s) {
}
////////////////////////////////////
@ -711,7 +710,7 @@ UDFextents::UDFextents(const struct UDFextent_ad &s) {
////////////////////////////////////
void isoDrive::UDFFileEntryToExtents(UDFextents &ex,UDFFileEntry &fe) {
void isoDrive::UDFFileEntryToExtents(UDFextents &ex,UDFFileEntry &fe) const {
ex.xl.clear();
ex.indata.clear();
ex.is_indata = false;
@ -739,7 +738,7 @@ void isoDrive::UDFFileEntryToExtents(UDFextents &ex,UDFFileEntry &fe) {
////////////////////////////////////
void isoDrive::UDFextent_rewind(struct UDFextents &ex) {
void isoDrive::UDFextent_rewind(struct UDFextents &ex) const {
ex.relofs = 0;
ex.extent = 0;
ex.extofs = 0;
@ -755,7 +754,7 @@ uint64_t isoDrive::UDFtotalsize(struct UDFextents &ex) const {
return total;
}
uint64_t isoDrive::UDFextent_seek(struct UDFextents &ex,uint64_t ofs) {
uint64_t isoDrive::UDFextent_seek(struct UDFextents &ex,uint64_t ofs) const {
UDFextent_rewind(ex);
if (ex.is_indata) {
@ -783,7 +782,7 @@ uint64_t isoDrive::UDFextent_seek(struct UDFextents &ex,uint64_t ofs) {
return (uint64_t)ex.extofs + (uint64_t)ex.relofs;
}
unsigned int isoDrive::UDFextent_read(struct UDFextents &ex,unsigned char *buf,size_t count) {
unsigned int isoDrive::UDFextent_read(struct UDFextents &ex,unsigned char *buf,size_t count) const {
unsigned int rd = 0;
if (ex.is_indata) {
@ -975,9 +974,6 @@ isoDrive::isoDrive(char driveLetter, const char* fileName, uint8_t mediaid, int&
enable_udf = (dos.version.major > 7 || (dos.version.major == 7 && dos.version.minor >= 10));//default
enable_rock_ridge = (dos.version.major >= 7 || uselfn);//default
enable_joliet = (dos.version.major >= 7 || uselfn);//default
is_rock_ridge = false;
is_joliet = false;
is_udf = false;
for (const auto &opt : options) {
size_t equ = opt.find_first_of('=');
std::string name,value;
@ -1590,7 +1586,7 @@ bool isoDrive::GetNextDirEntry(const int dirIteratorHandle, UDFFileIdentifierDes
while (*s == '.'||*s == ' ') s++;
bool lead = false;
while (*s != 0) {
if (s == ext) break; // doesn't match if ext == NULL, so no harm in that case
if(s == ext) break; // doesn't match if ext == NULL, so no harm in that case
if (!lead && ((IS_PC98_ARCH && shiftjis_lead_byte(*s & 0xFF)) || (isDBCSCP() && isKanji1_gbk(*s & 0xFF)))) {
if (c >= (7-tailsize)) break;
lead = true;
@ -1713,11 +1709,11 @@ bool isoDrive::ReadCachedSector(uint8_t** buffer, const uint32_t sector) {
return true;
}
inline bool isoDrive :: readSector(uint8_t *buffer, uint32_t sector) {
inline bool isoDrive :: readSector(uint8_t *buffer, uint32_t sector) const {
return CDROM_Interface_Image::images[subUnit]->ReadSector(buffer, false, sector);
}
int isoDrive::readDirEntry(isoDirEntry* de, const uint8_t* data,unsigned int dirIteratorIndex) {
int isoDrive::readDirEntry(isoDirEntry* de, const uint8_t* data,unsigned int dirIteratorIndex) const {
// This code is NOT for UDF filesystem access!
if (is_udf) return -1;
@ -1890,7 +1886,7 @@ int isoDrive::readDirEntry(isoDirEntry* de, const uint8_t* data,unsigned int dir
while (*s == '.'||*s == ' ') s++;
bool lead = false;
while (*s != 0) {
if (s == ext) break; // doesn't match if ext == NULL, so no harm in that case
if(s == ext) break; // doesn't match if ext == NULL, so no harm in that case
if (!lead && ((IS_PC98_ARCH && shiftjis_lead_byte(*s & 0xFF)) || (isDBCSCP() && isKanji1_gbk(*s & 0xFF)))) {
if (c >= (7-tailsize)) break;
lead = true;
@ -1955,7 +1951,7 @@ static bool escape_is_joliet(const unsigned char *esc) {
return false;
}
bool isoDrive :: loadImageUDFAnchorVolumePointer(UDFAnchorVolumeDescriptorPointer &avdp,uint8_t pvd[COOKED_SECTOR_SIZE],uint32_t sector) {
bool isoDrive :: loadImageUDFAnchorVolumePointer(UDFAnchorVolumeDescriptorPointer &avdp,uint8_t pvd[COOKED_SECTOR_SIZE],uint32_t sector) const {
UDFTagId aid;
if (!aid.get(COOKED_SECTOR_SIZE,pvd)) return false;

View File

@ -96,6 +96,12 @@
#include "cp1258_uni.h"
#include "cp3021_uni.h"
#if defined (WIN32)
#include <Shellapi.h>
#else
#include <glob.h>
#endif
#if defined(PATH_MAX) && !defined(MAX_PATH)
#define MAX_PATH PATH_MAX
#endif
@ -1090,7 +1096,7 @@ int FileDirExistUTF8(std::string &localname, const char *name) {
extern uint16_t fztime, fzdate;
extern bool force_conversion, InitCodePage();
std::string GetDOSBoxXPath(bool withexe=false);
void getdrivezpath(std::string &path, std::string dirname) {
void getdrivezpath(std::string &path, std::string const& dirname) {
const host_cnv_char_t* host_name = CodePageGuestToHost(path.c_str());
if (host_name == NULL) {path = "";return;}
struct stat cstat;
@ -1126,7 +1132,7 @@ void getdrivezpath(std::string &path, std::string dirname) {
}
}
void drivezRegister(std::string path, std::string dir, bool usecp) {
void drivezRegister(std::string const& path, std::string const& dir, bool usecp) {
int cp = dos.loaded_codepage;
if (!usecp || !cp) {
force_conversion = true;
@ -1494,13 +1500,13 @@ bool localDrive::FileOpen(DOS_File * * file,const char * name,uint32_t flags) {
break;
}
}
if (!dos_kernel_disabled)
for (i=0;i<DOS_FILES;i++) {
if (Files[i] && Files[i]->IsOpen() && Files[i]->GetDrive()==drive && Files[i]->IsName(name)) {
lfp=dynamic_cast<localFile*>(Files[i]);
if (lfp) lfp->Flush();
}
}
if(!dos_kernel_disabled)
for(i = 0; i < DOS_FILES; i++) {
if(Files[i] && Files[i]->IsOpen() && Files[i]->GetDrive() == drive && Files[i]->IsName(name)) {
lfp = dynamic_cast<localFile*>(Files[i]);
if(lfp) lfp->Flush();
}
}
// guest to host code page translation
const host_cnv_char_t* host_name = CodePageGuestToHost(newname);
@ -1612,11 +1618,6 @@ bool localDrive::GetSystemFilename(char *sysName, char const * const dosName) {
#endif
}
#if defined (WIN32)
#include <Shellapi.h>
#else
#include <glob.h>
#endif
bool localDrive::FileUnlink(const char * name) {
if (readonly) {
DOS_SetError(DOSERR_WRITE_PROTECTED);
@ -2888,14 +2889,12 @@ uint32_t localFile::GetSeekPos() {
localFile::localFile() {}
localFile::localFile(const char* _name, FILE * handle) {
fhandle=handle;
localFile::localFile(const char* _name, FILE* handle) : fhandle(handle) {
open=true;
localFile::UpdateDateTimeFromHost();
attr=DOS_ATTR_ARCHIVE;
last_action=NONE;
read_only_medium=false;
name=0;
SetName(_name);
@ -2982,15 +2981,12 @@ bool MSCDEX_HasMediaChanged(uint8_t subUnit);
bool MSCDEX_GetVolumeName(uint8_t subUnit, char* name);
cdromDrive::cdromDrive(const char driveLetter, const char * startdir,uint16_t _bytes_sector,uint8_t _sectors_cluster,uint16_t _total_clusters,uint16_t _free_clusters,uint8_t _mediaid, int& error, std::vector<std::string> &options)
:localDrive(startdir,_bytes_sector,_sectors_cluster,_total_clusters,_free_clusters,_mediaid,options),
subUnit(0),
driveLetter('\0')
:localDrive(startdir,_bytes_sector,_sectors_cluster,_total_clusters,_free_clusters,_mediaid,options), driveLetter(driveLetter)
{
// Init mscdex
error = MSCDEX_AddDrive(driveLetter,startdir,subUnit);
strcpy(info, "CDRom ");
strcat(info, startdir);
this->driveLetter = driveLetter;
// Get Volume Label
char name[32];
if (MSCDEX_GetVolumeName(subUnit,name)) dirCache.SetLabel(name,true,true);

View File

@ -101,7 +101,7 @@ public:
virtual bool add_special_file_to_disk(const char* dosname, const char* operation, uint16_t value, bool isdir);
virtual void EmptyCache(void) { dirCache.EmptyCache(); };
virtual void MediaChange() {};
const char* getBasedir() {return basedir;};
const char* getBasedir() const {return basedir;};
struct {
uint16_t bytes_sector;
uint8_t sectors_cluster;
@ -537,7 +537,7 @@ public:
virtual bool isRemote(void);
virtual bool isRemovable(void);virtual Bits UnMount(void);
private:
uint8_t subUnit; char driveLetter;
uint8_t subUnit = 0; char driveLetter = '\0';
};
class physfscdromDrive : public physfsDrive
@ -688,8 +688,8 @@ struct UDFTagId { /* ECMA-167 7.2.1 */
bool get(const unsigned int sz,const unsigned char *b);
void parse(const unsigned int sz,const unsigned char *b);
bool tagChecksumOK(const unsigned int sz,const unsigned char *b);
bool dataChecksumOK(const unsigned int sz,const unsigned char *b);
bool tagChecksumOK(const unsigned int sz,const unsigned char *b) const;
bool dataChecksumOK(const unsigned int sz,const unsigned char *b) const;
bool checksumOK(const unsigned int sz,const unsigned char *b);
UDFTagId(const unsigned int sz,const unsigned char *b);
UDFTagId();
@ -1059,13 +1059,13 @@ public:
virtual Bits UnMount(void);
bool loadImage();
bool loadImageUDF();
bool loadImageUDFAnchorVolumePointer(UDFAnchorVolumeDescriptorPointer &avdp,uint8_t *pvd/*COOKED_SECTOR_SIZE*/,uint32_t sector);
bool readSector(uint8_t *buffer, uint32_t sector);
bool loadImageUDFAnchorVolumePointer(UDFAnchorVolumeDescriptorPointer &avdp,uint8_t *pvd/*COOKED_SECTOR_SIZE*/,uint32_t sector) const;
bool readSector(uint8_t *buffer, uint32_t sector) const;
void setFileName(const char* fileName);
virtual char const* GetLabel(void) {return discLabel;};
virtual void Activate(void);
private:
int readDirEntry(isoDirEntry* de, const uint8_t* data, unsigned int direntindex);
int readDirEntry(isoDirEntry* de, const uint8_t* data, unsigned int direntindex) const;
bool lookup(isoDirEntry *de, const char *path);
bool lookup(UDFFileIdentifierDescriptor &fid, UDFFileEntry &fe, const char *path);
int UpdateMscdex(char driveLetter, const char* path, uint8_t& subUnit);
@ -1114,10 +1114,10 @@ private:
UDFFileSetDescriptor fsetd;
UDFPartitionDescriptor partd;
public:
void UDFextent_rewind(struct UDFextents &ex);
void UDFFileEntryToExtents(UDFextents &ex,UDFFileEntry &fe);
uint64_t UDFextent_seek(struct UDFextents &ex,uint64_t ofs);
unsigned int UDFextent_read(struct UDFextents &ex,unsigned char *buf,size_t count);
void UDFextent_rewind(struct UDFextents &ex) const;
void UDFFileEntryToExtents(UDFextents &ex,UDFFileEntry &fe) const;
uint64_t UDFextent_seek(struct UDFextents &ex,uint64_t ofs) const;
unsigned int UDFextent_read(struct UDFextents &ex,unsigned char *buf,size_t count) const;
uint64_t UDFtotalsize(struct UDFextents &ex) const;
private:
struct DirIterator {
@ -1190,7 +1190,7 @@ public:
virtual bool TestDir(const char * dir);
virtual bool RemoveDir(const char * dir);
virtual bool MakeDir(const char * dir);
const char* getOverlaydir() {return overlaydir;};
const char* getOverlaydir() const {return overlaydir;};
bool ovlnocachedir = false;
bool ovlreadonly = false;
private:

View File

@ -3614,7 +3614,7 @@ private:
OPL_Mode oplmode;
/* Support Functions */
void Find_Type_And_Opl(Section_prop* config,SB_TYPES& type, OPL_Mode& opl_mode){
void Find_Type_And_Opl(Section_prop* config,SB_TYPES& type, OPL_Mode& opl_mode) const {
sb.vibra = false;
sb.ess_type = ESS_NONE;
sb.reveal_sc_type = RSC_NONE;