From d56374e4b9018eb86fd351a35f2d42187ed8aa99 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 16 Mar 2017 12:42:44 +0100 Subject: [PATCH] base: handle 0 in Number_of_bytes::print This patch avoids printing the number 0 as "0G". --- repos/base/include/util/string.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repos/base/include/util/string.h b/repos/base/include/util/string.h index 4f2e991689..17f5059d1e 100644 --- a/repos/base/include/util/string.h +++ b/repos/base/include/util/string.h @@ -58,7 +58,8 @@ class Genode::Number_of_bytes enum { KB = 1024UL, MB = KB*1024UL, GB = MB*1024UL }; - if (_n % GB == 0) print(output, _n/GB, "G"); + if (_n == 0) print(output, 0); + else if (_n % GB == 0) print(output, _n/GB, "G"); else if (_n % MB == 0) print(output, _n/MB, "M"); else if (_n % KB == 0) print(output, _n/KB, "K"); else print(output, _n);