Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!elsie!ado From: ado@elsie.UUCP (Arthur David Olson) Newsgroups: comp.unix.questions Subject: Re: Shutting lint up about malloc (missing /*NOSTRICT*/) Message-ID: <7418@elsie.UUCP> Date: Mon, 18-May-87 22:27:57 EDT Article-I.D.: elsie.7418 Posted: Mon May 18 22:27:57 1987 Date-Received: Tue, 19-May-87 06:25:18 EDT References: <61@amanue.UUCP> <1994@a.cs.okstate.edu> <19123@sun.uucp> Organization: NIH-LEC, Bethesda, MD Lines: 86 > The reason why NOSTRICT doesn't work is that, to the best of my > knowledge, it has never been implemented, not that it was dropped. Those who'd like to give it a try may find the letter below (slightly edited from its original form) of interest. As others have noted, a better approach to malloc/calloc messages may be for lint to remain silent on pointer assignments involving (void *); the NOSTRICT mechanism is more generally useable (and abuseable). + From ado Fri Apr 17 15:40:38 1987 + Subject: Re: lint... + + > Also, speaking of man pages, how tough would /*NOSTRICT*/ be? + + Well, a simple-minded implementation of NOSTRICT isn't too bad. + First, we add this code to "lib/mip/scan.c" to recognize NOSTRICT in comments, + setting the variable "strictnein": + + case 'N': + lxget( c, LEXLET ); + #ifndef ASWAS + if (strcmp(yytext, "NOSTRICT") == 0) { + extern int strictnein; + + strictnein = 1; + continue; + } + #endif /* !ASWAS */ + if( strcmp( yytext, "NOTREACHED" ) ) continue; + reached = 0; + continue; + + Second, we visit "ecode" in "lint.c", + arranging things so that each time the compiler emits code strictnein gets + turned off: + + #ifndef ASWAS + int strictnein; + #endif /* !ASWAS */ + ecode( p ) NODE *p; { + /* compile code for p */ + + fwalk( p, contx, EFF ); + lnp = lnames; + lprt( p, EFF, 0 ); + #ifndef ASWAS + strictnein = 0; + #endif /* !ASWAS */ + } + + Finally, we conditionalize the appropriate error messages based on strictnein. + The big payoff place for doing this is in "lib/mip/trees.c", in the function + "chkpun": + + chkpun(p) register NODE *p; { + ... + register NODE *q; + register t1, t2; + register d1, d2; + #ifndef ASWAS + #ifdef LINT + extern int strictnein; + #endif /* LINT */ + #endif /* !ASWAS */ + ... + #ifndef ASWAS + #ifdef LINT + if (!strictnein) + #endif + #endif /* !ASWAS */ + werror( "illegal pointer combination" ); + } + + } + + You might also want to conditionalize some other messages. + + If the above approach is used, the manual page description of NOSTRICT needs + to say that it shuts off strict checking in the next "statement or + conditional", rather than in the next "expression." -- UNIX is a registered trademark of AT&T. Lint is a trademark of Oscar Madison. -- UUCP: ..seismo!elsie!ado ARPA: elsie!ado@seismo.CSS.GOV Elsie and Ado are trademarks of Borden, Inc. and Ampex.