From 9b7f4fb44e888dde7c9d0e82300d275e8671769d Mon Sep 17 00:00:00 2001 From: Spiros Date: Thu, 22 May 2025 00:13:42 +0300 Subject: [PATCH] Parse Total LBAs for drives which seem to use Gigabytes --- src/mainwindow.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9765168..e935cc9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -554,7 +554,11 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal qlonglong lbaWritten = attrObj["raw"].toObject()["value"].toVariant().toLongLong(); qlonglong oneGB = static_cast(std::pow(2, 30)); qlonglong gigabytes = (lbaWritten * logicalBlockSize) / oneGB; - totalWritesInt = static_cast(gigabytes); + int gigabytesInt = static_cast(gigabytes); + if (!gigabytesInt) { + gigabytesInt = static_cast(lbaWritten); + } + totalWritesInt = gigabytesInt; } else if (attrObj["name"] == "Host_Writes_GiB" || attrObj["name"] == "Lifetime_Writes_GiB") { double gibibytes = attrObj["raw"].toObject()["value"].toDouble(); double bytesPerGiB = static_cast(1ULL << 30); @@ -575,7 +579,11 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal qlonglong lbaRead = attrObj["raw"].toObject()["value"].toVariant().toLongLong(); qlonglong oneGB = static_cast(std::pow(2, 30)); qlonglong gigabytes = (lbaRead * logicalBlockSize) / oneGB; - totalReadsInt = static_cast(gigabytes); + int gigabytesInt = static_cast(gigabytes); + if (!gigabytesInt) { + gigabytesInt = static_cast(lbaRead); + } + totalReadsInt = gigabytesInt; } else if (attrObj["name"] == "Host_Reads_GiB" || attrObj["name"] == "Lifetime_Reads_GiB") { double gibibytes = attrObj["raw"].toObject()["value"].toDouble(); double bytesPerGiB = static_cast(1ULL << 30);