Bug 13722

Summary: typo in /usr/include/sys/mman.h
Product: Base System Reporter: bgregor <bgregor>
Component: kernAssignee: dufault
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description bgregor 1999-09-13 12:50:00 UTC
In line 124 of /usr/include/sys/mman.h there is an extra comma 
before 'mode_t':
int shm_open __P((const char *, int, mode_t));

Fix: 

Remove the comma after 'int' and before 'mode_t':
	int     shm_open __P((const char *, int mode_t));
How-To-Repeat: I came across this while compiling a homegrown GTK+ application.
Comment 1 ru freebsd_committer freebsd_triage 1999-09-13 13:20:06 UTC
Responsible Changed
From-To: freebsd-bugs->dufault

Over to Peter (the author of mman.h,v 1.21). 

Comment 2 Bruce Evans 1999-09-13 14:51:34 UTC
> >Description:
> In line 124 of /usr/include/sys/mman.h there is an extra comma 
> before 'mode_t':
> int shm_open __P((const char *, int, mode_t));

No, this is the correct declaration.  mode_t is a type, not a
parameter name.

> >How-To-Repeat:
> I came across this while compiling a homegrown GTK+ application.
> >Fix:
> Remove the comma after 'int' and before 'mode_t':
> 	int     shm_open __P((const char *, int mode_t));

The application apparently doesn't include <sys/types.h> before
<sys/mman.h> to get the typedef for mode_t.

<sys/types.h> is not a prerequisite of <sys/mman.h> in POSIX.1-1996,
so the bug is in <sys/mman.h>.

Bruce
Comment 3 des 1999-09-13 15:50:17 UTC
bgregor@buphy.bu.edu writes:
> In line 124 of /usr/include/sys/mman.h there is an extra comma 
> before 'mode_t':
> int shm_open __P((const char *, int, mode_t));

No, this prototype is correct. Your program is wrong. For reference,
see the Single Unix Specification v2:

 <URL:http://www.opengroup.org/onlinepubs/007908799/xsh/shm_open.html>

DES
-- 
Dag-Erling Smorgrav - des@flood.ping.uio.no
Comment 4 Dag-Erling Smørgrav freebsd_committer freebsd_triage 1999-09-13 15:50:25 UTC
State Changed
From-To: open->closed

Incorrect PR. 

Comment 5 bgregor 1999-09-13 15:52:08 UTC
On Mon, 13 Sep 1999, Bruce Evans wrote:

> > >Description:
> > In line 124 of /usr/include/sys/mman.h there is an extra comma 
> > before 'mode_t':
> > int shm_open __P((const char *, int, mode_t));
> 
> No, this is the correct declaration.  mode_t is a type, not a
> parameter name.
>

Yes.  Whoops.  
 
> > >How-To-Repeat:
> > I came across this while compiling a homegrown GTK+ application.
> > >Fix:
> > Remove the comma after 'int' and before 'mode_t':
> > 	int     shm_open __P((const char *, int mode_t));
> 
> The application apparently doesn't include <sys/types.h> before
> <sys/mman.h> to get the typedef for mode_t.
> 
> <sys/types.h> is not a prerequisite of <sys/mman.h> in POSIX.1-1996,
> so the bug is in <sys/mman.h>.
> 
> Bruce
> 


Thanks for the info - I misread the function prototype!


Brian
Comment 6 Sheldon Hearn 1999-09-13 18:39:25 UTC
On Mon, 13 Sep 1999 04:46:33 MST, bgregor@buphy.bu.edu wrote:

> Remove the comma after 'int' and before 'mode_t':
> 	int     shm_open __P((const char *, int mode_t));

That doesn't make much sense, since your change effectively suggests
that one of the parameters should be called mode_t. :-)

Could you provide more details indicating what leads you to believe that
this is a problem?

Ciao,
Sheldon.
Comment 7 Garrett A. Wollman 1999-09-13 19:23:40 UTC
<<On Mon, 13 Sep 1999 04:46:33 -0700 (PDT), bgregor@buphy.bu.edu said:

> In line 124 of /usr/include/sys/mman.h there is an extra comma 
> before 'mode_t':
> int shm_open __P((const char *, int, mode_t));

No, it is correct as written.  shm_open(), if we actually implemented
it, takes three arguments.

-GAWollman

--
Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
wollman@lcs.mit.edu  | O Siem / The fires of freedom 
Opinions not those of| Dance in the burning flame
MIT, LCS, CRS, or NSA|                     - Susan Aglukark and Chad Irschick
Comment 8 bgregor 1999-09-13 19:33:01 UTC
On Mon, 13 Sep 1999, Garrett Wollman wrote:

> <<On Mon, 13 Sep 1999 04:46:33 -0700 (PDT), bgregor@buphy.bu.edu said:
> 
> > In line 124 of /usr/include/sys/mman.h there is an extra comma 
> > before 'mode_t':
> > int shm_open __P((const char *, int, mode_t));
> 
> No, it is correct as written.  shm_open(), if we actually implemented
> it, takes three arguments.
> 

yes, I erred in suggesting a fix.  Nonetheless, I get the following error
when compiling my GTK+ (from the ports collection):
	gcc  -c -O2 `gtk-config --cflags`  functions.c
	In file included from functions.c:6:
	/usr/include/sys/mman.h:124: parse error before `mode_t'
	*** Error code 1

	Stop.
(this is version 1.2.3 of gtk+)
This program compiles cleanly without modification with the same version
of gtk under Irix 6.2 & 6.5, Solaris 2.6 for SPARC, and Redhat Linux 5.2
using glibc 2.0, so this would appear to be a FreeBSD problem somewhere?




brian
Comment 9 Garrett A. Wollman 1999-09-13 19:42:51 UTC
<<On Mon, 13 Sep 1999 14:33:01 -0400, Brian Gregor <bgregor@buphy.bu.edu> said:

> yes, I erred in suggesting a fix.  Nonetheless, I get the following error
> when compiling my GTK+ (from the ports collection):
> 	gcc  -c -O2 `gtk-config --cflags`  functions.c
> 	In file included from functions.c:6:
> 	/usr/include/sys/mman.h:124: parse error before `mode_t'
> 	*** Error code 1

The program erroneously fails to include <sys/types.h>, a documented
prerequisite of <sys/mman.h>.

-GAWollman

--
Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
wollman@lcs.mit.edu  | O Siem / The fires of freedom 
Opinions not those of| Dance in the burning flame
MIT, LCS, CRS, or NSA|                     - Susan Aglukark and Chad Irschick
Comment 10 bgregor 1999-09-13 19:57:58 UTC
> 
> The program erroneously fails to include <sys/types.h>, a documented
> prerequisite of <sys/mman.h>.
> 
> -GAWollman
> 

Actually, it does, but in this order:
	#include <sys/mman.h>
	#include <sys/types.h>
which works fine under the previously mentioned types of Unix.  Upon
swapping the order it works fine under FreeBSD as well - why would the
behavior here be different? (out of curiosity)


brian
Comment 11 Garrett A. Wollman 1999-09-13 20:16:23 UTC
<<On Mon, 13 Sep 1999 14:57:58 -0400, Brian Gregor <bgregor@buphy.bu.edu> said:

> Actually, it does, but in this order:
> 	#include <sys/mman.h>
> 	#include <sys/types.h>
> which works fine under the previously mentioned types of Unix.  Upon
> swapping the order it works fine under FreeBSD as well - why would the
> behavior here be different? (out of curiosity)

Because <sys/mman.h> requires types declared in <sys/types.h> --
specifically, mode_t.

-GAWollman

--
Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
wollman@lcs.mit.edu  | O Siem / The fires of freedom 
Opinions not those of| Dance in the burning flame
MIT, LCS, CRS, or NSA|                     - Susan Aglukark and Chad Irschick