summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRod Smith <rodsmith@rodsbooks.com>2021-03-17 21:57:12 -0400
committerRod Smith <rodsmith@rodsbooks.com>2021-03-17 21:59:18 -0400
commiteae9f7e2e1470ed2d5bc029180aa2adc88fbc4a7 (patch)
treedd82bf5ca410609032f73fe888a56d9f29ee3c93
parent80e66b25922ab78cf987f693bf5477e466b1443a (diff)
downloadsgdisk-eae9f7e2e1470ed2d5bc029180aa2adc88fbc4a7.tar.gz
Code cleanup based on 'infer' suggestions; mostly just dead stores.
One forgotten change
-rw-r--r--basicmbr.cc12
-rw-r--r--bsd.cc4
-rw-r--r--diskio-unix.cc2
-rw-r--r--gpt.cc6
-rw-r--r--gptcurses.cc1
-rw-r--r--gpttext.cc2
-rw-r--r--support.cc2
7 files changed, 13 insertions, 16 deletions
diff --git a/basicmbr.cc b/basicmbr.cc
index c266e39..e09b0e9 100644
--- a/basicmbr.cc
+++ b/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++) {
diff --git a/bsd.cc b/bsd.cc
index f487f18..1ef7c81 100644
--- a/bsd.cc
+++ b/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
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 @@ 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....
diff --git a/gpt.cc b/gpt.cc
index 842dfb1..51d482c 100644
--- a/gpt.cc
+++ b/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)
diff --git a/gptcurses.cc b/gptcurses.cc
index 71aa734..1fbaad2 100644
--- a/gptcurses.cc
+++ b/gptcurses.cc
@@ -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;
diff --git a/gpttext.cc b/gpttext.cc
index ea34444..505f006 100644
--- a/gpttext.cc
+++ b/gpttext.cc
@@ -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 {
diff --git a/support.cc b/support.cc
index 88c130b..99fdffe 100644
--- a/support.cc
+++ b/support.cc
@@ -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";