Re: full_read depends on incoming errno

2013-02-21 Thread Eli Zaretskii
> Date: Thu, 21 Feb 2013 09:39:50 -0800 > From: Paul Eggert > CC: Andy Wingo , bonz...@gnu.org, bug-gnulib@gnu.org > > On 02/21/13 09:36, Eli Zaretskii wrote: > >> Otherwise, full_read sets errno to 0 if it returns a length less than > >> > the length we asked for > > Where does it do that? I do

Re: full_read depends on incoming errno

2013-02-21 Thread Paul Eggert
On 02/21/13 09:36, Eli Zaretskii wrote: >> Otherwise, full_read sets errno to 0 if it returns a length less than >> > the length we asked for > Where does it do that? I don't think I see this. Maybe I'm blind. No, it's just hard to see. It's the line "errno = ZERO_BYTE_TRANSFER_ERRNO;" in full-

Re: full_read depends on incoming errno

2013-02-21 Thread Eli Zaretskii
> From: Andy Wingo > Cc: Eli Zaretskii , egg...@cs.ucla.edu, bug-gnulib@gnu.org > Date: Thu, 21 Feb 2013 17:47:43 +0100 > > On Thu 21 Feb 2013 17:29, Paolo Bonzini writes: > > > Il 20/02/2013 20:58, Andy Wingo ha scritto: > >> > >> if (full_read (fd, cookie, sizeof cookie) != sizeof cook

Re: full_read depends on incoming errno

2013-02-21 Thread Paul Eggert
On 02/21/13 09:16, Paolo Bonzini wrote: > I think usually errno is undefined for return values other than -1 That's true for system calls, but full_read is different in that it sets errno whenever it returns a value other than the requested size. That way, the caller can distinguish a short read

Re: full_read depends on incoming errno

2013-02-21 Thread Paolo Bonzini
Il 21/02/2013 17:47, Andy Wingo ha scritto: >> > Doesn't it need to set errno to zero before calling full_read? > Not sure! If full_read requires that errno be 0 going in, then yes, we > should. Is this a requirement? Hmm, I think usually errno is undefined for return values other than -1, so ne

Re: full_read depends on incoming errno

2013-02-21 Thread Andy Wingo
On Thu 21 Feb 2013 17:29, Paolo Bonzini writes: > Il 20/02/2013 20:58, Andy Wingo ha scritto: >> >> if (full_read (fd, cookie, sizeof cookie) != sizeof cookie >> || full_read (fd, SCM_BYTEVECTOR_CONTENTS (bv), >> SCM_BYTEVECTOR_LENGTH (bv)) != SCM_BYTEVECTOR_LEN

Re: full_read depends on incoming errno

2013-02-21 Thread Paolo Bonzini
Il 20/02/2013 20:58, Andy Wingo ha scritto: > > if (full_read (fd, cookie, sizeof cookie) != sizeof cookie > || full_read (fd, SCM_BYTEVECTOR_CONTENTS (bv), > SCM_BYTEVECTOR_LENGTH (bv)) != SCM_BYTEVECTOR_LENGTH > (bv)) > { > int errno_save = errno;

Re: full_read depends on incoming errno

2013-02-20 Thread Andy Wingo
On Wed 20 Feb 2013 20:02, Eli Zaretskii writes: > Btw, it might be a good idea to provide some application-level > diagnostics in this specific case, since "No error", which corresponds > to errno = 0, is not very useful. I pushed this: if (full_read (fd, cookie, sizeof cookie) != sizeof co

Re: full_read depends on incoming errno

2013-02-20 Thread Eli Zaretskii
> From: Andy Wingo > Cc: egg...@cs.ucla.edu, bug-gnulib@gnu.org > Date: Wed, 20 Feb 2013 20:58:13 +0100 > > if (full_read (fd, cookie, sizeof cookie) != sizeof cookie > || full_read (fd, SCM_BYTEVECTOR_CONTENTS (bv), > SCM_BYTEVECTOR_LENGTH (bv)) != SCM_BYTEVECT

Re: full_read depends on incoming errno

2013-02-20 Thread Eli Zaretskii
> From: Andy Wingo > Cc: Eli Zaretskii , bug-gnulib@gnu.org > Date: Tue, 19 Feb 2013 22:50:18 +0100 > > >> I think it's a Guile > >> problem, since from gnulib POV, nothing went wrong in that call. > > > > Yes, that sounds right. > > You are both right, yes. Thanks for the help and sorry for t

Re: full_read depends on incoming errno

2013-02-19 Thread Eli Zaretskii
> Date: Tue, 19 Feb 2013 12:19:38 -0800 > From: Paul Eggert > CC: bug-gnulib , Eli Zaretskii > > On 02/19/13 11:05, Andy Wingo wrote: > > We use full_read in Guile and just got a bug report that full_read was > > depending on the incoming errno. > > Sorry, I don't see the bug here. The calling

Re: full_read depends on incoming errno

2013-02-19 Thread Andy Wingo
Hi, On Tue 19 Feb 2013 22:25, Paul Eggert writes: > On 02/19/13 13:15, Eli Zaretskii wrote: >> if (full_read (fd, cookie, sizeof cookie) != sizeof cookie >> || full_read (fd, SCM_BYTEVECTOR_CONTENTS (bv), >>SCM_BYTEVECTOR_LENGTH (bv)) != SCM_BYTEVECTOR_LENGTH (bv)) >

Re: full_read depends on incoming errno

2013-02-19 Thread Paul Eggert
On 02/19/13 13:15, Eli Zaretskii wrote: > if (full_read (fd, cookie, sizeof cookie) != sizeof cookie > || full_read (fd, SCM_BYTEVECTOR_CONTENTS (bv), > SCM_BYTEVECTOR_LENGTH (bv)) != SCM_BYTEVECTOR_LENGTH (bv)) > { > int errno_save = errno; > (vo

Re: full_read depends on incoming errno

2013-02-19 Thread Paul Eggert
On 02/19/13 11:05, Andy Wingo wrote: > We use full_read in Guile and just got a bug report that full_read was > depending on the incoming errno. Sorry, I don't see the bug here. The calling code should look like this: size_t r = full_read (fd, buf, n); if (r != n) { if (errno

full_read depends on incoming errno

2013-02-19 Thread Andy Wingo
Hi, We use full_read in Guile and just got a bug report that full_read was depending on the incoming errno. Eli Zaretskii proposed that the fix be like this: > +errno = 0; > if (full_read (fd, cookie, sizeof cookie) != sizeof cookie [...] To recall, safe_read (called by full_read) look