This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [rfa] Add the bfd_iovec
Andrew Cagney <cagney@gnu.org> writes:
> > Andrew Cagney <cagney@gnu.org> writes:
> >
> >>>> > * I'm not crazy about the berror entry point. Right now it is used in
> >>>> > exactly one place, to indicate whether a short read is an error or
> >>>> > simply a truncated file. Since bfd_iovec is only going to be called
> >>>> > by BFD routines, I think it would be quite reasonable to make the
> >>>> > bread entry point responsible for calling bfd_set_error. Then the
> >>>> > caller does not need to go back in to find out what a short read
> >>>> > means. Note also that berror is the only function which doesn't
> >>>> > have an obvious mapping to a Unix system call.
> >>
> >>> There are three cases here:
> >>> - error
> >>> - eof
> >>> - partial read (as in the next read should yield more data)
> >>> I guess BFD isn't set up for partial transfers and retrys so the
> >>> third
> >>> case doesn't apply?
> > Yes. Or, to put it another way, the bread routine should be
> > responsible for handling partial reads, if they are possible for the
> > underlying I/O structure.
>
> Which leads to the next question, what should that return value be?
> read(2) or fread(3) or ??? semantics? At present it is system
> dependant (see the #ifdef code in cache_bread in my patch).
I would say that it should be whatever seems most useful. Probably it
should return number of bytes read, or -1 on error, with a short count
indicating EOF.
As you say, the return value of the current real_read() differs in the
error case. That is a lurking bug. It happens to not matter at
present, given the way the return value is used in the only call.
Ian