Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For HD Product name, use GiB unit from 10,000 Mib and higher. #1147

Merged
merged 2 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cpp/devices/scsihd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ string SCSIHD::GetProductData() const
uint64_t capacity = GetBlockCount() * GetSectorSizeInBytes();
string unit;

// 10 GiB and more
if (capacity >= 1'099'511'627'776) {
capacity /= 1'099'511'627'776;
// 10,000 MiB and more
if (capacity >= 10'485'760'000) {
capacity /= 1'073'741'824;
unit = "GiB";
}
// 1 MiB and more
Expand Down
4 changes: 2 additions & 2 deletions cpp/test/scsihd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ TEST(ScsiHdTest, GetProductData)

hd_gb.SetFilename(string(filename));
hd_gb.SetSectorSizeInBytes(1024);
hd_gb.SetBlockCount(1'099'511'627'776 / 1024);
hd_gb.SetBlockCount(10'737'418'240 / 1024);
hd_gb.FinalizeSetup(0);
s = hd_gb.GetProduct();
EXPECT_NE(string::npos, s.find("1 GiB"));
EXPECT_NE(string::npos, s.find("10 GiB"));
remove(filename);
}

Expand Down