From owner-freebsd-hackers Mon Jun 26 8:51: 2 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from bedrock.hboc.com (hboc.com [139.177.224.128]) by hub.freebsd.org (Postfix) with SMTP id 2983837B972 for ; Mon, 26 Jun 2000 08:50:46 -0700 (PDT) (envelope-from Peter.Bohne@hboc.com) Received: from moosehead.hboc.com by bedrock.hboc.com via smtpd (for hub.FreeBSD.ORG [204.216.27.18]) with SMTP; 26 Jun 2000 15:50:45 UT Received: from SMTP (msteal.hboc.com [192.168.0.19]) by mrcheatem.hboc.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2448.0) id KJGFHZNQ; Mon, 26 Jun 2000 11:49:20 +0100 Received: from dmz.hboc.com ([139.177.6.114]) by 192.168.0.19 (Norton AntiVirus for Internet Email Gateways 1.0) ; Mon, 26 Jun 2000 15:51:51 0000 (GMT) Received: from atlexc90nthub.hboc.com by dmz.hboc.com via smtpd (for wildgoose.hboc.com [192.168.0.19]) with SMTP; 26 Jun 2000 15:50:32 UT Received: by atlexc90nthub.hboc.com with Internet Mail Service (5.5.2448.0) id ; Mon, 26 Jun 2000 11:49:56 -0400 Message-ID: <35BEC7ED0A15D21199F000805F6F6D6A01CB00F4@bldexc01ntms.clinicom.com> From: "Bohne, Peter" To: 'Chuck Robey' Cc: hackers@FreeBSD.ORG Subject: RE: libc_r/_read(), should the errno be reset to 0? Date: Mon, 26 Jun 2000 11:50:04 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG My interest here was mainly to convey the fact that errno is not automatically reset to 0. I agree that there should be no need to check it if your system call succeeds. No arguments there. The original poster's question, however, was inquiring about an automatic reset of errno. In general, I've always held it to be good policy to reset errno before I make a call that can modify it if I plan to check it after the call. Regardless of OS - FreeBSD, HP-UX, AIX, what have you. pete > -----Original Message----- > From: Chuck Robey [mailto:chuckr@picnic.mat.net] > Sent: Saturday, June 24, 2000 10:28 PM > To: Bohne, Peter > Cc: 'FengYue'; 'andrew@ugh.net.au'; hackers@FreeBSD.ORG > Subject: RE: libc_r/_read(), should the errno be reset to 0? > > > On Fri, 23 Jun 2000, Bohne, Peter wrote: > > > True enough. That's the best advice. However, your > original post indicated > > an expectation on your part that errno would be somehow > automatically reset > > to 0 before a system call, which is definitely *not* the > case. You have to > > clear it - the kernel does not do it for you. > > Why would you bother to clear it? You don't check errno to determine > fail/success, you check the function return. If it returns fail, then > errno is going to be correct whether or not you bothered to > reset it or > not. Setting it to zero might give you a warm fuzzy feeling, but if > you're correctly detected errors, it's not going to change anything. > > If anyone is detecting the value of errno as an indication of > pass/fail, > they're going to be disappointed. > > > > > pete > > > > > -----Original Message----- > > > From: FengYue [mailto:fengyue@bluerose.windmoon.nu] > > > Sent: Friday, June 23, 2000 11:08 AM > > > To: Bohne, Peter > > > Cc: 'andrew@ugh.net.au'; hackers@FreeBSD.ORG > > > Subject: RE: libc_r/_read(), should the errno be reset to 0? > > > > > > > > > > > > Wait, that's not going to do anything, the errno is set inside the > > > _thread_sys_read(). But I agree with Andrew, why bother to check > > > errno if read() returns no error. > > > > > > On Fri, 23 Jun 2000, Bohne, Peter wrote: > > > > > > > This means that *you* should set errno to 0 just before you > > > do the read > > > > call. At this point, you no longer care what it had > been before. > > > > -- > > > > pete > > > > > > > > ====== pbohne at hboc dot com > > > > Peter Bohne -- McKessonHBOC -- Louisville, CO > > > > Work: 303-926-2218 -- Cell: 303-817-8312 -- Home Ofc: > 970-586-9031 > > > > ====== "Very funny, Scottie. Now beam down my clothes!" > > > > > > > > > > > > > > > > > -----Original Message----- > > > > > From: andrew@ugh.net.au [mailto:andrew@ugh.net.au] > > > > > Sent: Friday, June 23, 2000 3:02 AM > > > > > To: FengYue > > > > > Cc: hackers@FreeBSD.ORG > > > > > Subject: Re: libc_r/_read(), should the errno be reset to 0? > > > > > > > > > > > > > > > > > > > > > > > > > On Fri, 23 Jun 2000, FengYue wrote: > > > > > > > > > > > My question is, shouldn't it be reset to zero? > > > > > > > > > > From intro(2): > > > > > > > > > > Successful calls never set errno; once set, it remains until > > > > > another error > > > > > occurs. It should only be examined after an error. > > > > > > > > > > Andrew > > > > > > > > > > > > > > > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > > > > with "unsubscribe freebsd-hackers" in the body of the message > > > > > > > > > > > > > > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > with "unsubscribe freebsd-hackers" in the body of the message > > > > -------------------------------------------------------------- > -------------- > Chuck Robey | Interests include C & Java > programming, FreeBSD, > chuckr@picnic.mat.net | electronics, communications, and > signal processing. > > New Year's Resolution: I will not sphroxify gullible people > into looking up > fictitious words in the dictionary. > -------------------------------------------------------------- > -------------- > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message