Bug 20677

Summary: slight prototype inconsistency for poll(2)
Product: Base System Reporter: Ralf S. Engelschall <rse>
Component: kernAssignee: Sheldon Hearn <sheldonh>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.1-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Ralf S. Engelschall 2000-08-17 12:30:01 UTC
Under FreeBSD 4.1-STABLE (and also under 5.0-CURRENT if I had tried),
the Autoconf stuff of my GNU Portable Threads reports:

|    :
| checking for type of argument 2 for poll()... unsigned
| checking for fallback nfds_t... unsigned
|    :

And as a result my generated pth.h header then has a "typedef unsigned
nfds_t;", although I would have expected (both for cleanness and by reading
the poll(2) manpage) that the result is "typedef unsigned int nfds_t;" (note
the explicit "int").  This is caused because the prototype for poll() in
/usr/include/poll.h is not 100% syntactically equivalent to the one in the
manpage poll(2): it lacks the implicit "int" keyword.

Sure, I know that "unsigned" and "unsigned int" are semantically the same in
ANSI C, of course. But for consistency reasons I would appreciate that our
header poll.h exactly reflects the prototype from the manpage unless we
provide the more standardized (SUSv2) "nfds_t" type.

How-To-Repeat: 
:> grep "unsigned _nfds" /usr/include/sys/poll.h 
int     poll __P((struct pollfd *_pfd, unsigned _nfds, int _timeout));
:> gunzip </usr/share/man/man2/poll.2.gz | grep unsigned
.Fn poll "struct pollfd *fds" "unsigned int nfds" "int timeout"
Comment 1 Sheldon Hearn 2000-08-17 18:04:27 UTC
On Thu, 17 Aug 2000 13:24:18 +0200, "Ralf S. Engelschall" wrote:

> >Number:         20677
> >Category:       kern
> >Synopsis:       slight prototype inconsistency for poll(2)

> -int	poll __P((struct pollfd *_pfd, unsigned _nfds, int _timeout));
> +int	poll __P((struct pollfd *_pfd, unsigned int _nfds, int _timeout));

Hi Bruce,

You changed the type of the _nfds argument from u_int to unsigned in rev
1.4 of poll.h.  Can we change it to unsigned int to match the manual
page?

Ciao,
Sheldon.
Comment 2 Sheldon Hearn freebsd_committer freebsd_triage 2000-08-17 18:04:34 UTC
State Changed
From-To: open->feedback

Waiting for feedback from bde.
Comment 3 Bruce Evans 2000-08-18 21:48:56 UTC
>  > -int	poll __P((struct pollfd *_pfd, unsigned _nfds, int _timeout));
>  > +int	poll __P((struct pollfd *_pfd, unsigned int _nfds, int _timeout));

>  You changed the type of the _nfds argument from u_int to unsigned in rev
>  1.4 of poll.h.  Can we change it to unsigned int to match the manual
>  page?

OK (but I would have used "unsigned" in both).

Bruce
Comment 4 Sheldon Hearn freebsd_committer freebsd_triage 2000-08-21 13:26:14 UTC
Responsible Changed
From-To: freebsd-bugs->sheldonh

I'll take this nit.
Comment 5 Sheldon Hearn freebsd_committer freebsd_triage 2000-08-21 13:26:32 UTC
State Changed
From-To: feedback->closed

Committed, thanks.