lint warning messages with malloc()

Dave Hammond daveh at marob.MASA.COM
Thu Nov 3 23:34:48 AEST 1988


In article <142 at cjsa.WA.COM> jeff at cjsa.WA.COM (Jeffery Small) writes:
>When compiling a program on an AT&T 3B1 (running SystemV.2 +/-), I am
>getting the following warning message from lint when I use malloc(3):
>
>	warning: possible pointer alignment problem
>[...sample code deleted...]

The program code is not at fault.  The problem is that lint does not
know about malloc returning a suitably aligned pointer, therefore
it complains.  You could do some fancy declaration footwork and declare

X *malloc();

for the file, but be careful that there are no instances of any other
malloc casts (including char *) within the same file.

Most folks just ignore this warning when issued for malloc.

Dave Hammond
  UUCP: ...!uunet!masa.com!{marob,dsix2}!daveh
DOMAIN: daveh at marob.masa.com
----------------------------------------------------------------------------



More information about the Comp.lang.c mailing list