[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-hackers] [PATCH] Handle EINTR properly in getc()
From: |
John Cowan |
Subject: |
Re: [Chicken-hackers] [PATCH] Handle EINTR properly in getc() |
Date: |
Wed, 3 Oct 2012 17:12:26 -0400 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Peter Bex scripsit:
> It turns out that errno is *not* cleared in between calls,
This is a general principle of Posix programming: you MUST NOT examine
errno unless you already know you have an error, whether by a -1 return,
or by a -1 return plus a call to ferror().
> + return (errno == EINTR && !feof(fp)) ? C_fix(-1) : C_SCHEME_END_OF_FILE;
I recommend (ferror(fp) && errno == EINTR) instead. It's clearer to use
ferror() rather than !feof(), and the opposite order is more natural:
make sure there is an error, then check what error it is. This applies
to all uses of !feof() in this patch.
--
Not to perambulate John Cowan <address@hidden>
the corridors http://www.ccil.org/~cowan
during the hours of repose
in the boots of ascension. --Sign in Austrian ski-resort hotel