From: Paul R. Eggert Date: Tue, 13 Jul 2010 00:12:43 +0000 (-0700) Subject: dd: also spell out size on memory exhaustion X-Git-Tag: v8.6~113 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=335b59b9625758f92ba82cd6b7138f7423df60ef;p=thirdparty%2Fcoreutils.git dd: also spell out size on memory exhaustion * src/dd.c (dd_copy): Use requested blocksize (not adjusted) in diagnostic, to forestall user complaints that the numbers don't match exactly. Report both exact and human-readable sizes, using a message format that is consistent with both "BBBB bytes (N XB) copied" in dd.c and "memory exhausted" in lib/xmalloc.c. --- diff --git a/src/dd.c b/src/dd.c index c9b8cbda48..ab8b84c220 100644 --- a/src/dd.c +++ b/src/dd.c @@ -1603,12 +1603,11 @@ dd_copy (void) It is necessary when accessing raw (i.e. character special) disk devices on Unixware or other SVR4-derived system. */ - size_t sz = input_blocksize + INPUT_BLOCK_SLOP; - real_buf = malloc (sz); + real_buf = malloc (input_blocksize + INPUT_BLOCK_SLOP); if (!real_buf) error (EXIT_FAILURE, 0, - _("failed to allocate an input buffer of size %s"), - human_size (sz)); + _("memory exhausted by input buffer of size %zu bytes (%s)"), + input_blocksize, human_size (input_blocksize)); ibuf = real_buf; ibuf += SWAB_ALIGN_OFFSET; /* allow space for swab */ @@ -1618,12 +1617,11 @@ dd_copy (void) if (conversions_mask & C_TWOBUFS) { /* Page-align the output buffer, too. */ - sz = output_blocksize + OUTPUT_BLOCK_SLOP; - real_obuf = malloc (sz); + real_obuf = malloc (output_blocksize + OUTPUT_BLOCK_SLOP); if (!real_obuf) error (EXIT_FAILURE, 0, - _("failed to allocate an output buffer of size %s"), - human_size (sz)); + _("memory exhausted by output buffer of size %zu bytes (%s)"), + output_blocksize, human_size (output_blocksize)); obuf = ptr_align (real_obuf, page_size); } else