From 8da42c59831e3fd2cbfe0407240697a22b8472f6 Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Tue, 31 Dec 2019 20:29:22 +0100 Subject: [PATCH] Remove false friend declarations The single use from friended class is in public interface. Removal of friend designators allows Clang to pinpoint few additional unused private fields. --- src/dos/dos_programs.cpp | 12 +++++------- src/dos/drive_fat.cpp | 5 +---- src/dos/drives.cpp | 5 +---- src/dos/drives.h | 26 +++++--------------------- src/shell/shell_cmds.cpp | 2 +- 5 files changed, 13 insertions(+), 37 deletions(-) diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index 00399cea..1a57cea6 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -16,14 +16,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "programs.h" -#include "dosbox.h" -#include -#include #include +#include +#include #include #include -#include "programs.h" + #include "support.h" #include "drives.h" #include "cross.h" @@ -31,15 +31,13 @@ #include "callback.h" #include "cdrom.h" #include "dos_system.h" -#include "dos_inc.h" #include "bios.h" #include "bios_disk.h" #include "setup.h" #include "control.h" #include "inout.h" #include "dma.h" - - +#include "shell.h" #if defined(WIN32) #ifndef S_ISDIR diff --git a/src/dos/drive_fat.cpp b/src/dos/drive_fat.cpp index 6bbeb26f..975064c9 100644 --- a/src/dos/drive_fat.cpp +++ b/src/dos/drive_fat.cpp @@ -720,8 +720,6 @@ fatDrive::fatDrive(const char *sysFilename, Bit32u startSector) : loadedDisk(nullptr), created_successfully(true), - srchInfo{ {0} }, - allocation{0, 0, 0, 0, 0}, bootbuffer{{0}, {0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, 0, 0}, absolute(false), fattype(0), @@ -730,10 +728,9 @@ fatDrive::fatDrive(const char *sysFilename, firstDataSector(0), firstRootDirSect(0), cwdDirCluster(0), - dirPosition(0), fatSectBuffer{0}, curFatSect(0) - { +{ FILE *diskfile; Bit32u filesize; bool is_hdd; diff --git a/src/dos/drives.cpp b/src/dos/drives.cpp index 6b312bd6..5caaf519 100644 --- a/src/dos/drives.cpp +++ b/src/dos/drives.cpp @@ -16,11 +16,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#include "dosbox.h" -#include "dos_system.h" #include "drives.h" -#include "mapper.h" + #include "support.h" bool WildFileCmp(const char * file, const char * wild) diff --git a/src/dos/drives.h b/src/dos/drives.h index 27e8a298..77544cb9 100644 --- a/src/dos/drives.h +++ b/src/dos/drives.h @@ -16,16 +16,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#ifndef DOSBOX_DRIVES_H +#define DOSBOX_DRIVES_H -#ifndef _DRIVES_H__ -#define _DRIVES_H__ +#include "dosbox.h" #include #include #include -#include + +#include "dos_inc.h" #include "dos_system.h" -#include "shell.h" /* for DOS_Shell */ bool WildFileCmp(const char * file, const char * wild); void Set_Label(char const * const input, char * const output, bool cdrom); @@ -75,9 +76,6 @@ public: const char* getBasedir() {return basedir;}; protected: char basedir[CROSS_LEN]; -private: - friend void DOS_Shell::CMD_SUBST(char* args); -protected: struct { char srch_dir[CROSS_LEN]; } srchInfo[MAX_OPENDIRS]; @@ -197,18 +195,6 @@ private: bool addDirectoryEntry(Bit32u dirClustNumber, direntry useEntry); void zeroOutCluster(Bit32u clustNumber); bool getEntryName(char *fullname, char *entname); - friend void DOS_Shell::CMD_SUBST(char* args); - struct { - char srch_dir[CROSS_LEN]; - } srchInfo[MAX_OPENDIRS]; - - struct { - Bit16u bytes_sector; - Bit8u sectors_cluster; - Bit16u total_clusters; - Bit16u free_clusters; - Bit8u mediaid; - } allocation; bootstrap bootbuffer; bool absolute; @@ -219,13 +205,11 @@ private: Bit32u firstRootDirSect; Bit32u cwdDirCluster; - Bit32u dirPosition; /* Position in directory search */ Bit8u fatSectBuffer[1024]; Bit32u curFatSect; }; - class cdromDrive : public localDrive { public: diff --git a/src/shell/shell_cmds.cpp b/src/shell/shell_cmds.cpp index 95a6f594..e5f24ed6 100644 --- a/src/shell/shell_cmds.cpp +++ b/src/shell/shell_cmds.cpp @@ -1275,7 +1275,7 @@ void DOS_Shell::CMD_SUBST (char * args) { if( ( ldp=dynamic_cast(Drives[drive])) == 0 ) throw 0; char newname[CROSS_LEN]; - strcpy(newname, ldp->basedir); + strcpy(newname, ldp->getBasedir()); strcat(newname,fulldir); CROSS_FILENAME(newname); ldp->dirCache.ExpandName(newname);