Added explicit copy constructors and made other tweaks to avoid
compiler complaints.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
CC=gcc
|
CC=gcc
|
||||||
CXX=clang++
|
CXX=clang++
|
||||||
FATBINFLAGS=-arch x86_64 -arch i386 -mmacosx-version-min=10.4
|
FATBINFLAGS=-arch x86_64 -arch i386 -mmacosx-version-min=10.4
|
||||||
|
THINBINFLAGS=-arch x86_64 -mmacosx-version-min=10.4
|
||||||
CFLAGS=$(FATBINFLAGS) -O2 -D_FILE_OFFSET_BITS=64 -g
|
CFLAGS=$(FATBINFLAGS) -O2 -D_FILE_OFFSET_BITS=64 -g
|
||||||
#CXXFLAGS=-O2 -Wall -D_FILE_OFFSET_BITS=64 -D USE_UTF16 -I/opt/local/include -I/usr/local/include -I/opt/local/include -g
|
#CXXFLAGS=-O2 -Wall -D_FILE_OFFSET_BITS=64 -D USE_UTF16 -I/opt/local/include -I/usr/local/include -I/opt/local/include -g
|
||||||
CXXFLAGS=$(FATBINFLAGS) -O2 -Wall -D_FILE_OFFSET_BITS=64 -I/opt/local/include -I /usr/local/include -I/opt/local/include -g
|
CXXFLAGS=$(FATBINFLAGS) -O2 -Wall -D_FILE_OFFSET_BITS=64 -I/opt/local/include -I /usr/local/include -I/opt/local/include -g
|
||||||
@@ -24,7 +25,7 @@ cgdisk: $(LIB_OBJS) cgdisk.o gptcurses.o
|
|||||||
|
|
||||||
sgdisk: $(LIB_OBJS) gptcl.o sgdisk.o
|
sgdisk: $(LIB_OBJS) gptcl.o sgdisk.o
|
||||||
# $(CXX) $(LIB_OBJS) gptcl.o sgdisk.o /opt/local/lib/libiconv.a /opt/local/lib/libintl.a /opt/local/lib/libpopt.a $(FATBINFLAGS) -o sgdisk
|
# $(CXX) $(LIB_OBJS) gptcl.o sgdisk.o /opt/local/lib/libiconv.a /opt/local/lib/libintl.a /opt/local/lib/libpopt.a $(FATBINFLAGS) -o sgdisk
|
||||||
$(CXX) $(LIB_OBJS) gptcl.o sgdisk.o -L/opt/local/lib -lpopt $(FATBINFLAGS) -o sgdisk
|
$(CXX) $(LIB_OBJS) gptcl.o sgdisk.o -L/usr/local/lib -lpopt $(THINBINFLAGS) -o sgdisk
|
||||||
# $(CXX) $(LIB_OBJS) gptcl.o sgdisk.o -L/sw/lib -licucore -lpopt -o sgdisk
|
# $(CXX) $(LIB_OBJS) gptcl.o sgdisk.o -L/sw/lib -licucore -lpopt -o sgdisk
|
||||||
|
|
||||||
fixparts: $(MBR_LIB_OBJS) fixparts.o
|
fixparts: $(MBR_LIB_OBJS) fixparts.o
|
||||||
|
|||||||
11
NEWS
11
NEWS
@@ -1,6 +1,17 @@
|
|||||||
1.0.4 (7/5/2018):
|
1.0.4 (7/5/2018):
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Added some explicit copy constructors and made some other tweaks to avoid
|
||||||
|
compiler warnings.
|
||||||
|
|
||||||
|
- The macOS binary for sgdisk is now a pure 64-bit build; I'm no longer
|
||||||
|
supporting 32-bit builds of sgdisk. The gdisk and cgdisk binaries remain
|
||||||
|
"fat" 32-/64-bit builds. The reason for dropping the 32-bit support from
|
||||||
|
sgdisk is that I've re-built my macOS development system, and I had
|
||||||
|
trouble building a "fat" binary with the fresh install of the popt
|
||||||
|
libraries upon which sgdisk relies. 32-bit support for the other binaries
|
||||||
|
is now officially deprecated, too.
|
||||||
|
|
||||||
- Added search feature to partition type list functions ("L" on main menu of
|
- Added search feature to partition type list functions ("L" on main menu of
|
||||||
gdisk and "L" when entered in response to the "Hex code or GUID" prompt in
|
gdisk and "L" when entered in response to the "Hex code or GUID" prompt in
|
||||||
gdisk and sgdisk). This feature filters the partition type list to those
|
gdisk and sgdisk). This feature filters the partition type list to those
|
||||||
|
|||||||
74
basicmbr.cc
74
basicmbr.cc
@@ -43,6 +43,36 @@ BasicMBRData::BasicMBRData(void) {
|
|||||||
EmptyMBR();
|
EmptyMBR();
|
||||||
} // BasicMBRData default constructor
|
} // BasicMBRData default constructor
|
||||||
|
|
||||||
|
BasicMBRData::BasicMBRData(const BasicMBRData & orig) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (&orig != this) {
|
||||||
|
memcpy(code, orig.code, 440);
|
||||||
|
diskSignature = orig.diskSignature;
|
||||||
|
nulls = orig.nulls;
|
||||||
|
MBRSignature = orig.MBRSignature;
|
||||||
|
blockSize = orig.blockSize;
|
||||||
|
diskSize = orig.diskSize;
|
||||||
|
numHeads = orig.numHeads;
|
||||||
|
numSecspTrack = orig.numSecspTrack;
|
||||||
|
canDeleteMyDisk = orig.canDeleteMyDisk;
|
||||||
|
device = orig.device;
|
||||||
|
state = orig.state;
|
||||||
|
|
||||||
|
myDisk = new DiskIO;
|
||||||
|
if (myDisk == NULL) {
|
||||||
|
cerr << "Unable to allocate memory in BasicMBRData copy constructor! Terminating!\n";
|
||||||
|
exit(1);
|
||||||
|
} // if
|
||||||
|
if (orig.myDisk != NULL)
|
||||||
|
myDisk->OpenForRead(orig.myDisk->GetName());
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_MBR_PARTS; i++) {
|
||||||
|
partitions[i] = orig.partitions[i];
|
||||||
|
} // for
|
||||||
|
} // if
|
||||||
|
} // BasicMBRData copy constructor
|
||||||
|
|
||||||
BasicMBRData::BasicMBRData(string filename) {
|
BasicMBRData::BasicMBRData(string filename) {
|
||||||
blockSize = SECTOR_SIZE;
|
blockSize = SECTOR_SIZE;
|
||||||
diskSize = 0;
|
diskSize = 0;
|
||||||
@@ -73,29 +103,31 @@ BasicMBRData::~BasicMBRData(void) {
|
|||||||
BasicMBRData & BasicMBRData::operator=(const BasicMBRData & orig) {
|
BasicMBRData & BasicMBRData::operator=(const BasicMBRData & orig) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
memcpy(code, orig.code, 440);
|
if (&orig != this) {
|
||||||
diskSignature = orig.diskSignature;
|
memcpy(code, orig.code, 440);
|
||||||
nulls = orig.nulls;
|
diskSignature = orig.diskSignature;
|
||||||
MBRSignature = orig.MBRSignature;
|
nulls = orig.nulls;
|
||||||
blockSize = orig.blockSize;
|
MBRSignature = orig.MBRSignature;
|
||||||
diskSize = orig.diskSize;
|
blockSize = orig.blockSize;
|
||||||
numHeads = orig.numHeads;
|
diskSize = orig.diskSize;
|
||||||
numSecspTrack = orig.numSecspTrack;
|
numHeads = orig.numHeads;
|
||||||
canDeleteMyDisk = orig.canDeleteMyDisk;
|
numSecspTrack = orig.numSecspTrack;
|
||||||
device = orig.device;
|
canDeleteMyDisk = orig.canDeleteMyDisk;
|
||||||
state = orig.state;
|
device = orig.device;
|
||||||
|
state = orig.state;
|
||||||
|
|
||||||
myDisk = new DiskIO;
|
myDisk = new DiskIO;
|
||||||
if (myDisk == NULL) {
|
if (myDisk == NULL) {
|
||||||
cerr << "Unable to allocate memory in BasicMBRData::operator=()! Terminating!\n";
|
cerr << "Unable to allocate memory in BasicMBRData::operator=()! Terminating!\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
|
} // if
|
||||||
|
if (orig.myDisk != NULL)
|
||||||
|
myDisk->OpenForRead(orig.myDisk->GetName());
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_MBR_PARTS; i++) {
|
||||||
|
partitions[i] = orig.partitions[i];
|
||||||
|
} // for
|
||||||
} // if
|
} // if
|
||||||
if (orig.myDisk != NULL)
|
|
||||||
myDisk->OpenForRead(orig.myDisk->GetName());
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_MBR_PARTS; i++) {
|
|
||||||
partitions[i] = orig.partitions[i];
|
|
||||||
} // for
|
|
||||||
return *this;
|
return *this;
|
||||||
} // BasicMBRData::operator=()
|
} // BasicMBRData::operator=()
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
BasicMBRData(void);
|
BasicMBRData(void);
|
||||||
BasicMBRData(string deviceFilename);
|
BasicMBRData(string deviceFilename);
|
||||||
|
BasicMBRData(const BasicMBRData &);
|
||||||
~BasicMBRData(void);
|
~BasicMBRData(void);
|
||||||
BasicMBRData & operator=(const BasicMBRData & orig);
|
BasicMBRData & operator=(const BasicMBRData & orig);
|
||||||
|
|
||||||
|
|||||||
99
gpt.cc
99
gpt.cc
@@ -86,6 +86,45 @@ GPTData::GPTData(void) {
|
|||||||
chksum_crc32gentab();
|
chksum_crc32gentab();
|
||||||
} // GPTData default constructor
|
} // GPTData default constructor
|
||||||
|
|
||||||
|
GPTData::GPTData(const GPTData & orig) {
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
if (&orig != this) {
|
||||||
|
mainHeader = orig.mainHeader;
|
||||||
|
numParts = orig.numParts;
|
||||||
|
secondHeader = orig.secondHeader;
|
||||||
|
protectiveMBR = orig.protectiveMBR;
|
||||||
|
device = orig.device;
|
||||||
|
blockSize = orig.blockSize;
|
||||||
|
physBlockSize = orig.physBlockSize;
|
||||||
|
diskSize = orig.diskSize;
|
||||||
|
state = orig.state;
|
||||||
|
justLooking = orig.justLooking;
|
||||||
|
mainCrcOk = orig.mainCrcOk;
|
||||||
|
secondCrcOk = orig.secondCrcOk;
|
||||||
|
mainPartsCrcOk = orig.mainPartsCrcOk;
|
||||||
|
secondPartsCrcOk = orig.secondPartsCrcOk;
|
||||||
|
apmFound = orig.apmFound;
|
||||||
|
bsdFound = orig.bsdFound;
|
||||||
|
sectorAlignment = orig.sectorAlignment;
|
||||||
|
beQuiet = orig.beQuiet;
|
||||||
|
whichWasUsed = orig.whichWasUsed;
|
||||||
|
|
||||||
|
myDisk.OpenForRead(orig.myDisk.GetName());
|
||||||
|
|
||||||
|
delete[] partitions;
|
||||||
|
partitions = new GPTPart [numParts];
|
||||||
|
if (partitions == NULL) {
|
||||||
|
cerr << "Error! Could not allocate memory for partitions in GPTData::operator=()!\n"
|
||||||
|
<< "Terminating!\n";
|
||||||
|
exit(1);
|
||||||
|
} // if
|
||||||
|
for (i = 0; i < numParts; i++) {
|
||||||
|
partitions[i] = orig.partitions[i];
|
||||||
|
} // for
|
||||||
|
} // if
|
||||||
|
} // GPTData copy constructor
|
||||||
|
|
||||||
// The following constructor loads GPT data from a device file
|
// The following constructor loads GPT data from a device file
|
||||||
GPTData::GPTData(string filename) {
|
GPTData::GPTData(string filename) {
|
||||||
blockSize = SECTOR_SIZE; // set a default
|
blockSize = SECTOR_SIZE; // set a default
|
||||||
@@ -120,38 +159,40 @@ GPTData::~GPTData(void) {
|
|||||||
GPTData & GPTData::operator=(const GPTData & orig) {
|
GPTData & GPTData::operator=(const GPTData & orig) {
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
mainHeader = orig.mainHeader;
|
if (&orig != this) {
|
||||||
numParts = orig.numParts;
|
mainHeader = orig.mainHeader;
|
||||||
secondHeader = orig.secondHeader;
|
numParts = orig.numParts;
|
||||||
protectiveMBR = orig.protectiveMBR;
|
secondHeader = orig.secondHeader;
|
||||||
device = orig.device;
|
protectiveMBR = orig.protectiveMBR;
|
||||||
blockSize = orig.blockSize;
|
device = orig.device;
|
||||||
physBlockSize = orig.physBlockSize;
|
blockSize = orig.blockSize;
|
||||||
diskSize = orig.diskSize;
|
physBlockSize = orig.physBlockSize;
|
||||||
state = orig.state;
|
diskSize = orig.diskSize;
|
||||||
justLooking = orig.justLooking;
|
state = orig.state;
|
||||||
mainCrcOk = orig.mainCrcOk;
|
justLooking = orig.justLooking;
|
||||||
secondCrcOk = orig.secondCrcOk;
|
mainCrcOk = orig.mainCrcOk;
|
||||||
mainPartsCrcOk = orig.mainPartsCrcOk;
|
secondCrcOk = orig.secondCrcOk;
|
||||||
secondPartsCrcOk = orig.secondPartsCrcOk;
|
mainPartsCrcOk = orig.mainPartsCrcOk;
|
||||||
apmFound = orig.apmFound;
|
secondPartsCrcOk = orig.secondPartsCrcOk;
|
||||||
bsdFound = orig.bsdFound;
|
apmFound = orig.apmFound;
|
||||||
sectorAlignment = orig.sectorAlignment;
|
bsdFound = orig.bsdFound;
|
||||||
beQuiet = orig.beQuiet;
|
sectorAlignment = orig.sectorAlignment;
|
||||||
whichWasUsed = orig.whichWasUsed;
|
beQuiet = orig.beQuiet;
|
||||||
|
whichWasUsed = orig.whichWasUsed;
|
||||||
|
|
||||||
myDisk.OpenForRead(orig.myDisk.GetName());
|
myDisk.OpenForRead(orig.myDisk.GetName());
|
||||||
|
|
||||||
delete[] partitions;
|
delete[] partitions;
|
||||||
partitions = new GPTPart [numParts];
|
partitions = new GPTPart [numParts];
|
||||||
if (partitions == NULL) {
|
if (partitions == NULL) {
|
||||||
cerr << "Error! Could not allocate memory for partitions in GPTData::operator=()!\n"
|
cerr << "Error! Could not allocate memory for partitions in GPTData::operator=()!\n"
|
||||||
<< "Terminating!\n";
|
<< "Terminating!\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
|
} // if
|
||||||
|
for (i = 0; i < numParts; i++) {
|
||||||
|
partitions[i] = orig.partitions[i];
|
||||||
|
} // for
|
||||||
} // if
|
} // if
|
||||||
for (i = 0; i < numParts; i++) {
|
|
||||||
partitions[i] = orig.partitions[i];
|
|
||||||
} // for
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
} // GPTData::operator=()
|
} // GPTData::operator=()
|
||||||
|
|||||||
1
gpt.h
1
gpt.h
@@ -92,6 +92,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
// Basic necessary functions....
|
// Basic necessary functions....
|
||||||
GPTData(void);
|
GPTData(void);
|
||||||
|
GPTData(const GPTData &);
|
||||||
GPTData(string deviceFilename);
|
GPTData(string deviceFilename);
|
||||||
virtual ~GPTData(void);
|
virtual ~GPTData(void);
|
||||||
GPTData & operator=(const GPTData & orig);
|
GPTData & operator=(const GPTData & orig);
|
||||||
|
|||||||
@@ -394,6 +394,7 @@ void GPTDataCurses::ChangeType(int partNum) {
|
|||||||
// Sets the partition alignment value
|
// Sets the partition alignment value
|
||||||
void GPTDataCurses::SetAlignment(void) {
|
void GPTDataCurses::SetAlignment(void) {
|
||||||
int alignment;
|
int alignment;
|
||||||
|
char conversion_specifier[] = "%d";
|
||||||
|
|
||||||
move(LINES - 4, 0);
|
move(LINES - 4, 0);
|
||||||
clrtobot();
|
clrtobot();
|
||||||
@@ -402,7 +403,7 @@ void GPTDataCurses::SetAlignment(void) {
|
|||||||
move(LINES - 3, 0);
|
move(LINES - 3, 0);
|
||||||
printw("Type new alignment value, in sectors: ");
|
printw("Type new alignment value, in sectors: ");
|
||||||
echo();
|
echo();
|
||||||
scanw("%d", &alignment);
|
scanw(conversion_specifier, &alignment);
|
||||||
noecho();
|
noecho();
|
||||||
} while ((alignment == 0) || (alignment > MAX_ALIGNMENT));
|
} while ((alignment == 0) || (alignment > MAX_ALIGNMENT));
|
||||||
GPTData::SetAlignment(alignment);
|
GPTData::SetAlignment(alignment);
|
||||||
|
|||||||
@@ -38,6 +38,15 @@ GPTPart::GPTPart(void) {
|
|||||||
memset(name, 0, NAME_SIZE * sizeof(name[0]) );
|
memset(name, 0, NAME_SIZE * sizeof(name[0]) );
|
||||||
} // Default constructor
|
} // Default constructor
|
||||||
|
|
||||||
|
GPTPart::GPTPart(const GPTPart & orig) {
|
||||||
|
partitionType = orig.partitionType;
|
||||||
|
uniqueGUID = orig.uniqueGUID;
|
||||||
|
firstLBA = orig.firstLBA;
|
||||||
|
lastLBA = orig.lastLBA;
|
||||||
|
attributes = orig.attributes;
|
||||||
|
memcpy(name, orig.name, NAME_SIZE * sizeof( name[ 0 ] ) );
|
||||||
|
} // Copy constructor
|
||||||
|
|
||||||
GPTPart::~GPTPart(void) {
|
GPTPart::~GPTPart(void) {
|
||||||
} // destructor
|
} // destructor
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user