about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2019-03-09 11:59:02 -0500
committerZack Weinberg <zackw@panix.com>2020-01-08 12:56:31 -0500
commit454939fdd0da872d25870daf4146889f0c3a9d45 (patch)
tree9a776dcc1426adee05473f9ee36b7abc3c0731bf /sysdeps/unix/sysv/linux
parent40782c2685760fc7fe9d82738e3091bfa5216c1c (diff)
downloadglibc-454939fdd0da872d25870daf4146889f0c3a9d45.tar.gz
glibc-454939fdd0da872d25870daf4146889f0c3a9d45.tar.xz
glibc-454939fdd0da872d25870daf4146889f0c3a9d45.zip
Add caddr_t, daddr_t, and loff_t to the set of obsolete typedefs.
caddr_t is a BSD-derived alias for ‘char *’, obsoleted by the
introduction of ‘void *’ in C89 (!)  daddr_t is a “disk address,”
but it’s always defined as ‘int’, making it too small for modern
disks and tapes.  loff_t is another name for off64_t, from early
drafts of LFS.  All three are already only exposed by sys/types.h
under __USE_MISC.

This patch adds them to the set of types that shall not be used in
installed headers (enforced by check-obsolete-constructs.py) and
expunges all remaining uses, internally as well as in installed
headers.  Since __DADDR_T_TYPE is always defined as __S32_TYPE, and
daddr_t is obsolete so there’s no need to worry about future
variation, the patch also removes __DADDR_T_TYPE from the set of
macros that bits/typesizes.h is required to define.  Instead
bits/types.h always defines __daddr_t as __S32_TYPE, and the
definition is moved to a more logical location within the file, next
to __caddr_t.

It’s always safe to change (__)loff_t to the matching (__)off64_t;
in a few internal files, I removed an unnecessary __ prefix.

daddr_t is only used for struct ustat, which is obsoleted by struct
statvfs and we already don’t declare it in public headers, and for an
ioctl parameter block in sys/mtio.h (which may or may not be obsolete,
I can’t tell).  In sys/mtio.h I replaced both uses with ‘int’ to match
the use of bare ‘long int’ for most of the other fields of that
structure.  In misc/ustat.c, the definition of struct ustat is not
actually necessary so I removed it entirely.  In
sysdeps/unix/sysv/linux/ustat.c a definition is necessary but only
because INLINE_SYSCALL_CALL doesn’t work (on at least x86) when an
argument is a pointer to an incomplete type, so I substituted a dummy
definition.

Most of the internal uses of caddr_t are in the sunrpc and nis
directories, and since most of that code is obsolete, I mechanically
replaced them with char * rather than consider whether void * might
make more sense.  Because “const caddr_t foo” is semantically
different from “const char *foo” (in the first case ‘foo’ itself is
const but the memory pointed to isn’t, in the second case the memory
pointed to is const but ‘foo’ isn’t) this change exposed some
const-correctness errors in sunrpc, which I fixed minimally.  Outside
of sunrpc and nis, I put a little more thought into whether uses of
caddr_t should be void * instead.

	* scripts/check-obsolete-constructs.py: Add caddr_t, daddr_t,
        and loff_t to the set of obsolete types forbidden in public
        headers.

	* posix/bits/types.h: Unconditionally define __daddr_t as
        __S32_TYPE.  Move definition of __daddr_t next to definition
        of __caddr_t.
	* bits/typesizes.h
	* sysdeps/mach/hurd/bits/typesizes.h
	* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
	* sysdeps/unix/sysv/linux/generic/bits/typesizes.h
	* sysdeps/unix/sysv/linux/mips/bits/typesizes.h
	* sysdeps/unix/sysv/linux/s390/bits/typesizes.h
	* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
	* sysdeps/unix/sysv/linux/x86/bits/typesizes.h:
        Don’t define __DADDR_T_TYPE.

        * sysdeps/gnu/sys/mtio.h (struct mtget): Change all uses of
	__daddr_t to int.
	* misc/ustat.c: Remove definition of struct ustat; only
        forward-declare it.
	* sysdeps/unix/sysv/linux/ustat.c: Replace fields of
        struct ustat with a size-preserving dummy field.

	* hurd/Makefile (migheaderpipe): Rewrite loff_t as __off64_t.
        * hurd/fd-read.c (_hurd_fd_read): Use off64_t instead of loff_t.
        * hurd/fd-write.c (hurd_fd_write): Use off64_t instead of loff_t.
        * hurd/hurd/fd.h (_hurd_fd_read, _hurd_fd_write): Declare
        using __off64_t instead of __loff_t.
        * support/xunistd.h (xcopy_file_range): Declare using off64_t
        instead of loff_t.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
	* sysdeps/unix/sysv/linux/lseek.c
	* sysdeps/unix/sysv/linux/lseek64.c
	* sysdeps/unix/sysv/linux/splice.c
        Throughout, use off64_t instead of loff_t.

	* sysdeps/unix/sysv/linux/sys/quota.h
        (dqoff): Use __off64_t instead of __loff_t.
        (quotactl): Declare using char * instead of caddr_t.
	* sysdeps/unix/sysv/linux/test-errno-linux.c
        (do_test): Cast to char * instead of caddr_t when calling quotactl.

	* elf/dl-map-segments.h (_dl_map_segments): Cast to void *
        instead of caddr_t when calling __mprotect and __mmap.
        * elf/dl-minimal.c (malloc): Declare page as char *, not caddr_t.
        * elf/dl-reloc.c (_dl_relocate_object): Declare textrels.start
        as char *, not caddr_t.  Cast to char *, not caddr_t, in
        pointer arithmetic.

	* intl/loadmsgcat.c: Remove two unnecessary casts to caddr_t
        when calling munmap. Change a third cast to target void *
        instead and add a comment explaining why this one is necessary.

	* locale/loadlocale.c (_nl_load_locale): Use NULL instead of
        `(caddr_t)0`, and remove an unnecessary cast to caddr_t when
        calling munmap.
        (_nl_unload_locale): Change casts when calling free and munmap
        to target char *, and add a comment explaining why they are
        necessary.

	* sysdeps/gnu/net/if.h
        (struct ifreq): Declare ifru_data as char *, not __caddr_t.
        (struct ifconf): Declare ifcu_buf as char *, not __caddr_t.

	* nis/nis_add.c
	* nis/nis_call.c
	* nis/nis_callback.c
	* nis/nis_checkpoint.c
	* nis/nis_findserv.c
	* nis/nis_intern.h
	* nis/nis_lookup.c
	* nis/nis_mkdir.c
	* nis/nis_modify.c
	* nis/nis_ping.c
	* nis/nis_remove.c
	* nis/nis_rmdir.c
	* nis/nis_server.c
	* nis/nis_table.c
	* nis/nis_util.c
	* nis/nss_nisplus/nisplus-grp.c
	* nis/nss_nisplus/nisplus-pwd.c
	* nis/rpcsvc/nis_callback.h
	* nis/rpcsvc/yp.h
	* nis/ypclnt.c
	* sunrpc/auth_des.c
	* sunrpc/auth_unix.c
	* sunrpc/authdes_prot.c
	* sunrpc/authuxprot.c
	* sunrpc/clnt_raw.c
	* sunrpc/clnt_tcp.c
	* sunrpc/clnt_udp.c
	* sunrpc/clnt_unix.c
	* sunrpc/key_call.c
	* sunrpc/pm_getmaps.c
	* sunrpc/pm_getport.c
	* sunrpc/pmap_clnt.c
	* sunrpc/pmap_prot2.c
	* sunrpc/pmap_rmt.c
	* sunrpc/proto.h
	* sunrpc/rpc/auth.h
	* sunrpc/rpc/clnt.h
	* sunrpc/rpc/pmap_clnt.h
	* sunrpc/rpc/pmap_rmt.h
	* sunrpc/rpc/rpc_msg.h
	* sunrpc/rpc/svc.h
	* sunrpc/rpc/xdr.h
	* sunrpc/rpc_clntout.c
	* sunrpc/rpc_cmsg.c
	* sunrpc/rpc_hout.c
	* sunrpc/rpc_prot.c
	* sunrpc/rpc_sample.c
	* sunrpc/rpc_svcout.c
	* sunrpc/svc.c
	* sunrpc/svc_authux.c
	* sunrpc/svc_raw.c
	* sunrpc/svc_tcp.c
	* sunrpc/svc_udp.c
	* sunrpc/svc_unix.c
	* sunrpc/xdr.c
	* sunrpc/xdr_array.c
	* sunrpc/xdr_mem.c
	* sunrpc/xdr_rec.c
	* sunrpc/xdr_ref.c
	* sunrpc/xdr_sizeof.c
	* sunrpc/xdr_stdio.c:
        Mechanically replace all uses of caddr_t with char *.

        * sunrpc/xdr_mem.c (xdrmem_create): Cast away const when
        setting xdrs->x_private and xdrs->x_base.
        * sunrpc/xdr_stdio.c (xdrstdio_getbytes): Correct argument
        types in definition to match prototype.
Diffstat (limited to 'sysdeps/unix/sysv/linux')
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/typesizes.h1
-rw-r--r--sysdeps/unix/sysv/linux/generic/bits/typesizes.h1
-rw-r--r--sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h2
-rw-r--r--sysdeps/unix/sysv/linux/lseek.c4
-rw-r--r--sysdeps/unix/sysv/linux/lseek64.c2
-rw-r--r--sysdeps/unix/sysv/linux/mips/bits/typesizes.h1
-rw-r--r--sysdeps/unix/sysv/linux/s390/bits/typesizes.h1
-rw-r--r--sysdeps/unix/sysv/linux/sparc/bits/typesizes.h1
-rw-r--r--sysdeps/unix/sysv/linux/splice.c2
-rw-r--r--sysdeps/unix/sysv/linux/sys/quota.h4
-rw-r--r--sysdeps/unix/sysv/linux/test-errno-linux.c2
-rw-r--r--sysdeps/unix/sysv/linux/ustat.c9
-rw-r--r--sysdeps/unix/sysv/linux/x86/bits/typesizes.h1
13 files changed, 13 insertions, 18 deletions
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
index 44e5381822..13e0428c40 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
@@ -49,7 +49,6 @@
 #define __TIME_T_TYPE		__SLONGWORD_TYPE
 #define __USECONDS_T_TYPE	__U32_TYPE
 #define __SUSECONDS_T_TYPE	__S64_TYPE
-#define __DADDR_T_TYPE		__S32_TYPE
 #define __KEY_T_TYPE		__S32_TYPE
 #define __CLOCKID_T_TYPE	__S32_TYPE
 #define __TIMER_T_TYPE		void *
diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
index 47b91568dd..c7e72f3ca5 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
@@ -51,7 +51,6 @@
 #define __TIME_T_TYPE		__SLONGWORD_TYPE
 #define __USECONDS_T_TYPE	__U32_TYPE
 #define __SUSECONDS_T_TYPE	__SLONGWORD_TYPE
-#define __DADDR_T_TYPE		__S32_TYPE
 #define __KEY_T_TYPE		__S32_TYPE
 #define __CLOCKID_T_TYPE	__S32_TYPE
 #define __TIMER_T_TYPE		void *
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
index c5e028625a..08e96d0d00 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
@@ -24,7 +24,7 @@
    in with standard 64-bit syscalls but return them through APIs that
    only expose the low 32 bits of some fields.  */
 
-static inline off_t lseek_overflow (loff_t res)
+static inline off_t lseek_overflow (off64_t res)
 {
   off_t retval = (off_t) res;
   if (retval == res)
diff --git a/sysdeps/unix/sysv/linux/lseek.c b/sysdeps/unix/sysv/linux/lseek.c
index 3b3e0c4a8b..0576835291 100644
--- a/sysdeps/unix/sysv/linux/lseek.c
+++ b/sysdeps/unix/sysv/linux/lseek.c
@@ -28,7 +28,7 @@
    in with standard 64-bit syscalls but return them through APIs that
    only expose the low 32 bits of some fields.  */
 
-static inline off_t lseek_overflow (loff_t res)
+static inline off_t lseek_overflow (off64_t res)
 {
   off_t retval = (off_t) res;
   if (retval == res)
@@ -42,7 +42,7 @@ off_t
 __lseek (int fd, off_t offset, int whence)
 {
 # ifdef __NR__llseek
-  loff_t res;
+  off64_t res;
   int rc = INLINE_SYSCALL_CALL (_llseek, fd,
 				(long) (((uint64_t) (offset)) >> 32),
 				(long) offset, &res, whence);
diff --git a/sysdeps/unix/sysv/linux/lseek64.c b/sysdeps/unix/sysv/linux/lseek64.c
index d1aee524e2..8a53dea9f9 100644
--- a/sysdeps/unix/sysv/linux/lseek64.c
+++ b/sysdeps/unix/sysv/linux/lseek64.c
@@ -27,7 +27,7 @@ off64_t
 __lseek64 (int fd, off64_t offset, int whence)
 {
 #ifdef __NR__llseek
-  loff_t res;
+  off64_t res;
   int rc = INLINE_SYSCALL_CALL (_llseek, fd,
 				(long) (((uint64_t) (offset)) >> 32),
 				(long) offset, &res, whence);
diff --git a/sysdeps/unix/sysv/linux/mips/bits/typesizes.h b/sysdeps/unix/sysv/linux/mips/bits/typesizes.h
index 1132670b1c..7c1bedd9af 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/typesizes.h
@@ -50,7 +50,6 @@
 #define __TIME_T_TYPE		__SLONGWORD_TYPE
 #define __USECONDS_T_TYPE	__U32_TYPE
 #define __SUSECONDS_T_TYPE	__SLONGWORD_TYPE
-#define __DADDR_T_TYPE		__S32_TYPE
 #define __KEY_T_TYPE		__S32_TYPE
 #define __CLOCKID_T_TYPE	__S32_TYPE
 #define __TIMER_T_TYPE		void *
diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
index 91c601d0fe..e812109140 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
@@ -50,7 +50,6 @@
 #define __TIME_T_TYPE		__SLONGWORD_TYPE
 #define __USECONDS_T_TYPE	__U32_TYPE
 #define __SUSECONDS_T_TYPE	__SLONGWORD_TYPE
-#define __DADDR_T_TYPE		__S32_TYPE
 #define __KEY_T_TYPE		__S32_TYPE
 #define __CLOCKID_T_TYPE	__S32_TYPE
 #define __TIMER_T_TYPE		void *
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
index d19742d932..830a45f01c 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
@@ -50,7 +50,6 @@
 #define __TIME_T_TYPE		__SLONGWORD_TYPE
 #define __USECONDS_T_TYPE	__U32_TYPE
 #define __SUSECONDS_T_TYPE	__S32_TYPE
-#define __DADDR_T_TYPE		__S32_TYPE
 #define __KEY_T_TYPE		__S32_TYPE
 #define __CLOCKID_T_TYPE	__S32_TYPE
 #define __TIMER_T_TYPE		void *
diff --git a/sysdeps/unix/sysv/linux/splice.c b/sysdeps/unix/sysv/linux/splice.c
index fe21cf1988..36e5d0ad35 100644
--- a/sysdeps/unix/sysv/linux/splice.c
+++ b/sysdeps/unix/sysv/linux/splice.c
@@ -20,7 +20,7 @@
 #include <sysdep-cancel.h>
 
 ssize_t
-splice (int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len,
+splice (int fd_in, off64_t *off_in, int fd_out, off64_t *off_out, size_t len,
 	unsigned int flags)
 {
   return SYSCALL_CANCEL (splice, fd_in, off_in, fd_out, off_out, len, flags);
diff --git a/sysdeps/unix/sysv/linux/sys/quota.h b/sysdeps/unix/sysv/linux/sys/quota.h
index 2178d839d2..23f00684b6 100644
--- a/sysdeps/unix/sysv/linux/sys/quota.h
+++ b/sysdeps/unix/sysv/linux/sys/quota.h
@@ -114,7 +114,7 @@ struct dqblk
 #define	dq_btime	dq_dqb.dqb_btime
 #define	dq_itime	dq_dqb.dqb_itime
 
-#define dqoff(UID)      ((__loff_t)((UID) * sizeof (struct dqblk)))
+#define dqoff(UID)      ((__off64_t)((UID) * sizeof (struct dqblk)))
 
 /* Old name for struct if_dqinfo.  */
 struct dqinfo
@@ -128,7 +128,7 @@ struct dqinfo
 __BEGIN_DECLS
 
 extern int quotactl (int __cmd, const char *__special, int __id,
-		     __caddr_t __addr) __THROW;
+		     char *__addr) __THROW;
 
 __END_DECLS
 
diff --git a/sysdeps/unix/sysv/linux/test-errno-linux.c b/sysdeps/unix/sysv/linux/test-errno-linux.c
index b748f8f2a0..0bd1fbeffe 100644
--- a/sysdeps/unix/sysv/linux/test-errno-linux.c
+++ b/sysdeps/unix/sysv/linux/test-errno-linux.c
@@ -163,7 +163,7 @@ do_test (void)
      of containers.  Linux 5.4 added additional argument validation
      and can return EINVAL.  */
   fails |= test_wrp2 (LIST (ENODEV, ENOSYS, EPERM, EINVAL),
-		      quotactl, Q_GETINFO, NULL, -1, (caddr_t) &dqblk);
+		      quotactl, Q_GETINFO, NULL, -1, (char *) &dqblk);
   fails |= test_wrp (EINVAL, sched_getparam, -1, &sch_param);
   fails |= test_wrp (EINVAL, sched_getscheduler, -1);
   fails |= test_wrp (EINVAL, sched_get_priority_max, -1);
diff --git a/sysdeps/unix/sysv/linux/ustat.c b/sysdeps/unix/sysv/linux/ustat.c
index 51f20a2a73..8d8b99aea4 100644
--- a/sysdeps/unix/sysv/linux/ustat.c
+++ b/sysdeps/unix/sysv/linux/ustat.c
@@ -36,12 +36,13 @@
   })
 # endif
 
+/* INLINE_SYSCALL_CALL requires all pointer arguments to point to
+   complete types, but we do not need to access any of the fields of
+   this structure.  It was formerly 20, 24, or 32 bytes, depending on
+   architecture and _FILE_OFFSET_BITS.  */
 struct ustat
 {
-  __daddr_t f_tfree;         /* Number of free blocks.  */
-  __ino_t f_tinode;          /* Number of free inodes.  */
-  char f_fname[6];
-  char f_fpack[6];
+  char dummy[32];
 };
 
 int
diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
index 67ebbb2e17..55f9a4c430 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
@@ -66,7 +66,6 @@
 #define __TIME_T_TYPE		__SYSCALL_SLONG_TYPE
 #define __USECONDS_T_TYPE	__U32_TYPE
 #define __SUSECONDS_T_TYPE	__SYSCALL_SLONG_TYPE
-#define __DADDR_T_TYPE		__S32_TYPE
 #define __KEY_T_TYPE		__S32_TYPE
 #define __CLOCKID_T_TYPE	__S32_TYPE
 #define __TIMER_T_TYPE		void *