Re: [PATCH v2 2/4] csum-file.h: increase hashfile buffer size

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

 



On Tue, May 18, 2021 at 03:31:28AM -0400, Jeff King wrote:

> Does this have to use the same-size buffer? We could read and check
> smaller chunks, like:
> 
>   while (count > 0) {
> 	static unsigned char chunk[1024];
> 	unsigned int chunk_len = sizeof(chunk) < count ? sizeof(chunk) : count;
> 	ssize_t ret = read_in_full(f->check_fd, chunk, chunk_len);
> 
> 	if (ret < 0)
> 	   ...
> 	if (ret != count)
> 	   ...
> 	if (memcmp(buf, chunk, chunk_len))
> 	   ...
> 	buf += chunk_len;
> 	count -= chunk_len;
>   }

That should be "ret != chunk_len" in the middle conditional, of course.
In case you do go this route (I typed this straight into my email, so
other bugs may be lurking. But I noticed that one. :) ).

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux