Added explicit copy constructors and made other tweaks to avoid
compiler complaints.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
CC=gcc
|
||||
CXX=clang++
|
||||
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
|
||||
#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
|
||||
@@ -24,7 +25,7 @@ cgdisk: $(LIB_OBJS) cgdisk.o gptcurses.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 -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
|
||||
|
||||
fixparts: $(MBR_LIB_OBJS) fixparts.o
|
||||
|
||||
11
NEWS
11
NEWS
@@ -1,6 +1,17 @@
|
||||
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
|
||||
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
|
||||
|
||||
74
basicmbr.cc
74
basicmbr.cc
@@ -43,6 +43,36 @@ BasicMBRData::BasicMBRData(void) {
|
||||
EmptyMBR();
|
||||
} // 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) {
|
||||
blockSize = SECTOR_SIZE;
|
||||
diskSize = 0;
|
||||
@@ -73,29 +103,31 @@ BasicMBRData::~BasicMBRData(void) {
|
||||
BasicMBRData & BasicMBRData::operator=(const BasicMBRData & orig) {
|
||||
int i;
|
||||
|
||||
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;
|
||||
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::operator=()! Terminating!\n";
|
||||
exit(1);
|
||||
myDisk = new DiskIO;
|
||||
if (myDisk == NULL) {
|
||||
cerr << "Unable to allocate memory in BasicMBRData::operator=()! 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
|
||||
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;
|
||||
} // BasicMBRData::operator=()
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ protected:
|
||||
public:
|
||||
BasicMBRData(void);
|
||||
BasicMBRData(string deviceFilename);
|
||||
BasicMBRData(const BasicMBRData &);
|
||||
~BasicMBRData(void);
|
||||
BasicMBRData & operator=(const BasicMBRData & orig);
|
||||
|
||||
|
||||
99
gpt.cc
99
gpt.cc
@@ -86,6 +86,45 @@ GPTData::GPTData(void) {
|
||||
chksum_crc32gentab();
|
||||
} // 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
|
||||
GPTData::GPTData(string filename) {
|
||||
blockSize = SECTOR_SIZE; // set a default
|
||||
@@ -120,38 +159,40 @@ GPTData::~GPTData(void) {
|
||||
GPTData & GPTData::operator=(const GPTData & orig) {
|
||||
uint32_t i;
|
||||
|
||||
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;
|
||||
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());
|
||||
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);
|
||||
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
|
||||
for (i = 0; i < numParts; i++) {
|
||||
partitions[i] = orig.partitions[i];
|
||||
} // for
|
||||
|
||||
return *this;
|
||||
} // GPTData::operator=()
|
||||
|
||||
1
gpt.h
1
gpt.h
@@ -92,6 +92,7 @@ protected:
|
||||
public:
|
||||
// Basic necessary functions....
|
||||
GPTData(void);
|
||||
GPTData(const GPTData &);
|
||||
GPTData(string deviceFilename);
|
||||
virtual ~GPTData(void);
|
||||
GPTData & operator=(const GPTData & orig);
|
||||
|
||||
@@ -394,6 +394,7 @@ void GPTDataCurses::ChangeType(int partNum) {
|
||||
// Sets the partition alignment value
|
||||
void GPTDataCurses::SetAlignment(void) {
|
||||
int alignment;
|
||||
char conversion_specifier[] = "%d";
|
||||
|
||||
move(LINES - 4, 0);
|
||||
clrtobot();
|
||||
@@ -402,7 +403,7 @@ void GPTDataCurses::SetAlignment(void) {
|
||||
move(LINES - 3, 0);
|
||||
printw("Type new alignment value, in sectors: ");
|
||||
echo();
|
||||
scanw("%d", &alignment);
|
||||
scanw(conversion_specifier, &alignment);
|
||||
noecho();
|
||||
} while ((alignment == 0) || (alignment > MAX_ALIGNMENT));
|
||||
GPTData::SetAlignment(alignment);
|
||||
|
||||
@@ -38,6 +38,15 @@ GPTPart::GPTPart(void) {
|
||||
memset(name, 0, NAME_SIZE * sizeof(name[0]) );
|
||||
} // 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) {
|
||||
} // destructor
|
||||
|
||||
|
||||
Reference in New Issue
Block a user