From 35feaf1f27cd2ada2d52e3c21e0edb8f4abc2805 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Fri, 13 Sep 2019 17:19:20 +0200
Subject: [PATCH] Adjust various public struct members and one function
 argument to POSIX.

Specifically:

<ndbm.h>:     change dsize in struct datum from int to
              size_t (unsigned long)

<sys/ipc.h>:  change cuid, cgid, uid, gid and mode in struct ipc_perm
              from unsigned short to uid_t (unsigned int),
              gid_t (unsigned int) and mode_t (unsigned short)

<sys/stat.h>: change st_blocks from int64_t to blkcnt_t (long) and
              st_blksize from uint32_t to blksize_t (long)
---
 include/ndbm.h           |  4 +---
 include/rpcsvc/yp_prot.h |  3 +--
 lib/libc/db/man/dbm.3    |  4 ++--
 lib/libc/sys/msgctl.2    | 12 ++++++------
 lib/libc/sys/stat.2      |  6 +++---
 lib/libc/yp/xdryp.c      |  5 ++---
 sys/sys/ipc.h            | 14 +++++---------
 sys/sys/stat.h           |  7 ++-----
 8 files changed, 22 insertions(+), 33 deletions(-)

diff --git a/include/ndbm.h b/include/ndbm.h
index 5d025b935b..25ed78bba9 100644
--- a/include/ndbm.h
+++ b/include/ndbm.h
@@ -48,14 +48,12 @@
 /*
  * The db(3) support for ndbm always appends this suffix to the
  * file name to avoid overwriting the user's original database.
- *
- * XXX dsize should be size_t; see 1003.1-2008
  */
 #define	DBM_SUFFIX	".db"
 
 typedef struct {
 	void *dptr;
-	int dsize;
+	size_t dsize;
 } datum;
 
 typedef DB DBM;
diff --git a/include/rpcsvc/yp_prot.h b/include/rpcsvc/yp_prot.h
index 96caa57e57..eb359ce2fa 100644
--- a/include/rpcsvc/yp_prot.h
+++ b/include/rpcsvc/yp_prot.h
@@ -27,7 +27,6 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/include/rpcsvc/yp_prot.h,v 1.13 2005/12/06 02:01:06 peter Exp $
- * $DragonFly: src/include/rpcsvc/yp_prot.h,v 1.3 2004/12/15 09:44:47 dillon Exp $
  */
 
 #ifndef _RPCSVC_YP_PROT_H_
@@ -88,7 +87,7 @@
 #ifndef DATUM
 typedef struct {
 	char	*dptr;
-	int	dsize;
+	size_t	dsize;
 } datum;
 #define DATUM
 #endif
diff --git a/lib/libc/db/man/dbm.3 b/lib/libc/db/man/dbm.3
index 585e7e4b99..0a003098b9 100644
--- a/lib/libc/db/man/dbm.3
+++ b/lib/libc/db/man/dbm.3
@@ -15,7 +15,7 @@
 .\"
 .\" $FreeBSD: head/lib/libc/db/man/dbm.3 187918 2009-01-30 15:28:35Z gabor $
 .\"
-.Dd April 16, 2006
+.Dd September 13, 2019
 .Dt DBM 3
 .Os
 .Sh NAME
@@ -69,7 +69,7 @@ is declared in
 .Bd -literal
 typedef struct {
 	char *dptr;
-	int dsize;
+	size_t dsize;
 } datum;
 .Ed
 .Pp
diff --git a/lib/libc/sys/msgctl.2 b/lib/libc/sys/msgctl.2
index 15774e2576..a3af07b1a2 100644
--- a/lib/libc/sys/msgctl.2
+++ b/lib/libc/sys/msgctl.2
@@ -31,7 +31,7 @@
 .\"
 .\" $FreeBSD: src/lib/libc/gen/msgctl.3,v 1.8.2.7 2003/03/13 18:05:37 trhodes Exp $
 .\"
-.Dd September 12, 2019
+.Dd September 13, 2019
 .Dt MSGCTL 2
 .Os
 .Sh NAME
@@ -89,11 +89,11 @@ structure is defined in
 and looks like this:
 .Bd -literal
 struct ipc_perm {
-	ushort	cuid;	/* creator user id */
-	ushort	cgid;	/* creator group id */
-	ushort	uid;	/* user id */
-	ushort	gid;	/* group id */
-	ushort	mode;	/* r/w permission */
+	uid_t	cuid;	/* creator user id */
+	gid_t	cgid;	/* creator group id */
+	uid_t	uid;	/* user id */
+	gid_t	gid;	/* group id */
+	mode_t	mode;	/* r/w permission */
 	ushort	seq;	/* sequence # (to generate unique msg/sem/shm id) */
 	key_t	key;	/* user specified msg/sem/shm key */
 };
diff --git a/lib/libc/sys/stat.2 b/lib/libc/sys/stat.2
index 8dc32fc1f1..5791c250c5 100644
--- a/lib/libc/sys/stat.2
+++ b/lib/libc/sys/stat.2
@@ -28,7 +28,7 @@
 .\"     @(#)stat.2	8.4 (Berkeley) 5/1/95
 .\" $FreeBSD: src/lib/libc/sys/stat.2,v 1.16.2.7 2001/12/14 18:34:01 ru Exp $
 .\"
-.Dd August 3, 2016
+.Dd September 13, 2019
 .Dt STAT 2
 .Os
 .Sh NAME
@@ -141,8 +141,8 @@ struct stat {
     struct timespec st_mtim;        /* time of last data modification */
     struct timespec st_ctim;        /* time of last file status change */
     off_t     st_size;              /* file size, in bytes */
-    int64_t   st_blocks;            /* blocks allocated for file */
-    u_int32_t st_blksize;           /* optimal blocksize for I/O */
+    blkcnt_t  st_blocks;            /* blocks allocated for file */
+    blksize_t st_blksize;           /* optimal blocksize for I/O */
     u_int32_t st_flags;             /* user defined flags for file */
     u_int32_t st_gen;               /* file generation number */
     int32_t   st_lspare;
diff --git a/lib/libc/yp/xdryp.c b/lib/libc/yp/xdryp.c
index 779d49084b..3664cb8eef 100644
--- a/lib/libc/yp/xdryp.c
+++ b/lib/libc/yp/xdryp.c
@@ -27,7 +27,6 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/lib/libc/yp/xdryp.c,v 1.15 2008/03/26 07:32:06 brueffer Exp $
- * $DragonFly: src/lib/libc/yp/xdryp.c,v 1.4 2005/11/20 13:24:36 swildner Exp $
  */
 
 #include <rpc/rpc.h>
@@ -45,8 +44,8 @@ extern void *ypresp_data;
  * leave it in case somebody goes looking for it.
  */
 typedef struct {
-	char *dptr;
-	int  dsize;
+	char   *dptr;
+	size_t dsize;
 } datum;
 
 bool_t
diff --git a/sys/sys/ipc.h b/sys/sys/ipc.h
index 1936eb5f29..06c34b9615 100644
--- a/sys/sys/ipc.h
+++ b/sys/sys/ipc.h
@@ -49,16 +49,12 @@
 #include <sys/cdefs.h>
 #include <sys/types.h>
 
-/*
- * XXX cuid and uid should be uid_t; cgid and gid should be gid_t
- *     mode should be mode_t; see 1003.1-2008
- */
 struct ipc_perm {
-	unsigned short	cuid;	/* creator user id; XXX should be uid_t */
-	unsigned short	cgid;	/* creator group id; XXX should be gid_t */
-	unsigned short	uid;	/* user id; XXX should be uid_t */
-	unsigned short	gid;	/* group id; XXX should be gid_t */
-	unsigned short	mode;	/* r/w permission */
+	uid_t		cuid;	/* creator user id */
+	gid_t		cgid;	/* creator group id */
+	uid_t		uid;	/* user id */
+	gid_t		gid;	/* group id */
+	mode_t		mode;	/* r/w permission */
 	unsigned short	seq;	/* sequence # (to generate unique msg/sem/shm id) */
 	key_t		key;	/* user specified msg/sem/shm key */
 };
diff --git a/sys/sys/stat.h b/sys/sys/stat.h
index ad7152b40e..b69b4e4f6e 100644
--- a/sys/sys/stat.h
+++ b/sys/sys/stat.h
@@ -60,9 +60,6 @@
  * stat structure notes:
  *
  * NOTE: st_fsmid removed in DragonFly 2.5.x.
- *
- * XXX st_blocks should be blkcnt_t; st_blksize should be blksize_t;
- *     see 1003.1-2008
  */
 struct stat {
 	ino_t	  st_ino;		/* inode's number */
@@ -77,8 +74,8 @@ struct stat {
 	struct	timespec st_mtim;	/* time of last data modification */
 	struct	timespec st_ctim;	/* time of last file status change */
 	off_t	  st_size;		/* file size, in bytes */
-	int64_t	  st_blocks;		/* blocks allocated for file */
-	u_int32_t st_blksize;		/* optimal blocksize for I/O */
+	blkcnt_t  st_blocks;		/* blocks allocated for file */
+	blksize_t st_blksize;		/* optimal blocksize for I/O */
 	u_int32_t st_flags;		/* user defined flags for file */
 	u_int32_t st_gen;		/* file generation number */
 	int32_t	  st_lspare;
-- 
2.22.0

