Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!bbn!papaya.bbn.com!rsalz From: rsalz@bbn.com (Rich Salz) Newsgroups: comp.lang.c Subject: Re: Question on ANSI C compatibility (really return values and errno) Message-ID: <244@papaya.bbn.com> Date: Thu, 19-Nov-87 17:23:54 EST Article-I.D.: papaya.244 Posted: Thu Nov 19 17:23:54 1987 Date-Received: Sun, 22-Nov-87 08:33:35 EST References: <10224@brl-adm.ARPA> <9272@mimsy.UUCP> <1804@geac.UUCP> <1761@haddock.ISC.COM> Reply-To: rsalz@bbn.com (Rich Salz) Organization: BBN Laboratories, Cambridge MA Lines: 15 Summary: Can't check errno unless syscall fails >This code is correct, but unavoidably generates a lint warning (though it can >be silenced with a (void) cast): > errno = 0; > unlink(fname); > if (errno != 0) abort(); Nope. You're not "allowed" (sic) to check errno unless you know that the call really failed. That is: if (unlink(fname) < 0 && errno == ENOPERM) perror("Try 'su'"), exit(1); is legal, albeit gross, code. I'll now step aside, and watch this degenerate into another isatty()/perror/ "not a typewriter" mudslide... /r$ -- For comp.sources.unix stuff, mail to sources@uunet.uu.net.