Code cleanup based on 'infer' suggestions; mostly just dead stores.
One forgotten change
This commit is contained in:
12
basicmbr.cc
12
basicmbr.cc
@@ -140,7 +140,7 @@ BasicMBRData & BasicMBRData::operator=(const BasicMBRData & orig) {
|
|||||||
// Read data from MBR. Returns 1 if read was successful (even if the
|
// Read data from MBR. Returns 1 if read was successful (even if the
|
||||||
// data isn't a valid MBR), 0 if the read failed.
|
// data isn't a valid MBR), 0 if the read failed.
|
||||||
int BasicMBRData::ReadMBRData(const string & deviceFilename) {
|
int BasicMBRData::ReadMBRData(const string & deviceFilename) {
|
||||||
int allOK = 1;
|
int allOK;
|
||||||
|
|
||||||
if (myDisk == NULL) {
|
if (myDisk == NULL) {
|
||||||
myDisk = new DiskIO;
|
myDisk = new DiskIO;
|
||||||
@@ -355,7 +355,7 @@ int BasicMBRData::ReadLogicalParts(uint64_t extendedStart, int partNum) {
|
|||||||
// MBR itself and any defined logical partitions, provided there's an
|
// MBR itself and any defined logical partitions, provided there's an
|
||||||
// MBR extended partition.
|
// MBR extended partition.
|
||||||
int BasicMBRData::WriteMBRData(void) {
|
int BasicMBRData::WriteMBRData(void) {
|
||||||
int allOK = 1;
|
int allOK;
|
||||||
|
|
||||||
if (myDisk != NULL) {
|
if (myDisk != NULL) {
|
||||||
if (myDisk->OpenForWrite() != 0) {
|
if (myDisk->OpenForWrite() != 0) {
|
||||||
@@ -372,7 +372,7 @@ int BasicMBRData::WriteMBRData(void) {
|
|||||||
// Save the MBR data to a file. This writes both the
|
// Save the MBR data to a file. This writes both the
|
||||||
// MBR itself and any defined logical partitions.
|
// MBR itself and any defined logical partitions.
|
||||||
int BasicMBRData::WriteMBRData(DiskIO *theDisk) {
|
int BasicMBRData::WriteMBRData(DiskIO *theDisk) {
|
||||||
int i, j, partNum, next, allOK = 1, moreLogicals = 0;
|
int i, j, partNum, next, allOK, moreLogicals = 0;
|
||||||
uint64_t extFirstLBA = 0;
|
uint64_t extFirstLBA = 0;
|
||||||
uint64_t writeEbrTo; // 64-bit because we support extended in 2-4TiB range
|
uint64_t writeEbrTo; // 64-bit because we support extended in 2-4TiB range
|
||||||
TempMBR tempMBR;
|
TempMBR tempMBR;
|
||||||
@@ -948,7 +948,7 @@ int BasicMBRData::SpaceBeforeAllLogicals(void) {
|
|||||||
// primary status. Also does NOT consider partition order; there
|
// primary status. Also does NOT consider partition order; there
|
||||||
// can be gaps and it will still be considered legal.
|
// can be gaps and it will still be considered legal.
|
||||||
int BasicMBRData::IsLegal(void) {
|
int BasicMBRData::IsLegal(void) {
|
||||||
int allOK = 1;
|
int allOK;
|
||||||
|
|
||||||
allOK = (FindOverlaps() == 0);
|
allOK = (FindOverlaps() == 0);
|
||||||
allOK = (allOK && (NumPrimaries() <= 4));
|
allOK = (allOK && (NumPrimaries() <= 4));
|
||||||
@@ -1055,7 +1055,7 @@ void BasicMBRData::MakePart(int num, uint64_t start, uint64_t length, int type,
|
|||||||
// Set the partition's type code.
|
// Set the partition's type code.
|
||||||
// Returns 1 if successful, 0 if not (invalid partition number)
|
// Returns 1 if successful, 0 if not (invalid partition number)
|
||||||
int BasicMBRData::SetPartType(int num, int type) {
|
int BasicMBRData::SetPartType(int num, int type) {
|
||||||
int allOK = 1;
|
int allOK;
|
||||||
|
|
||||||
if ((num >= 0) && (num < MAX_MBR_PARTS)) {
|
if ((num >= 0) && (num < MAX_MBR_PARTS)) {
|
||||||
if (partitions[num].GetLengthLBA() != UINT32_C(0)) {
|
if (partitions[num].GetLengthLBA() != UINT32_C(0)) {
|
||||||
@@ -1308,7 +1308,7 @@ void BasicMBRData::MakeItLegal(void) {
|
|||||||
// entries (primary space).
|
// entries (primary space).
|
||||||
// Returns the number of partitions moved.
|
// Returns the number of partitions moved.
|
||||||
int BasicMBRData::RemoveLogicalsFromFirstFour(void) {
|
int BasicMBRData::RemoveLogicalsFromFirstFour(void) {
|
||||||
int i, j = 4, numMoved = 0, swapped = 0;
|
int i, j, numMoved = 0, swapped = 0;
|
||||||
MBRPart temp;
|
MBRPart temp;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
|
|||||||
4
bsd.cc
4
bsd.cc
@@ -44,7 +44,7 @@ BSDData::~BSDData(void) {
|
|||||||
// just opens the device file and then calls an overloaded function to do
|
// just opens the device file and then calls an overloaded function to do
|
||||||
// the bulk of the work. Returns 1 on success, 0 on failure.
|
// the bulk of the work. Returns 1 on success, 0 on failure.
|
||||||
int BSDData::ReadBSDData(const string & device, uint64_t startSector, uint64_t endSector) {
|
int BSDData::ReadBSDData(const string & device, uint64_t startSector, uint64_t endSector) {
|
||||||
int allOK = 1;
|
int allOK;
|
||||||
DiskIO myDisk;
|
DiskIO myDisk;
|
||||||
|
|
||||||
if (device != "") {
|
if (device != "") {
|
||||||
@@ -64,7 +64,7 @@ int BSDData::ReadBSDData(const string & device, uint64_t startSector, uint64_t e
|
|||||||
// Load the BSD disklabel data from an already-opened disk
|
// Load the BSD disklabel data from an already-opened disk
|
||||||
// file, starting with the specified sector number.
|
// file, starting with the specified sector number.
|
||||||
int BSDData::ReadBSDData(DiskIO *theDisk, uint64_t startSector, uint64_t endSector) {
|
int BSDData::ReadBSDData(DiskIO *theDisk, uint64_t startSector, uint64_t endSector) {
|
||||||
int allOK = 1;
|
int allOK;
|
||||||
int i, foundSig = 0, bigEnd = 0;
|
int i, foundSig = 0, bigEnd = 0;
|
||||||
int relative = 0; // assume absolute partition sector numbering
|
int relative = 0; // assume absolute partition sector numbering
|
||||||
uint8_t buffer[4096]; // I/O buffer
|
uint8_t buffer[4096]; // I/O buffer
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ int DiskIO::Read(void* buffer, int numBytes) {
|
|||||||
// size with the number of bytes read.
|
// size with the number of bytes read.
|
||||||
// Returns the number of bytes written.
|
// Returns the number of bytes written.
|
||||||
int DiskIO::Write(void* buffer, int numBytes) {
|
int DiskIO::Write(void* buffer, int numBytes) {
|
||||||
int blockSize = 512, i, numBlocks, retval = 0;
|
int blockSize, i, numBlocks, retval = 0;
|
||||||
char* tempSpace;
|
char* tempSpace;
|
||||||
|
|
||||||
// If disk isn't open, try to open it....
|
// If disk isn't open, try to open it....
|
||||||
|
|||||||
6
gpt.cc
6
gpt.cc
@@ -582,7 +582,7 @@ int GPTData::CheckHeaderCRC(struct GPTHeader* header, int warn) {
|
|||||||
// byte order and then undoes that reversal.)
|
// byte order and then undoes that reversal.)
|
||||||
void GPTData::RecomputeCRCs(void) {
|
void GPTData::RecomputeCRCs(void) {
|
||||||
uint32_t crc, hSize;
|
uint32_t crc, hSize;
|
||||||
int littleEndian = 1;
|
int littleEndian;
|
||||||
|
|
||||||
// If the header size is bigger than the GPT header data structure, reset it;
|
// If the header size is bigger than the GPT header data structure, reset it;
|
||||||
// otherwise, set both header sizes to whatever the main one is....
|
// otherwise, set both header sizes to whatever the main one is....
|
||||||
@@ -2144,7 +2144,6 @@ int GPTData::Align(uint64_t* sector) {
|
|||||||
// Check to see that every sector between the earlier one and the
|
// Check to see that every sector between the earlier one and the
|
||||||
// requested one is clear, and that it's not too early....
|
// requested one is clear, and that it's not too early....
|
||||||
if (earlier >= mainHeader.firstUsableLBA) {
|
if (earlier >= mainHeader.firstUsableLBA) {
|
||||||
sectorOK = 1;
|
|
||||||
testSector = earlier;
|
testSector = earlier;
|
||||||
do {
|
do {
|
||||||
sectorOK = IsFree(testSector++);
|
sectorOK = IsFree(testSector++);
|
||||||
@@ -2157,7 +2156,6 @@ int GPTData::Align(uint64_t* sector) {
|
|||||||
|
|
||||||
// If couldn't move the sector earlier, try to move it later instead....
|
// If couldn't move the sector earlier, try to move it later instead....
|
||||||
if ((sectorOK != 1) && (later <= mainHeader.lastUsableLBA)) {
|
if ((sectorOK != 1) && (later <= mainHeader.lastUsableLBA)) {
|
||||||
sectorOK = 1;
|
|
||||||
testSector = later;
|
testSector = later;
|
||||||
do {
|
do {
|
||||||
sectorOK = IsFree(testSector--);
|
sectorOK = IsFree(testSector--);
|
||||||
@@ -2454,7 +2452,7 @@ void GPTData::SetAlignment(uint32_t n) {
|
|||||||
// is used on big disks (as safety for Advanced Format drives).
|
// is used on big disks (as safety for Advanced Format drives).
|
||||||
// Returns the computed alignment value.
|
// Returns the computed alignment value.
|
||||||
uint32_t GPTData::ComputeAlignment(void) {
|
uint32_t GPTData::ComputeAlignment(void) {
|
||||||
uint32_t i = 0, found, exponent = 31;
|
uint32_t i = 0, found, exponent;
|
||||||
uint32_t align = DEFAULT_ALIGNMENT;
|
uint32_t align = DEFAULT_ALIGNMENT;
|
||||||
|
|
||||||
if (blockSize > 0)
|
if (blockSize > 0)
|
||||||
|
|||||||
@@ -437,7 +437,6 @@ void GPTDataCurses::MakeNewPart(void) {
|
|||||||
move(LINES - 4, 0);
|
move(LINES - 4, 0);
|
||||||
clrtobot();
|
clrtobot();
|
||||||
while ((newFirstLBA < currentSpace->firstLBA) || (newFirstLBA > currentSpace->lastLBA)) {
|
while ((newFirstLBA < currentSpace->firstLBA) || (newFirstLBA > currentSpace->lastLBA)) {
|
||||||
newFirstLBA = currentSpace->firstLBA;
|
|
||||||
move(LINES - 4, 0);
|
move(LINES - 4, 0);
|
||||||
clrtoeol();
|
clrtoeol();
|
||||||
newFirstLBA = currentSpace->firstLBA;
|
newFirstLBA = currentSpace->firstLBA;
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ void GPTDataTextUI::CreatePartition(void) {
|
|||||||
} while (IsFree(sector) == 0);
|
} while (IsFree(sector) == 0);
|
||||||
lastBlock = sector;
|
lastBlock = sector;
|
||||||
|
|
||||||
firstFreePart = GPTData::CreatePartition(partNum, firstBlock, lastBlock);
|
GPTData::CreatePartition(partNum, firstBlock, lastBlock);
|
||||||
partitions[partNum].ChangeType();
|
partitions[partNum].ChangeType();
|
||||||
partitions[partNum].SetDefaultDescription();
|
partitions[partNum].SetDefaultDescription();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ uint64_t GetSectorNum(uint64_t low, uint64_t high, uint64_t def, uint64_t sSize,
|
|||||||
// compiled with GCC (and so the value is rejected), whereas when VC++
|
// compiled with GCC (and so the value is rejected), whereas when VC++
|
||||||
// is used, the default value is returned.
|
// is used, the default value is returned.
|
||||||
uint64_t IeeeToInt(string inValue, uint64_t sSize, uint64_t low, uint64_t high, uint64_t def) {
|
uint64_t IeeeToInt(string inValue, uint64_t sSize, uint64_t low, uint64_t high, uint64_t def) {
|
||||||
uint64_t response = def, bytesPerUnit = 1, mult = 1, divide = 1;
|
uint64_t response = def, bytesPerUnit, mult = 1, divide = 1;
|
||||||
size_t foundAt = 0;
|
size_t foundAt = 0;
|
||||||
char suffix = ' ', plusFlag = ' ';
|
char suffix = ' ', plusFlag = ' ';
|
||||||
string suffixes = "KMGTPE";
|
string suffixes = "KMGTPE";
|
||||||
|
|||||||
Reference in New Issue
Block a user