Code cleanup based on 'infer' suggestions; mostly just dead stores.
One forgotten change
diff --git a/basicmbr.cc b/basicmbr.cc
index c266e39..e09b0e9 100644
--- a/basicmbr.cc
+++ b/basicmbr.cc
@@ -140,7 +140,7 @@
// Read data from MBR. Returns 1 if read was successful (even if the
// data isn't a valid MBR), 0 if the read failed.
int BasicMBRData::ReadMBRData(const string & deviceFilename) {
- int allOK = 1;
+ int allOK;
if (myDisk == NULL) {
myDisk = new DiskIO;
@@ -355,7 +355,7 @@
// MBR itself and any defined logical partitions, provided there's an
// MBR extended partition.
int BasicMBRData::WriteMBRData(void) {
- int allOK = 1;
+ int allOK;
if (myDisk != NULL) {
if (myDisk->OpenForWrite() != 0) {
@@ -372,7 +372,7 @@
// Save the MBR data to a file. This writes both the
// MBR itself and any defined logical partitions.
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 writeEbrTo; // 64-bit because we support extended in 2-4TiB range
TempMBR tempMBR;
@@ -948,7 +948,7 @@
// primary status. Also does NOT consider partition order; there
// can be gaps and it will still be considered legal.
int BasicMBRData::IsLegal(void) {
- int allOK = 1;
+ int allOK;
allOK = (FindOverlaps() == 0);
allOK = (allOK && (NumPrimaries() <= 4));
@@ -1055,7 +1055,7 @@
// Set the partition's type code.
// Returns 1 if successful, 0 if not (invalid partition number)
int BasicMBRData::SetPartType(int num, int type) {
- int allOK = 1;
+ int allOK;
if ((num >= 0) && (num < MAX_MBR_PARTS)) {
if (partitions[num].GetLengthLBA() != UINT32_C(0)) {
@@ -1308,7 +1308,7 @@
// entries (primary space).
// Returns the number of partitions moved.
int BasicMBRData::RemoveLogicalsFromFirstFour(void) {
- int i, j = 4, numMoved = 0, swapped = 0;
+ int i, j, numMoved = 0, swapped = 0;
MBRPart temp;
for (i = 0; i < 4; i++) {
diff --git a/bsd.cc b/bsd.cc
index f487f18..1ef7c81 100644
--- a/bsd.cc
+++ b/bsd.cc
@@ -44,7 +44,7 @@
// 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.
int BSDData::ReadBSDData(const string & device, uint64_t startSector, uint64_t endSector) {
- int allOK = 1;
+ int allOK;
DiskIO myDisk;
if (device != "") {
@@ -64,7 +64,7 @@
// Load the BSD disklabel data from an already-opened disk
// file, starting with the specified sector number.
int BSDData::ReadBSDData(DiskIO *theDisk, uint64_t startSector, uint64_t endSector) {
- int allOK = 1;
+ int allOK;
int i, foundSig = 0, bigEnd = 0;
int relative = 0; // assume absolute partition sector numbering
uint8_t buffer[4096]; // I/O buffer
diff --git a/diskio-unix.cc b/diskio-unix.cc
index 4aefc6f..7780aeb 100644
--- a/diskio-unix.cc
+++ b/diskio-unix.cc
@@ -376,7 +376,7 @@
// size with the number of bytes read.
// Returns the number of bytes written.
int DiskIO::Write(void* buffer, int numBytes) {
- int blockSize = 512, i, numBlocks, retval = 0;
+ int blockSize, i, numBlocks, retval = 0;
char* tempSpace;
// If disk isn't open, try to open it....
diff --git a/gpt.cc b/gpt.cc
index 842dfb1..51d482c 100644
--- a/gpt.cc
+++ b/gpt.cc
@@ -582,7 +582,7 @@
// byte order and then undoes that reversal.)
void GPTData::RecomputeCRCs(void) {
uint32_t crc, hSize;
- int littleEndian = 1;
+ int littleEndian;
// 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....
@@ -2144,7 +2144,6 @@
// Check to see that every sector between the earlier one and the
// requested one is clear, and that it's not too early....
if (earlier >= mainHeader.firstUsableLBA) {
- sectorOK = 1;
testSector = earlier;
do {
sectorOK = IsFree(testSector++);
@@ -2157,7 +2156,6 @@
// If couldn't move the sector earlier, try to move it later instead....
if ((sectorOK != 1) && (later <= mainHeader.lastUsableLBA)) {
- sectorOK = 1;
testSector = later;
do {
sectorOK = IsFree(testSector--);
@@ -2454,7 +2452,7 @@
// is used on big disks (as safety for Advanced Format drives).
// Returns the computed alignment value.
uint32_t GPTData::ComputeAlignment(void) {
- uint32_t i = 0, found, exponent = 31;
+ uint32_t i = 0, found, exponent;
uint32_t align = DEFAULT_ALIGNMENT;
if (blockSize > 0)
diff --git a/gptcurses.cc b/gptcurses.cc
index 71aa734..1fbaad2 100644
--- a/gptcurses.cc
+++ b/gptcurses.cc
@@ -437,7 +437,6 @@
move(LINES - 4, 0);
clrtobot();
while ((newFirstLBA < currentSpace->firstLBA) || (newFirstLBA > currentSpace->lastLBA)) {
- newFirstLBA = currentSpace->firstLBA;
move(LINES - 4, 0);
clrtoeol();
newFirstLBA = currentSpace->firstLBA;
diff --git a/gpttext.cc b/gpttext.cc
index ea34444..505f006 100644
--- a/gpttext.cc
+++ b/gpttext.cc
@@ -251,7 +251,7 @@
} while (IsFree(sector) == 0);
lastBlock = sector;
- firstFreePart = GPTData::CreatePartition(partNum, firstBlock, lastBlock);
+ GPTData::CreatePartition(partNum, firstBlock, lastBlock);
partitions[partNum].ChangeType();
partitions[partNum].SetDefaultDescription();
} else {
diff --git a/support.cc b/support.cc
index 88c130b..99fdffe 100644
--- a/support.cc
+++ b/support.cc
@@ -154,7 +154,7 @@
// compiled with GCC (and so the value is rejected), whereas when VC++
// 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 response = def, bytesPerUnit = 1, mult = 1, divide = 1;
+ uint64_t response = def, bytesPerUnit, mult = 1, divide = 1;
size_t foundAt = 0;
char suffix = ' ', plusFlag = ' ';
string suffixes = "KMGTPE";