lint on malloc calls
T. William Wells
bill at proxftl.UUCP
Tue Sep 13 11:41:42 AEST 1988
In article <39617 at linus.UUCP> jgb at linus.UUCP (Jonathan G. Bressel) writes:
: What is the best way of using malloc to get a pointer to a structure?
: I am using the line below:
:
: nextentry = (entry *) malloc(sizeof(entry));
:
: where nextentry is defined as
:
: entry *nextentry;
:
: Running lint -bach yields:
:
: phone.c(61): warning: illegal pointer combination
: phone.c(61): warning: possible pointer alignment problem
:
: What am I doing wrong? Doesn't K+R suggest this on pp. 133-134 (at
: the end of section 6.5)?
You are using lint. :-)
This is a problem with every lint I have used. Lint doesn't
understand that malloc returns a properly aligned pointer, so you
get the messages.
To shut lint up, you need to trick it a little. Here is one way:
Place
#ifdef lint /* lint defines this symbol */
#define malloc(x) 0
#endif
somewhere so that every call to malloc can be overridden by the
macro. You may want to put a #undef malloc in front of the
#define.
---
Bill
novavax!proxftl!bill
More information about the Comp.lang.c
mailing list