Solved Can Lint warnings about va_start() safely be ignored?

Here's something I've been wondering for a long time.

Consider the following simple example:
Code:
#include <stdarg.h>
#include <stdio.h>

void
function(const char *fmt,...)
{
  va_list ap;

  va_start(ap,fmt);
  (void)printf(fmt,ap);
  va_end(ap);
}
Code:
[cmd]lint -aabceghnsux foo.c[/cmd]
foo.c:
foo.c(9): warning: pointer casts may be troublesome [247]
[i][snip warnings about the standard library itself][/i]
Lint pass2:
I've always used va_start(3) this way and I've always assumed that Lint doesn't know how to deal with it properly (or perhaps FreeBSD's implementation of stdarg(3) is somewhat iffy) so this warning can safely be ignored. But from time to time I keep wondering about this, so I figured perhaps someone here knows for sure. Any thoughts?
 
I'd say yes, it's safe to ignore this warning... :)

Code:
% grep -A8 lint /usr/include/stdarg.h
#elif defined(lint)
/* Provide a fake implementation for lint's benefit */
#define __va_size(type) \
  (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
#define va_start(ap, last) \
  ((ap) = (va_list)&(last) + __va_size(last))
#define va_arg(ap, type) \
  (*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
#define va_end(ap)

% _
 
I figured as much. This whole stdarg (or variadic functions/macros in general) business is probably on the edge of what the C syntax allows and with Lint being as tight-arsed as it is (and should be) it's not too strange that this kind of sizeof trickery sets it off.

Thanks for the confirmation :)
 
Back
Top