Bug 25923

Summary: vm_map.h defines a macro called "min_offset" that creates problems with similarly-named variables
Product: Base System Reporter: Jim Zelenka <jimz>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.1.1-RELEASE   
Hardware: Any   
OS: Any   

Description Jim Zelenka 2001-03-19 16:10:00 UTC
/usr/src/sys/vm/vm_map.h contains the following line of code:
   #define       min_offset              header.start

This causes problems for code using a variable named min_offset. At best,
it fails to compile. At worst, the code contains a structure named
header with a field named start, and this creates a very mysterious
memory-corruption bug.

Fix: 

"A whole lot of query-replace" :-)
How-To-Repeat: Include vm_map.h in a file using a local variable named min_offset
Comment 1 Bruce Evans 2001-03-20 01:47:44 UTC
On Mon, 19 Mar 2001 jimz@panasas.com wrote:

> >How-To-Repeat:
> Include vm_map.h in a file using a local variable named min_offset
> 
> >Fix:
> "A whole lot of query-replace" :-)

I think the fix is "Don't include vm_map.h in a file using a local
variable named min_offset".  There are are thousands of other instances
of undocumented namespace pollution in FreeBSD headers.  min_offset
is one of the least important since it is in a "kernel-only" header.
(vm_map.h is not quite kernel-only, but probably should be.  It is
needed only in programs like top and fstat that know too much about
kernel internals.)

Bruce
Comment 2 iedowse freebsd_committer freebsd_triage 2001-12-02 22:20:53 UTC
State Changed
From-To: open->feedback


Is Bruce's suggestion ("Don't include vm_map.h in a file using a 
local variable named min_offset") acceptible to you?
Comment 3 Giorgos Keramidas freebsd_committer freebsd_triage 2002-08-26 04:29:02 UTC
State Changed
From-To: feedback->closed

Feedback timeout.