Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!gatech!hao!boulder!forys From: forys@sigi.Colorado.EDU (Jeff Forys) Newsgroups: comp.unix.questions Subject: Re: Shutting lint up about malloc (missing /*NOSTRICT*/) Message-ID: <1117@sigi.Colorado.EDU> Date: Mon, 18-May-87 16:57:08 EDT Article-I.D.: sigi.1117 Posted: Mon May 18 16:57:08 1987 Date-Received: Tue, 19-May-87 04:44:25 EDT References: <61@amanue.UUCP> <1994@a.cs.okstate.edu> Reply-To: forys@boulder.Colorado.EDU (Jeff Forys) Organization: University of Colorado, Boulder Lines: 19 In article <1994@a.cs.okstate.edu> gregg@a.cs.okstate.edu (Gregg Wonderly) writes: > Try [casting the NULL pointer] making this > if ((p = (struct foo*) malloc(sizeof(struct foo))) == (struct foo *)NULL) { > (void) fprintf(stderr, "Out er memory, turkey\n"); > return NULL; > } > Comparing a structure pointer (namely p) against NULL (sometimes declared > as ((char *)0) is probably biting you. No, that's perfectly legal without casting NULL -- unless the C compiler is brain damaged (K&R, pg 98). The problem here is 2 fold: 1) His version of lint doesnt know that the C compiler will align pointers to differnt types (4.3BSD lint understands this). 2) the /*NOSTRICT*/ directive is probably not implemented in his version of lint (it's unimplemented in 4.3BSD as well). --- Jeff Forys @ UC/Boulder Engineering Research Comp Cntr (303-492-6096) forys@Boulder.Colorado.EDU -or- ..!{hao|nbires}!boulder!forys