Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: lint suggestion Message-ID: <631@cresswell.quintus.UUCP> Date: 8 Feb 88 06:15:13 GMT Organization: Quintus Computer Systems, Mountain View, CA Lines: 26 Keywords: printf-"prototype" There's a feature missing from every Lint I've tried, which would be very useful, and should be easy to add (if I had sources, I'd be doing it right now). Consider the stdio functions fscanf( FILE *f, const char *f, ...) sscanf( char *b, const char *f, ...) scanf( const char *f, ...) fprintf(FILE *f, const char *f, ...) sprintf(char *b, const char *f, ...) printf( const char *f, ...) In each of these functions, the format argument is almost always a literal, and it is very easy by inspecting this literal to determine how many arguments should follow and what their types should be. Why not check that the arguments are consistent with the format? (This would also help to catch unimplemented format items; I wouldn't be surprised to find that some of my old programs still contain %r.) What got me thinking about this was seeing a program which did unsigned short x; ... printf("...%ld...", ..., x, ...); and which Lint had no objection to at all. I've used a Fortran compiler which caught this kind of mistake at compile time, and format errors were no less common than some of the other things Lint catches.