From 65e100d19625df4298405ca4151c09da1629ec38 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Mon, 16 Mar 2026 23:44:25 +0100 Subject: [PATCH] review --- lib/hal/HalStorage.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/hal/HalStorage.cpp b/lib/hal/HalStorage.cpp index ed21eb37..63f469ed 100644 --- a/lib/hal/HalStorage.cpp +++ b/lib/hal/HalStorage.cpp @@ -81,7 +81,12 @@ uint64_t HalStorage::sdUsedBytes() const { return (clusterCount - cappedFreeClusters) * bytesPerCluster; } -uint64_t HalStorage::sdFreeBytes() const { return sdTotalBytes() - sdUsedBytes(); } +uint64_t HalStorage::sdFreeBytes() const { + uint64_t total = sdTotalBytes(); + uint64_t used = sdUsedBytes(); + if (total <= used) return 0; + return total - used; +} class HalFile::Impl { public: