[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] delaying dd allocation

From: Ondrej Oprala
Subject: Re: [PATCH] delaying dd allocation
Date: Thu, 11 Apr 2013 08:53:36 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4

On 04/10/2013 10:03 PM, Pádraig Brady wrote:
On 01/23/2013 10:48 AM, Ondrej Oprala wrote:
+  /* Delay buffer allocation if possible.  */
+  if ((skip_records > OFF_T_MAX / input_blocksize)
+      || 0 > skip_via_lseek (input_file, STDIN_FILENO, 0, SEEK_CUR))
+    alloc_ibuf ();
- /* Write a sentinel to the slop after the buffer,
-     to allow efficient checking for NUL blocks.  */
-  assert (sizeof (uintptr_t) <= OUTPUT_BLOCK_SLOP);
-  memset (obuf + output_blocksize, 1, sizeof (uintptr_t));
+  if ((seek_records > OFF_T_MAX / output_blocksize)
+      || 0 > skip_via_lseek (output_file, STDOUT_FILENO, 0, SEEK_CUR))
+    alloc_obuf ();
This doesn't look right.
skip_via_lseek() doesn't support lseek(..., 0, SEEK_CUR)
and may always warn for tape devices?
Also does skip bytes need to be considered?
Also you don't always need to allocate both buffers.

How about avoiding new conditions altogether and just
alloc_[io]buf() before they're needed
(i.e. closer to the read() as I suggested originally).

Also I adjusted the memory limits in the test,
to reduce the chances of false positives,
and bolstered the test cases to cater for the
new allocation calls within skip().

I'll push the attached soon.

Thanks for looking at this,
the changes seem great.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]