[comp.lang.c] format string linting?

mikeg@c3.c3.lanl.gov (Michael P. Gerlek) (01/26/91)

(This only *sounds* bizzarre... Trust me.)

Does anyone have a hack that will "lint" my format strings for printf,
scanf, and the like?  For example,

	char *s;
	printf("%d", s);

is icky, but lint can't see it.  Furthermore,

	int x,y;
	printf("%d %d %d", x, y);

is equally icky.

I really need a hack that will grind through thousands of lines of C
to find these yucky lines.  Ob. explanation: these errors crop up in
error code like:

	if (frob != notz)
	  printf("Internal error: frob (%d) != notz (%d)\n");

where only at certain high tide/moon phase conditions would these
error lines get printed...

Thanks.

-[mpg]
 mikeg@lanl.gov
 "...making the world safe for supercomputing."

mcdaniel@adi.com (Tim McDaniel) (01/29/91)

mikeg@c3.c3.lanl.gov (Michael P. Gerlek) writes:
   Does anyone have a hack that will "lint" my format strings for printf,
   scanf, and the like?

Contact
   Gimpel Software
   3207 Hogarth Lane
   Collegeville, PA 19426
   Voice: +1 215 584 4261
   Fax:   +1 215 584 4266

FlexeLint is *not* a hack at all.  It's an ANSI-compatable lint, and
also works for old K&R code.  It does printf/scanf conversion
checking, among many other things.  *Each of the 300-odd messages can
be individually suppressed*, on a message-number basis (and a symbol
name or file name basis where appropriate); messages can be turned off
and on in code, via comments.  That alone is worth the price, even
without all the good checking!  PC-lint is their PC version.

With my personalized lint option file, it's so easy and useful that I
lint as often as I compile (and often before).  It has saved me quite
a bit of trouble.

Disclaimer: I have never had a financial interest in Gimpel Software.
I am merely a very satisfied customer.

--
Tim McDaniel                 Applied Dynamics Int'l.; Ann Arbor, Michigan, USA
Work phone: +1 313 973 1300                        Home phone: +1 313 677 4386
Internet: mcdaniel@adi.com                UUCP: {uunet,sharkey}!amara!mcdaniel

rsalz@bbn.com (Rich Salz) (01/30/91)

In <MIKEG.91Jan25120642@c3.c3.lanl.gov> mikeg@c3.c3.lanl.gov (Michael P. Gerlek) writes:
comp.sources.unix, volume 6:
	printfck2       New printfck and manpage
comp.sources.unix, volume 4:
	printfck        Have lint check (most) printf calls
-- 
Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
Use a domain-based address or give alternate paths, or you may lose out.