A lint question
Richard A. O'Keefe
ok at quintus.uucp
Tue Nov 29 21:53:50 AEST 1988
In article <1256 at vsedev.VSE.COM> logan at vsedev.VSE.COM (James Logan III) writes:
>function argument ( number ) used inconsistently
> malloc( arg 1 ) llib-lc(338) :: findlinks.c(114)
> read( arg 3 ) llib-lc(104) :: findlinks.c(127)
>I assume that lint is telling me that I am calling malloc() and
>read() with an inconsistent number or parameters.
Nope. Read that as "either a function argument has the wrong type,
or the function has the wrong number of arguments".
>extern char *malloc();
>char *directory;
>directory = (char *)malloc((int)stbuf.st_size);
^^^^^^^^^^^^^^^^^
extern char *malloc(size_t howmuch);
size_t is an unsigned integral type (except in BSD systems, where it's "int").
>if (read(fd, directory, (int)stbuf.st_size) != (int)stbuf.st_size) {
^^^^^^^^^^^^^^^^^^
extern int read(int fd, char *buffer, size_t howmuch);
>while (read(fd, &mntbuf, sizeof(MNT)) == sizeof(MNT)) {
^^^^^^^
&mntbuf cannot be of type char* unless mntbuf is a single char.
I'm assuming here that mntbuf is some sort of record; in that case you want
read(fd, (char*)&mntbuf, sizeof mntbuf),
not that lint will like that either.
More information about the Comp.lang.c
mailing list