Subject: Re: Compile warning under NetBSD-1.3 for fetchmail-4.3.6
To: Webmaster Jim <jspath@mail.bcpl.lib.md.us>
From: David Brownlee <abs@anim.dreamworks.com>
List: tech-kern
Date: 02/17/1998 06:54:14
    Question to tech-kern:

	Nothing in userland uses the MSGBUFSIZE definition in 
	machine/param.h (since it can very from kernel to kernel).

	Fetchmail (a 3rd party app) generates compile warnings because it
	includes <netdb.h> (which includes <machine/param.h>), then
	defines MSGBUFSIZE (for something unrelated).

	Could/should the machine/param.h MSGBUFSIZE definition be 
	protected in #ifdef _KERNEL?

    Reply to jspath:

	I doubt fetchmail is using the MSGBUFSIZE define for the same
	purpose, so that would not be the desired behaviour.

	Some options are
	   a) Modify fetchmail.h to quiet the compiler by adding
		#undef MSGBUFSIZE
	      before the '#define MSGBUFSIZE 2048' line. It may be more
	      correct to have this as:
		#ifdef MSGBUFSIZE
		#undef MSGBUFSIZE
		#endif

	   b) Modify <machine/param.h> to hide MSGBUFSIZE from userland.

		David/absolute

> 
> It looks like several modules in fetchmail include <netdb.h>, which
> includes <sys/param.h>.  The <sys/param.h> then includes <machine/param.h>.
> This is where MSGBUFSIZE is defined in NetBSD.
> 
> Perhaps fetchmail.h should have something like this:
> 
> #ifndef MSGBUFSIZE
> #define MSGBUFSIZE  NBPG        /* default message buffer size */
> #endif
> 
> 
> ++++++++++++++++++++++++++++
> Marvin the Paranoid Android.
> 
On Fri, 13 Feb 1998, Webmaster Jim wrote:

> On Sun, Feb 08, 1998 at 03:25:40PM -0800, David Brownlee wrote:
> > 	Could you check if fetchmail.h directly includes
> > 	/usr/include/machine/param.h, if not can you determine what header
> > 	it includes that in turn includes param.h?
> > 
> > 	As far as I know, if fetchmail is defining _POSIX_SOURCE and
> > 	including a header file defined by posix then NetBSD is in
> > 	error. If fetchmail is not defining _POSIX_SOURCE then it is
> > 	not asking for a posix environment, so it should not expect
> > 	one. Similarly if it is including a header file not specific by
> > 	posix then it is 'breaking the rules'.
> > 
> > 	I'm sure someone can correct me if I've missed anything :)
> > 
> > 
> > 		David/absolute
> > 
> > 	   Raise your standards and lower your expectations...
> > 	            and we'll get along just fine.
> > 
> > On Sat, 7 Feb 1998, Jim Spath (Webmaster Jim) wrote:
> > 
> > > Is the attached message correct in stating that NetBSD's MSGBUFSIZE
> > > parameter is not "posixly-correct?"
> > > ---------- Forwarded message ----------
> > > Date: Sat, 7 Feb 1998 15:16:27 +0000 (GMT)
> > > From: Alan Cox <alan@lxorguk.ukuu.org.uk>
> > > To: jspath@mail.bcpl.lib.md.us
> > > Cc: fetchmail-friends@thyrsus.com
> > > Subject: Re: Compile warning under NetBSD-1.3 for fetchmail-4.3.6
> > > Resent-Date: Sat, 7 Feb 1998 10:37:09 -0500 (EST)
> > > Resent-From: fetchmail-friends@ccil.org
> > > 
> > > > In file included from etrn.c:15:
> > > > fetchmail.h:31: warning: `MSGBUFSIZE' redefined
> > > > /usr/include/machine/param.h:99: warning: this is the location of the previous definition
> > > 
> > > Yep. This occurs on a few non posix compliant platforms where kernel symbols
> > > leak into user name space. MSGBUFSIZE is a kernel parameter on netbsd that
> > > "leaks". Fortunately fetchmail keep redefining it the right way.
> > > 
> > > Alan
> 
> ===================
> gcc -DRELEASE_ID=\"4.3.6\" -DHAVE_CONFIG_H -c -I. -I.  -O driver.c
> In file included from driver.c:64:
> fetchmail.h:31: warning: `MSGBUFSIZE' redefined
> /usr/include/machine/param.h:99: warning: this is the location of the previous definition
> 23:27:35/jim> grep MSGBUFSIZE *.[hc]
> driver.c:    char buf[MSGBUFSIZE+1], return_path[MSGBUFSIZE+1]; 
> driver.c:       char    *ap, *ctt, options[MSGBUFSIZE], addr[128];
> driver.c:    char buf[MSGBUFSIZE+1];
> fetchmail.h:#define             MSGBUFSIZE      2048    /* size of message read buffer */
> rfc822.c:    char       buf[MSGBUFSIZE], longbuf[BUFSIZ];
> smtp.c:char smtp_response[MSGBUFSIZE];
> smtp.c:  char buf[MSGBUFSIZE];
> smtp.h:extern char smtp_response[MSGBUFSIZE];
> 23:27:49/jim> grep netdb.h etrn.c
> #include  <netdb.h>
> 23:28:02/jim> grep param.h /usr/include/netdb.h
> #include <sys/param.h>
> 23:28:09/jim> grep machine/param.h /usr/include/stdio.h
> =====================