Bug 12723

Summary: Unnecessary use of magic numbers in F_[SG]ETFD code
Product: Base System Reporter: Peter Jeremy <jeremyp>
Component: kernAssignee: Dag-Erling Smørgrav <des>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Peter Jeremy 1999-07-21 00:30:00 UTC
	The code implementing the F_[SG]ETFD fcntl's uses the magic
	number `1' to represent both the user mode and kernel mode
	close on exec flags.  These flags both have macros associated
	with them (FD_CLOEXEC and UF_EXCLOSE, respectively).  Neither
	macro mentions the existence of the other, or the requirement
	that the macro value not change from 1.

Fix: The following patch removes the reference to a magic value and
	dissociates the values of FD_CLOEXEC and UF_EXCLOSE.  The
	fcntl(2) man page is also updated to document FD_CLOEXEC.
How-To-Repeat: 
	Code inspection
Comment 1 peter.jeremy 2000-01-26 20:27:52 UTC
Hi Warner,

As the last person to touch /usr/src/sys/kern/kern_descrip.c, would
you please consider applying the patches in PR kern/12723 to remove
the unnecessary use of the magic number 1 instead of FD_CLOEXEC and
UF_EXCLOSE.

Peter
Comment 2 Warner Losh 2000-01-26 21:28:19 UTC
In message <00Jan27.072752est.115241@border.alcanet.com.au> Peter Jeremy writes:
: As the last person to touch /usr/src/sys/kern/kern_descrip.c, would
: you please consider applying the patches in PR kern/12723 to remove
: the unnecessary use of the magic number 1 instead of FD_CLOEXEC and
: UF_EXCLOSE.

Sure.  Go ahead and assign it to me if you can, let me know if you
can't.

Warner
Comment 3 ru freebsd_committer freebsd_triage 2000-01-27 08:19:41 UTC
Responsible Changed
From-To: freebsd-bugs->imp

Warner volunteered for this PR. 
Comment 4 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2001-11-21 00:39:27 UTC
Responsible Changed
From-To: imp->des

Warner asked me to take this.
Comment 5 Jeroen Ruigrok van der Werven freebsd_committer freebsd_triage 2002-04-13 11:21:51 UTC
State Changed
From-To: open->patched

This has been committed to CURRENT. 
Will be MFC'd in about 2 weeks. 

Thanks!
Comment 6 Jeroen Ruigrok van der Werven freebsd_committer freebsd_triage 2002-04-29 09:58:31 UTC
State Changed
From-To: patched->closed

Merged from CURRENT. 

Thanks.