aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2012-05-28 15:37:43 +0300
committerLasse Collin <lasse.collin@tukaani.org>2012-05-28 15:37:43 +0300
commit7769ea051d739a38a1640fd448cf5eb83cb119c6 (patch)
tree0c4f34485822fa821343c80468a388033f900f59 /src
parentxz: Document the "summary" lines of --robot -lvv. (diff)
downloadxz-7769ea051d739a38a1640fd448cf5eb83cb119c6.tar.xz
xz: Don't show a huge number in -vv when memory limit is disabled.
Diffstat (limited to 'src')
-rw-r--r--src/xz/message.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/xz/message.c b/src/xz/message.c
index e5591994..2b6ac5f0 100644
--- a/src/xz/message.c
+++ b/src/xz/message.c
@@ -859,6 +859,17 @@ message_mem_needed(enum message_verbosity v, uint64_t memusage)
// the user might need to +1 MiB to get high enough limit.)
memusage = round_up_to_mib(memusage);
+ uint64_t memlimit = hardware_memlimit_get(opt_mode);
+
+ // Handle the case when there is no memory usage limit.
+ // This way we don't print a weird message with a huge number.
+ if (memlimit == UINT64_MAX) {
+ message(v, _("%s MiB of memory is required. "
+ "The limiter is disabled."),
+ uint64_to_str(memusage, 0));
+ return;
+ }
+
// With US-ASCII:
// 2^64 with thousand separators + " MiB" suffix + '\0' = 26 + 4 + 1
// But there may be multibyte chars so reserve enough space.
@@ -867,7 +878,6 @@ message_mem_needed(enum message_verbosity v, uint64_t memusage)
// Show the memory usage limit as MiB unless it is less than 1 MiB.
// This way it's easy to notice errors where one has typed
// --memory=123 instead of --memory=123MiB.
- uint64_t memlimit = hardware_memlimit_get(opt_mode);
if (memlimit < (UINT32_C(1) << 20)) {
snprintf(memlimitstr, sizeof(memlimitstr), "%s B",
uint64_to_str(memlimit, 1));