svn commit: r303580 - in head: include lib/libc/gen usr.sbin/pw
Ed Schouten
ed at FreeBSD.org
Sun Jul 31 08:05:16 UTC 2016
Author: ed
Date: Sun Jul 31 08:05:15 2016
New Revision: 303580
URL: https://svnweb.freebsd.org/changeset/base/303580
Log:
Fix up setgrent(3) to have a POSIX-compliant prototype.
Just like with freelocale(3), I haven't been able to find any piece of
code that actually makes use of this function's return value, both in
base and in ports. The reason for this is that FreeBSD seems to be the
only operating system to have such a prototype. This is why I'm deciding
to not use symbol versioning for this.
It does seem that the pw(8) utility depends on the function's typing and
already had a switch in place to toggle between the FreeBSD and POSIX
variant of this function. Clean this up by always expecting the POSIX
variant.
There is also a single port that has a couple of local declarations of
setgrent(3) that need to be patched up. This is in the process of being
fixed.
PR: 211394 (exp-run)
Modified:
head/include/grp.h
head/lib/libc/gen/getgrent.3
head/lib/libc/gen/getgrent.c
head/usr.sbin/pw/pw_vpw.c
head/usr.sbin/pw/pwupd.h
Modified: head/include/grp.h
==============================================================================
--- head/include/grp.h Sun Jul 31 06:53:50 2016 (r303579)
+++ head/include/grp.h Sun Jul 31 08:05:15 2016 (r303580)
@@ -75,8 +75,7 @@ int pwcache_groupdb(int (*)(int), void
struct group * (*)(gid_t));
#endif
#if __XSI_VISIBLE
-/* XXX IEEE Std 1003.1, 2003 specifies `void setgrent(void)' */
-int setgrent(void);
+void setgrent(void);
#endif
#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
int getgrgid_r(gid_t, struct group *, char *, size_t,
Modified: head/lib/libc/gen/getgrent.3
==============================================================================
--- head/lib/libc/gen/getgrent.3 Sun Jul 31 06:53:50 2016 (r303579)
+++ head/lib/libc/gen/getgrent.3 Sun Jul 31 08:05:15 2016 (r303580)
@@ -28,7 +28,7 @@
.\" From: @(#)getgrent.3 8.2 (Berkeley) 4/19/94
.\" $FreeBSD$
.\"
-.Dd April 16, 2003
+.Dd July 31, 2016
.Dt GETGRENT 3
.Os
.Sh NAME
@@ -60,7 +60,7 @@
.Fn getgrgid_r "gid_t gid" "struct group *grp" "char *buffer" "size_t bufsize" "struct group **result"
.Ft int
.Fn setgroupent "int stayopen"
-.Ft int
+.Ft void
.Fn setgrent void
.Ft void
.Fn endgrent void
@@ -188,14 +188,13 @@ is set to
.Dv NULL
and the return value is 0, no matching entry exists.)
.Pp
-The functions
+The function
.Fn setgroupent
-and
-.Fn setgrent
-return the value 1 if successful, otherwise the value
+returns the value 1 if successful, otherwise the value
0 is returned.
The functions
-.Fn endgrent
+.Fn endgrent ,
+.Fn setgrent
and
.Fn setgrfile
have no return value.
Modified: head/lib/libc/gen/getgrent.c
==============================================================================
--- head/lib/libc/gen/getgrent.c Sun Jul 31 06:53:50 2016 (r303579)
+++ head/lib/libc/gen/getgrent.c Sun Jul 31 08:05:15 2016 (r303580)
@@ -533,12 +533,10 @@ out:
return (rv);
}
-/* XXX IEEE Std 1003.1, 2003 specifies `void setgrent(void)' */
-int
+void
setgrent(void)
{
(void)_nsdispatch(NULL, setgrent_dtab, NSDB_GROUP, "setgrent", defaultsrc, 0);
- return (1);
}
Modified: head/usr.sbin/pw/pw_vpw.c
==============================================================================
--- head/usr.sbin/pw/pw_vpw.c Sun Jul 31 06:53:50 2016 (r303579)
+++ head/usr.sbin/pw/pw_vpw.c Sun Jul 31 08:05:15 2016 (r303580)
@@ -130,13 +130,10 @@ vendgrent(void)
}
}
-RET_SETGRENT
+void
vsetgrent(void)
{
vendgrent();
-#if defined(__FreeBSD__)
- return 0;
-#endif
}
static struct group *
Modified: head/usr.sbin/pw/pwupd.h
==============================================================================
--- head/usr.sbin/pw/pwupd.h Sun Jul 31 06:53:50 2016 (r303579)
+++ head/usr.sbin/pw/pwupd.h Sun Jul 31 08:05:15 2016 (r303580)
@@ -38,12 +38,6 @@
#include <stdbool.h>
#include <stringlist.h>
-#if defined(__FreeBSD__)
-#define RET_SETGRENT int
-#else
-#define RET_SETGRENT void
-#endif
-
struct pwf {
int _altdir;
void (*_setpwent)(void);
@@ -51,7 +45,7 @@ struct pwf {
struct passwd * (*_getpwent)(void);
struct passwd * (*_getpwuid)(uid_t uid);
struct passwd * (*_getpwnam)(const char * nam);
- RET_SETGRENT (*_setgrent)(void);
+ void (*_setgrent)(void);
void (*_endgrent)(void);
struct group * (*_getgrent)(void);
struct group * (*_getgrgid)(gid_t gid);
@@ -141,7 +135,7 @@ struct passwd * vgetpwnam(const char * n
struct group * vgetgrent(void);
struct group * vgetgrgid(gid_t gid);
struct group * vgetgrnam(const char * nam);
-RET_SETGRENT vsetgrent(void);
+void vsetgrent(void);
void vendgrent(void);
void copymkdir(int rootfd, char const * dir, int skelfd, mode_t mode, uid_t uid,
More information about the svn-src-head
mailing list