coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] delaying dd allocation


From: Pádraig Brady
Subject: Re: [PATCH] delaying dd allocation
Date: Wed, 10 Apr 2013 21:03:12 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

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,
Pádraig.

Attachment: dd-avoid-alloc.patch
Description: Text Data


reply via email to

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