Subject: Re: Problems with lint(1)
To: None <tech-userlevel@NetBSD.ORG>
From: Christos Zoulas <>
List: tech-userlevel
Date: 07/28/1998 10:56:19
In article <> writes:
>Christos Zoulas writes:
>> >vfscanf.c(146): warning: expression has null effect
>> >
>> >                                nread++, fp->_r--, fp->_p++;
>> This can be fixed by altering the code to be { stmt; stmt; } instead of
>> stmt, stmt
>I'm sure this is a fine kludge, but shouldn't lint know that the other 
>expression isn't "do nothing"?

It knows that it does nothing, but it cannot determine if the author
had intended it this way thus it produces a warning. 
	(void) (expr, expr, expr);
might get rid of the warning too, but it is ugly. In the case above,
one does not even need the braces; substituting the commas with semicolons
works fine.

>> >2) All uses of va_start() and va_arg() generate warnings:
>> >
>> >vfscanf.c(277): warning: possible pointer alignment problem
>> >vfscanf.c(277): warning: pointer casts may be troublesome
>> >
>> >                                *va_arg(ap, short *) = nread;
>> Well, changing the macro to "(type *)(void *) expr" from "(type *) expr"
>> should silence it.

Casting to (void *) basically tells lint that the pointer is aligned
properly. Another way is to have an /*ALIGNEDn*/ directive if one is
not there already.