Subject: bin/1893: tn3270 is missing some prototypes.
To: None <gnats-bugs@gnats.netbsd.org>
From: Chris G. Demetriou <cgd@NetBSD.ORG>
List: netbsd-bugs
Date: 01/05/1996 15:05:16
>Number:         1893
>Category:       bin
>Synopsis:       tn3270 is missing some prototypes, doesn't compile correctly
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan  5 15:20:03 1996
>Last-Modified:
>Originator:     Chris G. Demetriou
>Organization:
Kernel Hackers 'r' Us
>Release:        NetBSD-current, January 5, 1996
>Environment:
	
System: NetBSD sun-lamp.pc.cs.cmu.edu 1.1A NetBSD 1.1A (SUN_LAMP) #19: Thu Jan 4 20:42:03 EST 1996 cgd@sun-lamp.pc.cs.cmu.edu:/usr/src/sys/arch/i386/compile/SUN_LAMP i386


>Description:
	tn3270 is missing prototypes for the mem* functions.  it didn't
	need them previously because it #defined mem* to use be b* functions
	on systems which had the "unix" preprocessor symbol defined.

	the fix for PR 1873 removed those #defines, and so code which
	previously used the b* functions starting using the mem* functions.

	The b* functions aren't built in to the compiler, but the mem* 
	functions are.  The mem* functions, therefore have prototypes
	built in to the compiler as well, and, unless they're prototyped
	for real, those builtin prototypes can conflict with the implicit
	prototypes that would be generated by unprototyped use.

	This actually happens on the Alpha port, leading to errors like:

cc -O -I/usr/src/usr.bin/tn3270/tn3270 -I. -DTERMCAP -DSRCRT -DKLUDGELINEMODE -DUSE_TERMIO -DTN3270 -Dunix  -DTERMCAP -DSRCRT -DKLUDGELINEMODE -DUSE_TERMIO -DTN3270 -Dunix -Werror  -c /usr/src/usr.bin/tn3270/tn3270/../ctlr/api.c
cc1: warnings being treated as errors
/usr/src/usr.bin/tn3270/tn3270/../ctlr/api.c: In function `query_session_id':
/usr/src/usr.bin/tn3270/tn3270/../ctlr/api.c:177: warning: type mismatch in implicit declaration for built-in function `memcpy'

>How-To-Repeat:
	Try to compile tn3270 from unmodified sources on NetBSD/Alpha, then,
	when it fails, not the lack of mem* prototypes.

>Fix:
	One possible fix is below.  However, i'm not sure that the change
	to the FD_* macros in <sys/types.h>, which necessitated the change
	to tn3270/general/general.h pointed out by PR 1873, is correct.

	If the FD_* macros were changed so that they didn't rely on mem*,
	then this change, and the change done because of PR 1873, would
	both be unnecessary.

Index: general/general.h
===================================================================
RCS file: /a/cvsroot/src/usr.bin/tn3270/general/general.h,v
retrieving revision 1.3
diff -c -r1.3 general.h
*** general.h	1996/01/01 02:16:34	1.3
--- general.h	1996/01/05 19:47:25
***************
*** 64,67 ****
  				    } \
  				}
  #define	memcmp(s1,s2,n)		bcmp(s1,s2,n)
! #endif	/* defined(unix) && !defined(__NetBSD__) */
--- 64,69 ----
  				    } \
  				}
  #define	memcmp(s1,s2,n)		bcmp(s1,s2,n)
! #else /* !(defined(unix) && !defined(__NetBSD__)) */
! #include <string.h>
! #endif	/* !(defined(unix) && !defined(__NetBSD__)) */
>Audit-Trail:
>Unformatted: