2 lint questions

Jeffrey Kegler jeffrey at algor2.uu.net
Thu Aug 17 01:23:16 AEST 1989


In article <5967 at ingr.com> boyd at ingr.com (Boyd Nation) writes:
>1)  How does one prevent lint from issuing a warning message about possible
>pointer alignment problems given the following line of code:
>
>	x = (blivet *)malloc(sizeof(blivet));

#ifdef lint
#define NOSTRICT(type, exp) ((exp)?(type)0:(type)0)
#else
#define NOSTRICT(type, exp) ((type)(exp))
#endif

so that the expression above becomes
       x = NOSTRICT(blivet *,malloc(sizeof(blivet)));

This solves all complaints about casts, possible loss of precision,
etc.  Note the expression exp is still type-checked by lint, so you
are turning lint off only on the cast.

I believe in making lint absolutely silent, that is, lint returns nothing
but another shell prompt.  Otherwise, lint messages pile up and it
becomes impossible to sort out that there are now 16 "possible loss of
precision" messages instead of 15 and the new one ain't just crying
wolf, either.  This is particularly true is you are not the only one
who worked on the code.
-- 

Jeffrey Kegler, Independent UNIX Consultant, Algorists, Inc.
jeffrey at algor2.ALGORISTS.COM or uunet!algor2!jeffrey
1762 Wainwright DR, Reston VA 22090



More information about the Comp.lang.c mailing list