Doug Morris <[EMAIL PROTECTED]> writes:
> "Dan Harkless" wrote:
> >While building nmh 1.0.1, I noticed that almost every file has these two
> >warnings:
> >
> > rmf.c: In function `main':
> > rmf.c:57: warning: implicit declaration of function `snprintf'
> > rmf.c:119: warning: control reaches end of non-void function
> >
> >Before I start looking into this, has anyone already done so? Seems like
> >both should be quite easy to clean up.
>
> What are you building on?
AIX 4.1.5.0.01.
> I don't get these on OpenBSD, Linux, or Solaris 2.5.1 (my current build
> platforms).
Do all those platforms have native snprintf() functions? AIX 4.1 does not.
configure is putting "#define HAVE_SNPRINTF 1" in config.h -- I wasn't able
to easily determine whether this is the correct behavior for OSes that don't
have their own snprintf()s and must use the Apache one.
In any case, that's what it's doing, so the following code in prototypes.h
doesn't get compiled:
#ifndef HAVE_SNPRINTF
int snprintf (char *, size_t, const char *, ...);
int vsnprintf (char *, size_t, const char *, va_list);
#endif
As for the "control reaches end of non-void function" warnings, what version
of gcc are you using (or are you using something else)? I'm using 2.8.1,
with the default -Wall option, and it correctly notes that there is no
return statement in main(). main() calls done() at the end, which I take it
calls exit(). Three obvious fixes for this:
1. Change main() to return void. It's possible that some compilers might
complain about this, and this is not a solution for programs (though I
doubt there are any) that return in some cases and call done() in others.
2. Put a dead "return 0" after the done() call. There's no way the
optimizer can get rid of that dead code, though of course it's only a few
bytes wasted.
3. Change done() to return and int and change "done()" calls to "return
done()". There's dead code here, too, but it's a little bit cleaner from
the C perspective. Also, it's feasible that some future version of
done() could have situations where it can't successfully exit, at which
point it should return a non-zero value up to main, which would return
that to the OS. return from main() can't fail.
I prefer solution #3. Any differing opinions?
-----------------------------------------------------------------------
Dan Harkless | To prevent SPAM contamination, please do not post this
[EMAIL PROTECTED] | private email address to the USENET or WWW. Thank you.