This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA/cache.c] large fread fails on NetApp share...


Hi Nick,

On Wed, Apr 30, 2008 at 08:19:54AM +0100, Nick Clifton wrote:
> Hi Joel,
> 
> >2008-04-29  Joel Brobecker  <brobecker@adacore.com>
> >
> >        * cache.c (cache_bread_1): Renames cache_bread.
> >        (cache_bread): New function.
> 
> A reasonable idea, but I think that there is a bug:
> 
> >+      chunk_nread = cache_bread_1 (abfd, buf + nread, chunk_size);
> >+      nread += chunk_nread;
> >+
> >+      if (chunk_nread < chunk_size)
> >+        break;
> >+    }
> >+
> >+  return nread;
> 
> If cache_bread_1() returns -1 for a read after the first chunk then 
> cache_bread() will return one less byte than was actually read.  Hardly 
> world shattering I agree, but it would nice to see this corner case 
> handled correctly.

Argh! You are right, I completely missed the case when cache_bread_1
would return a negative value. Thanks for catching this. I think
the following patch should work better.

2008-04-30  Joel Brobecker  <brobecker@adacore.com>

        * cache.c (cache_bread_1): Renames cache_bread.
        (cache_bread): New function.

Tested similarly as before (gdb testsuite, max_chunk_size set to 0x100
and 8MB).

-- 
Joel

Attachment: cache.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]