From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11743 invoked by alias); 23 Apr 2009 20:45:41 -0000 Received: (qmail 11734 invoked by uid 22791); 23 Apr 2009 20:45:41 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 23 Apr 2009 20:45:35 +0000 Received: from brahms.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by brahms.sibelius.xs4all.nl (8.14.3/8.14.3) with ESMTP id n3NKimWI030178; Thu, 23 Apr 2009 22:44:48 +0200 (CEST) Received: (from kettenis@localhost) by brahms.sibelius.xs4all.nl (8.14.3/8.14.3/Submit) id n3NKimSD023708; Thu, 23 Apr 2009 22:44:48 +0200 (CEST) Date: Thu, 23 Apr 2009 20:45:00 -0000 Message-Id: <200904232044.n3NKimSD023708@brahms.sibelius.xs4all.nl> From: Mark Kettenis To: brobecker@adacore.com CC: mark.kettenis@xs4all.nl, gdb-patches@sourceware.org In-reply-to: <20090423203710.GH7552@adacore.com> (message from Joel Brobecker on Thu, 23 Apr 2009 13:37:10 -0700) Subject: Re: [RFA/commit] Handle EOF on terminals opened with ENONBLOCK... References: <20090423191446.GB7512@adacore.com> <200904231934.n3NJY7j7006691@brahms.sibelius.xs4all.nl> <20090423203710.GH7552@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-04/txt/msg00665.txt.bz2 > Date: Thu, 23 Apr 2009 13:37:10 -0700 > From: Joel Brobecker > > > I suppose the errno == EAGAIN is supposed to check whether fgetc() > > failed. However, your code has an ferror() in between, which could > > clobber errno. So perhaps it is better to reverse those checks. > > I did it in that order because I wanted to test the error condition > on the FILE before actually checking errno. The C99 draft that I have > does not say anything about errno, but the man page on my GNU/Linux > machine does say explicitly that errno doesn't get set during > a call to ferror. > > I can try reversing them, though... Let me know if you think I should. Hmm, looking at the OpenBSD and Solaris implementations of ferror(3), they both are just checking a flag. so what you currently have should be safe.