about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/test-errno-linux.c
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/test-errno-linux.c
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/test-errno-linux.c')
-rw-r--r--sysdeps/unix/sysv/linux/test-errno-linux.c2
1 files changed, 1 insertions, 1 deletions
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);