Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!yetti!geac!daveb From: daveb@geac.UUCP Newsgroups: comp.lang.c Subject: Re: Question on ANSI C compatibility Message-ID: <1804@geac.UUCP> Date: Wed, 11-Nov-87 10:48:42 EST Article-I.D.: geac.1804 Posted: Wed Nov 11 10:48:42 1987 Date-Received: Fri, 13-Nov-87 06:33:21 EST References: <10224@brl-adm.ARPA> <9272@mimsy.UUCP> Reply-To: daveb@geac.UUCP (Dave Collier-Brown) Organization: The little blue rock next to that twinkly star. Lines: 47 In article <9272@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: | Some functions never return errors: strcpy, for instance, copies | its second argument on top of its first, then returns its first. | `(void) strcpy(to, from)' is only interesting if you have not | saved `to' anywhere else: | ... | Unfortunately, there is no (standard) way to distinguish between | functions with `interesting' values and those with `dull' values. | Indeed, in 4BSD there is no way at all; this is something I intend | to change. It looks as though it will be fairly easy to add to | lint a new pragma: | | ... | double atof(s) char *s; { return (0.0); } | int strlen(s) char *s; { return (1); } | /* DULLVALUE */ | char *strcpy(to, from) char *to, *from; { return (to); } | ... There are several (methinks five) disjoint sets of return values: 1) functions which return 0 or ERR (-1). 2) functions which return NULL or a valid string. 3) functions which return EOF (-1) or a valid character. 4) functions which return a valid positive char/int or a negative char/int as a specific error indication. 5) functions which return a boolean value (0 or non-zero). They also may affect errno: type (1) almost always does, (2) and (3) sometimes do. Any function which sets errno is a candidate for (a) dullness and (b) order-of-error related bugs [ie, "not a typewriter"]. Types (2) through (5) sound like they're not dull, but [fs]printf is a member of (4), sorta. Can we come up with a criteria for "dullness" which lint can infer by itself? if necessary from the presence of "extern int errno; return ERR" in a lintlibrary entry? Or can someone suggest a better/more-general way? --dave -- David Collier-Brown. {mnetor|yetti|utgpu}!geac!daveb Geac Computers International Inc., | Computer Science loses its 350 Steelcase Road,Markham, Ontario, | memory (if not its mind) CANADA, L3R 1B3 (416) 475-0525 x3279 | every 6 months.