Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: Shutting lint up about malloc (missing /*NOSTRICT*/) Message-ID: <6735@mimsy.UUCP> Date: Mon, 18-May-87 14:41:22 EDT Article-I.D.: mimsy.6735 Posted: Mon May 18 14:41:22 1987 Date-Received: Tue, 19-May-87 04:55:51 EDT References: <61@amanue.UUCP> <1994@a.cs.okstate.edu> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 41 >in article <61@amanue.UUCP> jr@amanue.UUCP (Jim Rosenberg) says: >>... I can't get lint on my system to shut up about malloc. ... >> /*NOSTRICT*/ >> if ((p = (struct foo*) malloc(sizeof(struct foo))) == NULL) { In article <1994@a.cs.okstate.edu> gregg@a.cs.okstate.edu (Gregg Wonderly) writes: >Try making this > if ((p = (struct foo*) malloc(sizeof(struct foo))) == (struct foo *)NULL) { >Comparing a structure pointer (namely p) against NULL (sometimes declared as >((char *)0) is probably biting you. Nope. If NULL has been defined as `(char *)0', it is wrong and should be changed (to just `0'), but lint will still complain. Jim Rosenberg was on target with his `strings' on lint. He noted that this unearthed (unoxided?) `VARARGS' and `ARGSUSED' and `NOTREACHED', but not `NOSTRICT'. Why? Because it is *not* *there*. NOSTRICT is documented but not implemented in most `lint's. I have used two different tactics: ${LINT} ${LINTFLAGS} ${SOURCES} | \ grep -v 'possible pointer alignment problem' and #ifdef lint { static struct foo oof; p = &oof; } #else p = (struct foo *) malloc(sizeof (struct foo)); #endif if (p == NULL) ... Neither is pretty; nor, for that matter, is /*NOSTRICT*/. The proper solution is to convince lint that pointers returned by malloc are properly aligned for all data types. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: seismo!mimsy!chris