On Wed, Jun 11, 2008 at 11:58:39AM +1000, David Gibson wrote: > Scott's original patch does still have some implementation details I > didn't like. So in the interests of saving time, I've addressed some > of those, added a testcase, and and now resubmitting my revised > version of Scott's patch.
Acked-by: Scott Wood <[EMAIL PROTECTED]> > -struct data data_copy_file(FILE *f, size_t len) > +struct data data_copy_file(FILE *f, size_t maxlen) > { > - struct data d; > + struct data d = empty_data; > + > + while (!feof(f) && (d.len < maxlen)) { > + size_t chunksize, ret; > + > + if (maxlen == -1) > + chunksize = 4096; > + else > + chunksize = maxlen - d.len; > + > + d = data_grow_for(d, chunksize); > + ret = fread(d.val + d.len, 1, chunksize, f); > + > + if (ferror(f)) > + die("Error reading file into data: %s", > strerror(errno)); It'd be nice if we could keep the filename around for reporting here... -Scott _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev