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
|
||||
// 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 @@ int BasicMBRData::ReadLogicalParts(uint64_t extendedStart, int partNum) {
|
||||
// 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 @@ int BasicMBRData::WriteMBRData(void) {
|
||||
// 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 @@ int BasicMBRData::SpaceBeforeAllLogicals(void) {
|
||||
// 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 @@ void BasicMBRData::MakePart(int num, uint64_t start, uint64_t length, int type,
|
||||
// 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 @@ void BasicMBRData::MakeItLegal(void) {
|
||||
// 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++) {
|
||||
|
||||
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
|
||||
// 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 @@ int BSDData::ReadBSDData(const string & device, uint64_t startSector, uint64_t e
|
||||
// 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
|
||||
|
||||
@@ -376,7 +376,7 @@ int DiskIO::Read(void* buffer, int numBytes) {
|
||||
// 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....
|
||||
|
||||
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.)
|
||||
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 @@ int GPTData::Align(uint64_t* sector) {
|
||||
// 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 @@ int GPTData::Align(uint64_t* sector) {
|
||||
|
||||
// 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 @@ void GPTData::SetAlignment(uint32_t n) {
|
||||
// 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)
|
||||
|
||||
@@ -437,7 +437,6 @@ void GPTDataCurses::MakeNewPart(void) {
|
||||
move(LINES - 4, 0);
|
||||
clrtobot();
|
||||
while ((newFirstLBA < currentSpace->firstLBA) || (newFirstLBA > currentSpace->lastLBA)) {
|
||||
newFirstLBA = currentSpace->firstLBA;
|
||||
move(LINES - 4, 0);
|
||||
clrtoeol();
|
||||
newFirstLBA = currentSpace->firstLBA;
|
||||
|
||||
@@ -251,7 +251,7 @@ void GPTDataTextUI::CreatePartition(void) {
|
||||
} while (IsFree(sector) == 0);
|
||||
lastBlock = sector;
|
||||
|
||||
firstFreePart = GPTData::CreatePartition(partNum, firstBlock, lastBlock);
|
||||
GPTData::CreatePartition(partNum, firstBlock, lastBlock);
|
||||
partitions[partNum].ChangeType();
|
||||
partitions[partNum].SetDefaultDescription();
|
||||
} 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++
|
||||
// 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";
|
||||
|
||||
Reference in New Issue
Block a user