lib updates and test suite

Russ Allbery rra at
Thu Jun 15 04:57:23 UTC 2000

Geoff Wilson <gmwils at> writes:

> Just to let you know, the current version inn-CURRENT-20000614 won't
> compile innfeed due to a name clash.

> innfeed/misc.c
> lib/error.c

> Both define warn and die as functions with the same arguments/types.
> Under FreeBSD 3.4/gcc this results in a fatal linking error.

Bleh.  That's a rather unforgiving linker; it links fine on Solaris,
resolving the ambiguity in favor of the first one found (which will be the
innfeed one).

> Renaming the functions within innfeed to innfeed_warn and innfeed_die
> solve the problems.

> My guess is that eventually innfeed will use the general routines in the
> library, but for the minute it may be easier just to rename one set of
> them.

I'm looking at converting them to use the new routines in lib/error.c.
It's interesting; innfeed's log() function actually does something

  fprintf (stderr, "%s %s: ",
           timeString, (program ? program : "UNKNOWN PROGRAM NAME")) ;
  out = vfprintf (stderr, fmt, args) ;
  fprintf (stderr,"\n") ;

  p = malloc (out + 10) ;
  vsprintf (p,fmt,args) ;
  syslog (level,p) ;

That's actually a really cute idea and a cool way to avoid the problem of
not being able to pass a va_args argument to a syslog function without
using static buffers.  The problem is that it passes args to two different
functions without an intervening va_end/va_start.  That's illegal
according to the C standard and will break on platforms that pass va_args
variables by reference rather than by value.

You have to either do this at the top-level variadic function, not in a
function with a va_args argument, or you have to use va_copy() (which is
part of ISO C99, but currently not widely available yet).

Anyway, I think that innfeed can use the standard functions if I add one
more hook, a function to call after doing the vfprintf that takes the
return value of vfprintf (so that it knows how long the message will be),
the format, and a fresh va_args argument.  I'm going to work on that now.
Note that in the code I'm checking into the CURRENT tree, I'm assuming
that stdarg.h is available and not trying to do fallback to varargs.h
ever.  ANSI C89 requires stdarg.h, and gcc provides it even on non-ANSI
systems like SunOS.

Russ Allbery (rra at             <>

More information about the inn-workers mailing list