diff --git a/src/apps/drivesetup/CreateParamsPanel.cpp b/src/apps/drivesetup/CreateParamsPanel.cpp index 251da5ca0c..0ac94be003 100644 --- a/src/apps/drivesetup/CreateParamsPanel.cpp +++ b/src/apps/drivesetup/CreateParamsPanel.cpp @@ -78,6 +78,11 @@ CreateParamsPanel::CreateParamsPanel(BWindow* window, off_t offset, off_t size) fReturnValue(GO_CANCELED) { AddCommonFilter(fEscapeFilter); + + // Scale offset, and size from bytes to megabytes (2^20) + // so that we do not run over a signed int32. + offset /= kMegaByte; + size /= kMegaByte; _CreateViewControls(offset, size); } @@ -156,7 +161,8 @@ CreateParamsPanel::Go(off_t& offset, off_t& size, BString& type) _type = "BFS Filesystem"; type << _type; } - size = fSizeSlider->Value(); + // Return the value back as bytes. + size = (off_t)fSizeSlider->Value() * kMegaByte; } int32 value = fReturnValue; diff --git a/src/apps/drivesetup/Support.cpp b/src/apps/drivesetup/Support.cpp index 6d8f6982c2..87357a9712 100644 --- a/src/apps/drivesetup/Support.cpp +++ b/src/apps/drivesetup/Support.cpp @@ -6,6 +6,7 @@ * Erik Jaesler * Ithamar R. Adema * Stephan Aßmus + * Bryce Groff */ #include "Support.h" @@ -16,9 +17,6 @@ #include -uint32 kMegaByte = 1048576; - - const char* string_for_size(off_t size, char *string) { @@ -124,8 +122,10 @@ SizeSlider::SizeSlider(const char* name, const char* label, { SetBarColor((rgb_color){ 0, 80, 255, 255 }); BString offset, size; - offset << fOffset / kMegaByte; offset << " MB"; - size << fSize / kMegaByte; size << " MB"; + offset << fOffset; + offset << " MB"; + size << fSize; + size << " MB"; SetLimitLabels(offset.String(), size.String()); } @@ -139,7 +139,7 @@ const char* SizeSlider::UpdateText() const { fStatusLabel.Truncate(0); - fStatusLabel << (Value() / kMegaByte); + fStatusLabel << Value(); fStatusLabel << " MB"; return fStatusLabel.String(); diff --git a/src/apps/drivesetup/Support.h b/src/apps/drivesetup/Support.h index 4fa5650eb6..adf7287d9f 100644 --- a/src/apps/drivesetup/Support.h +++ b/src/apps/drivesetup/Support.h @@ -27,6 +27,9 @@ enum { GO_SUCCESS }; + +static const uint32 kMegaByte = 1048576; + class SpaceIDMap : public HashMap { public: SpaceIDMap();