summaryrefslogtreecommitdiff
path: root/gpt.cc
diff options
context:
space:
mode:
authorRod Smith <rodsmith@rodsbooks.com>2021-02-01 10:19:50 -0500
committerRod Smith <rodsmith@rodsbooks.com>2021-02-01 10:19:50 -0500
commitf063fe08e424c99f133df18bf9dce49c851bcb0a (patch)
treeb08fed3d2c7e4d9e2546f91fa757d8eb6c6e74a2 /gpt.cc
parent6180deb472c302c47f4d4acff8f2123d10824364 (diff)
downloadsgdisk-f063fe08e424c99f133df18bf9dce49c851bcb0a.tar.gz
Fix spurious warnings of problems on MBR disks
Diffstat (limited to 'gpt.cc')
-rw-r--r--gpt.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/gpt.cc b/gpt.cc
index 1b4e10f..842dfb1 100644
--- a/gpt.cc
+++ b/gpt.cc
@@ -1042,11 +1042,19 @@ int GPTData::LoadHeader(struct GPTHeader *header, DiskIO & disk, uint64_t sector
*crcOk = CheckHeaderCRC(&tempHeader);
if (tempHeader.sizeOfPartitionEntries != sizeof(GPTPart)) {
- cerr << "Warning: Partition table header claims that the size of partition table\n";
- cerr << "entries is " << tempHeader.sizeOfPartitionEntries << " bytes, but this program ";
- cerr << " supports only " << sizeof(GPTPart) << "-byte entries.\n";
- cerr << "Adjusting accordingly, but partition table may be garbage.\n";
- tempHeader.sizeOfPartitionEntries = sizeof(GPTPart);
+ // Print the below warning only if the CRC is OK -- but correct the
+ // problem either way. The warning is printed only on a valid CRC
+ // because otherwise this warning will display inappropriately when
+ // reading MBR disks. If the CRC is invalid, then a warning about
+ // that will be shown later, so the user will still know that
+ // something is wrong.
+ if (*crcOk) {
+ cerr << "Warning: Partition table header claims that the size of partition table\n";
+ cerr << "entries is " << tempHeader.sizeOfPartitionEntries << " bytes, but this program ";
+ cerr << " supports only " << sizeof(GPTPart) << "-byte entries.\n";
+ cerr << "Adjusting accordingly, but partition table may be garbage.\n";
+ }
+ tempHeader.sizeOfPartitionEntries = sizeof(GPTPart);
}
if (allOK && (numParts != tempHeader.numParts) && *crcOk) {