Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Lint warnings (was: gotos and switch statements) Message-ID: <1053@haddock.ISC.COM> Date: Wed, 31-Dec-69 18:59:59 EDT Article-I.D.: haddock.1053 Posted: Wed Dec 31 18:59:59 1969 Date-Received: Sat, 5-Sep-87 10:52:30 EDT References: <855@tjalk.cs.vu.nl> <2683@hoptoad.uucp> <916@haddock.ISC.COM> <929@haddock.ISC.COM> <867@mcgill-vision.UUCP> <869@tjalk.cs.vu.nl> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 32 In article <869@tjalk.cs.vu.nl> rblieva@cs.vu.nl (Roemer B. Lievaart) writes: >In article <867@mcgill-vision.UUCP> mouse@mcgill-vision.UUCP (der Mouse) writes: >>Any warning should have a means to turn it off. (For most current warnings, >>which tend to be type clashes, this means is provided: it's called a cast.) > >Oh yeah? How about the message I get for EVERY casted malloc or realloc: >:: somefile.c(007): warning: possible pointer alignment problem >Can't shut lint up about that. That's mostly true; there really should be a lintpragma for declaring aligned pointers like the result of malloc(). A solution I've used in the past: #ifdef lint extern char *cmalloc(); extern int *imalloc(); #else extern char *malloc(); #define cmalloc(n) ((char *)malloc((n)*sizeof(char))) #define imalloc(n) ((int *)malloc((n)*sizeof(int))) #endif >BTW. Does anybody know how to stop lint complaining about functions >returning values wich are always/sometimes ignored? I get one for every >time I use sprintf, fclose, strcpy and quite a few others! >[ OK, I meant another way than indeed using the values. > I just don't need them (always)! ] Explicitly cast them to (void). If that's too much trouble, define a macro to do it for you: "#define Strcpy(s,t) (void)strcpy(s,t)". I recommend this only for functions that return a useless value (like strcpy), not for those that flag an error (like putchar). Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint