🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #855

Re: hiding lint's ravings (was Re: FAQ - malloc array - clarify)

#855
From: Chris Torek
Date: Sat, 08 Sep 1990 20:10
68 lines
2923 bytes
In article <8086@helios.TAMU.EDU> jdm5548@diamond.tamu.edu
(James Darrell McCauley) writes:
>How do you professionals deal with insignificant(?) ravings from
>lint (or other high quality C program verifiers) such as
[the bogus `possible pointer alignment problem' messages from malloc]?
>... I can just ignore warnings like this, but those who review
>my code (professors, employers, clients) are not likely to.

Since the warning is due to a bug in lint, those who do not ignore it
are simply compounding the problem.  The real cure is to fix lint.

>By the way, I got this error while using a Sparc under Sun OS 4.0.3c,
>but not under 4.0.3 (which perplexes me).

Looks like someone fixed it, but had to back out the fix (or else 4.0.3
and 4.0.3c were separate development efforts, which is entirely possible).

This happens to be easy to fix as a special case inside lint (add an
`/*ALIGNOK*/' lint-pragma that can be used in <stdXXX.h> files to tag
the special functions malloc and calloc).  A harder one is varargs routines:

	/* used as error(quit, errno, fmt, ...) */

	/* VARARGS3 */
	error(va_alist)	/* note Classic C <varargs.h>, not New C <stdarg.h> */
		va_dcl
	{
		int quit, e;
		char *fmt;
		va_list ap;

		va_start(ap);
		quit = va_arg(ap, int);
		e = va_arg(ap, int);
		fmt = va_arg(ap, int);
		...

One would like lint to verify that the first three arguments are indeed
<int> <int> and <char *> respectively.  (Indeed, since this particular
function behaves like printf, one would also like lint to verify subsequent
arguments the way the 4.3BSD-reno lint [thanks to Arthur Olson] verifies
arguments to printf, fprintf, and sprintf.)

The only solution I have to this is:

	#ifdef lint
	/* VARARGS3 */
	error(quit, e, fmt) int quit, e; char *fmt; { }
	#define error lint_error
	#endif

	... definition of error() as before ...
	#undef error

You must then ignore all `function lint_.* defined but not used' errors.
If you were to use

	#ifdef lint
	/* VARARGS3 */
	error(quit, e, fmt) int quit, e; char *fmt; { }
	#else
	... definition of error() ...
	#endif

then lint would not be able to check the code inside error() itself.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris
Technical Details
Message-ID: <26436@mimsy.umd.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!pacbell!pacbell.com!mips!zaphod.mps.ohio-state.edu!wuarchive!julius.cs.uiuc.edu!ux1.cso.uiuc.edu!midway!mimsy!chris
References: <8056@helios.TAMU.EDU> <1990Sep08.022034.8444@virtech.uucp> <8086@helios.TAMU.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!pacbell!pacbell.com!mips!zaphod.mps.ohio-state.edu!wuarchive!julius.cs.uiuc.edu!ux1.cso.uiuc.edu!midway!mimsy!chris
From: chris@mimsy.umd.edu (Chris Torek)
Newsgroups: comp.unix.programmer
Subject: Re: hiding lint's ravings (was Re: FAQ - malloc array - clarify)
Keywords: malloc, Sun, lint
Message-ID: <26436@mimsy.umd.edu>
Date: 8 Sep 90 20:10:50 GMT
References: <8056@helios.TAMU.EDU> <1990Sep08.022034.8444@virtech.uucp> <8086@helios.TAMU.EDU>
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
Lines: 68