From durian@fever.boogie.com  Sun Sep 22 16:44:32 2002
Return-Path: <durian@fever.boogie.com>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id EB62037B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 22 Sep 2002 16:44:32 -0700 (PDT)
Received: from fever.boogie.com (cpe-66-87-52-132.co.sprintbbd.net [66.87.52.132])
	by mx1.FreeBSD.org (Postfix) with ESMTP id E50F943E42
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 22 Sep 2002 16:44:31 -0700 (PDT)
	(envelope-from durian@fever.boogie.com)
Received: from man.boogie.com (man.boogie.com [192.168.1.3])
	by fever.boogie.com (8.11.6/8.11.6) with ESMTP id g8MNiPY18481
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 22 Sep 2002 17:44:25 -0600 (MDT)
	(envelope-from durian@fever.boogie.com)
Received: from man.boogie.com (localhost [127.0.0.1])
	by man.boogie.com (8.12.3/8.11.4) with ESMTP id g8MNiOpx048146
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 22 Sep 2002 17:44:24 -0600 (MDT)
	(envelope-from durian@man.boogie.com)
Received: (from durian@localhost)
	by man.boogie.com (8.12.3/8.12.3/Submit) id g8MNiNP9048145;
	Sun, 22 Sep 2002 17:44:23 -0600 (MDT)
Message-Id: <200209222344.g8MNiNP9048145@man.boogie.com>
Date: Sun, 22 Sep 2002 17:44:23 -0600 (MDT)
From: Mike Durian <durian@boogie.com>
Reply-To: Mike Durian <durian@boogie.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: select(2) man page missing <string.h>
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         43270
>Category:       kern
>Synopsis:       select(2) man page missing <string.h>
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 22 16:50:08 PDT 2002
>Closed-Date:    Sun Nov 17 08:40:11 PST 2002
>Last-Modified:  Sun Nov 17 08:40:11 PST 2002
>Originator:     Mike Durian
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD man.boogie.com 5.0-CURRENT FreeBSD 5.0-CURRENT #13: Wed Apr 17 18:47:08 MDT 2002 root@man.boogie.com:/usr/obj/usr/src/sys/BOOGIE i386


>Description:
	The select(2) man page needs to specify <string.h> as a dependent
	include file to cover the bzero(3) usage by FD_ZERO.
>How-To-Repeat:
	Try to use FD_ZERO after only including the headers specified
	in the man page (-Wall required).
>Fix:


--- select.2.orig	Sun Sep 22 17:32:02 2002
+++ select.2	Sun Sep 22 17:32:15 2002
@@ -43,6 +43,7 @@
 .Sh SYNOPSIS
 .In sys/types.h
 .In sys/time.h
+.In string.h
 .In unistd.h
 .Ft int
 .Fn select "int nfds" "fd_set *readfds" "fd_set *writefds" "fd_set *exceptfds" "struct timeval *timeout"

>Release-Note:
>Audit-Trail:

From: Lyndon Nerenberg <lyndon@orthanc.ab.ca>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: kern/43270
Date: Sat, 05 Oct 2002 17:53:06 -0600

 The types(5) manpage also mentions FD_ZERO (and FD_COPY) without
 referencing <string.h>. The underlying bug is in sys/types.h, which
 needs a conditional declaration of bzero and bcopy. The attached patch
 (against 4.7-RC) solves the problem:
 
 Index: include/string.h
 ===================================================================
 RCS file: /home/ncvs/src/include/string.h,v
 retrieving revision 1.6.2.3
 diff -u -r1.6.2.3 string.h
 --- include/string.h	2001/12/25 00:36:57	1.6.2.3
 +++ include/string.h	2002/10/05 23:50:08
 @@ -76,8 +76,15 @@
  /* Nonstandard routines */
  #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
  int	 bcmp __P((const void *, const void *, size_t));
 +/* bcopy and bzero can also be declared by sys/types.h */
 +#ifndef _BCOPY_DECLARED
 +#define _BCOPY_DECLARED
  void	 bcopy __P((const void *, void *, size_t));
 +#endif
 +#ifndef _BZERO_DECLARED
 +#define _BZERO_DECLARED
  void	 bzero __P((void *, size_t));
 +#endif
  int	 ffs __P((int));
  char	*index __P((const char *, int));
  void	*memccpy __P((void *, const void *, int, size_t));
 Index: sys/sys/types.h
 ===================================================================
 RCS file: /home/ncvs/src/sys/sys/types.h,v
 retrieving revision 1.40.2.2
 diff -u -r1.40.2.2 types.h
 --- sys/sys/types.h	2001/04/21 14:53:06	1.40.2.2
 +++ sys/sys/types.h	2002/10/05 23:50:09
 @@ -179,6 +179,20 @@
  	fd_mask	fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  } fd_set;
  
 +/* 
 + * bcopy and bzero are properly declared in <string.h>, but
 + * are included here to satisfy FD_ZERO and FD_COPY for select(2),
 + * which doesn't specify <string.h> as a pre-requisite header.
 + */
 +#ifndef _BCOPY_DECLARED
 +#define _BCOPY_DECLARED
 +void     bcopy __P((const void *, void *, size_t));
 +#endif
 +#ifndef _BZERO_DECLARED
 +#define _BZERO_DECLARED
 +void     bzero __P((void *, size_t));
 +#endif
 +
  #define	_fdset_mask(n)	((fd_mask)1 << ((n) % NFDBITS))
  #define	FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= _fdset_mask(n))
  #define	FD_CLR(n, p)	((p)->fds_bits[(n)/NFDBITS] &= ~_fdset_mask(n))
State-Changed-From-To: open->closed 
State-Changed-By: mike 
State-Changed-When: Sun Nov 17 08:37:41 PST 2002 
State-Changed-Why:  

Fixed in -current by removing <sys/select.h>'s dependency on bcopy() 
and bzero(), and by documenting <sys/select.h> as the appropriate 
include for select(). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=43270 
>Unformatted:
