On 1/31/07, Robert Watson <[EMAIL PROTECTED]> wrote:
If we do decide to go ahead with the ABI change, there are a number of other
things that should be done simultaneously, such as changing the uid and gid
fields to uid_t and gid_t.  I would very much like to see the ABI change
happen, and the first step (breaking out kernel from user structures) has been
done already as part of the MAC work.  The next step is to add routines that
translate internal/external formats, which isn't hard, but requires a moderate
pile of code to do (as well as great care :-).

Well .. i finally found some spare time to have a closer look at the
"shm_segsz" issue ... and noticed there were actually a very limited
number of direct uses of the shm_segsz struct member (26 lines in the
entire /usr/src tree)

I have attached a patchset that should change shm_segsz to size_t.
There were however 2 to 3 locations all regarding compat code (ibcs2,
svr4 and COMPAT_43) where i opted to stay on the clear side and not
touch anything, the rest was fairly straightforward as should be
obvious from the diff. I checked to make sure no function prototypes
changed anywhere.

Please have a look at the attached patch (available at
http://callisto.offis.uni-oldenburg.de/shm_segsz-int2size_t.diff in
case the attachment gets stripped off by the mailinglist software) and
provide any feedback where appropriate.

--
 Pascal Hofstee
diff -rwuBb src.ref/lib/libc/sys/shmctl.2 src/lib/libc/sys/shmctl.2
--- src.ref/lib/libc/sys/shmctl.2	Thu Feb 15 09:55:01 2007
+++ src/lib/libc/sys/shmctl.2	Thu Feb 15 09:56:49 2007
@@ -100,7 +100,7 @@
 .Bd -literal
 struct shmid_ds {
     struct ipc_perm shm_perm;   /* operation permission structure */
-    int             shm_segsz;  /* size of segment in bytes */
+    size_t          shm_segsz;  /* size of segment in bytes */
     pid_t           shm_lpid;   /* process ID of last shared memory op */
     pid_t           shm_cpid;   /* process ID of creator */
     short           shm_nattch; /* number of current attaches */
diff -rwuBb src.ref/sys/compat/freebsd32/freebsd32_misc.c src/sys/compat/freebsd32/freebsd32_misc.c
--- src.ref/sys/compat/freebsd32/freebsd32_misc.c	Thu Feb 15 09:49:53 2007
+++ src/sys/compat/freebsd32/freebsd32_misc.c	Thu Feb 15 09:59:05 2007
@@ -1445,7 +1445,7 @@
 };
 struct shmid_ds32 {
 	struct ipc_perm32 shm_perm;
-	int32_t		shm_segsz;
+	size_t		shm_segsz;
 	int32_t		shm_lpid;
 	int32_t		shm_cpid;
 	int16_t		shm_nattch;
diff -rwuBb src.ref/sys/compat/linux/linux_ipc.c src/sys/compat/linux/linux_ipc.c
--- src.ref/sys/compat/linux/linux_ipc.c	Thu Feb 15 09:49:53 2007
+++ src/sys/compat/linux/linux_ipc.c	Thu Feb 15 10:03:43 2007
@@ -187,7 +187,7 @@
 
 struct l_shmid_ds {
 	struct l_ipc_perm	shm_perm;
-	l_int			shm_segsz;
+	l_size_t		shm_segsz;
 	l_time_t		shm_atime;
 	l_time_t		shm_dtime;
 	l_time_t		shm_ctime;
diff -rwuBb src.ref/sys/sys/shm.h src/sys/sys/shm.h
--- src.ref/sys/sys/shm.h	Thu Feb 15 09:52:13 2007
+++ src/sys/sys/shm.h	Thu Feb 15 10:14:56 2007
@@ -77,7 +77,7 @@
 
 struct shmid_ds {
 	struct ipc_perm shm_perm;	/* operation permission structure */
-	int             shm_segsz;	/* size of segment in bytes */
+	size_t          shm_segsz;	/* size of segment in bytes */
 	pid_t           shm_lpid;   /* process ID of last shared memory op */
 	pid_t           shm_cpid;	/* process ID of creator */
 	short		shm_nattch;	/* number of current attaches */
diff -rwuBb src.ref/tools/regression/sysvshm/shmtest.c src/tools/regression/sysvshm/shmtest.c
--- src.ref/tools/regression/sysvshm/shmtest.c	Thu Feb 15 09:49:36 2007
+++ src/tools/regression/sysvshm/shmtest.c	Thu Feb 15 10:22:24 2007
@@ -247,8 +247,8 @@
 	    sp->shm_perm.cuid, sp->shm_perm.cgid,
 	    sp->shm_perm.mode & 0777);
 
-	printf("segsz %lu, lpid %d, cpid %d, nattch %u\n",
-	    (u_long)sp->shm_segsz, sp->shm_lpid, sp->shm_cpid,
+	printf("segsz %zu, lpid %d, cpid %d, nattch %u\n",
+	    sp->shm_segsz, sp->shm_lpid, sp->shm_cpid,
 	    sp->shm_nattch);
 
 	printf("atime: %s", ctime(&sp->shm_atime));
diff -rwuBb src.ref/usr.bin/ipcs/ipcs.c src/usr.bin/ipcs/ipcs.c
--- src.ref/usr.bin/ipcs/ipcs.c	Thu Feb 15 09:49:15 2007
+++ src/usr.bin/ipcs/ipcs.c	Thu Feb 15 10:20:27 2007
@@ -439,7 +439,7 @@
 						    kshmptr->u.shm_nattch);
 
 					if (option & BIGGEST)
-						printf(" %12d",
+						printf(" %12zu",
 						    kshmptr->u.shm_segsz);
 
 					if (option & PID)
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to