diff options
Diffstat (limited to 'misc')
170 files changed, 1477 insertions, 617 deletions
diff --git a/misc/Makefile b/misc/Makefile index b7be2bc19a..1a74b3c3e4 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2018 Free Software Foundation, Inc. +# Copyright (C) 1991-2019 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ # You should have received a copy of the GNU Lesser General Public # License along with the GNU C Library; if not, see -# <http://www.gnu.org/licenses/>. +# <https://www.gnu.org/licenses/>. # # Sub-makefile for misc portion of the library. @@ -36,7 +36,8 @@ headers := sys/uio.h bits/uio-ext.h bits/uio_lim.h \ syslog.h sys/syslog.h \ bits/syslog.h bits/syslog-ldbl.h bits/syslog-path.h bits/error.h \ bits/select2.h bits/hwcap.h sys/auxv.h \ - sys/sysmacros.h bits/sysmacros.h bits/types/struct_iovec.h + sys/sysmacros.h bits/sysmacros.h bits/types/struct_iovec.h \ + bits/err-ldbl.h bits/error-ldbl.h routines := brk sbrk sstk ioctl \ readv writev preadv preadv64 pwritev pwritev64 \ @@ -80,11 +81,18 @@ aux := init-misc install-lib := libg.a gpl2lgpl := error.c error.h -tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \ +tests := tst-dirname tst-tsearch tst-fdset tst-mntent tst-hsearch \ tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1 \ tst-mntent-blank-corrupt tst-mntent-blank-passno bug18240 \ tst-preadvwritev tst-preadvwritev64 tst-makedev tst-empty \ - tst-preadvwritev2 tst-preadvwritev64v2 + tst-preadvwritev2 tst-preadvwritev64v2 tst-warn-wide \ + tst-ldbl-warn tst-ldbl-error tst-dbl-efgcvt tst-ldbl-efgcvt \ + tst-mntent-autofs + +# Tests which need libdl. +ifeq (yes,$(build-shared)) +tests += tst-gethostid +endif tests-internal := tst-atomic tst-atomic-long tst-allocate_once tests-static := tst-empty @@ -145,3 +153,5 @@ tst-allocate_once-ENV = MALLOC_TRACE=$(objpfx)tst-allocate_once.mtrace $(objpfx)tst-allocate_once-mem.out: $(objpfx)tst-allocate_once.out $(common-objpfx)malloc/mtrace $(objpfx)tst-allocate_once.mtrace > $@; \ $(evaluate-test) + +$(objpfx)tst-gethostid: $(libdl) diff --git a/misc/Versions b/misc/Versions index 900e4ffb79..e749582369 100644 --- a/misc/Versions +++ b/misc/Versions @@ -158,11 +158,14 @@ libc { GLIBC_2.26 { preadv2; preadv64v2; pwritev2; pwritev64v2; } + GLIBC_2.30 { + twalk_r; + } GLIBC_PRIVATE { __madvise; __mktemp; __libc_ifunc_impl_list; - __tdelete; __tfind; __tsearch; __twalk; + __tdelete; __tfind; __tsearch; __twalk; __twalk_r; __mmap; __munmap; __mprotect; __sched_get_priority_min; __sched_get_priority_max; __libc_allocate_once_slow; diff --git a/misc/acct.c b/misc/acct.c index bfe5faba62..70f4fc379e 100644 --- a/misc/acct.c +++ b/misc/acct.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/allocate_once.c b/misc/allocate_once.c index 2108014604..564d8c8fdb 100644 --- a/misc/allocate_once.c +++ b/misc/allocate_once.c @@ -1,5 +1,5 @@ /* Concurrent allocation and initialization of a pointer. - Copyright (C) 2018 Free Software Foundation, Inc. + Copyright (C) 2018-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <allocate_once.h> #include <stdlib.h> @@ -1,5 +1,5 @@ /* Header describing `ar' archive file format. - Copyright (C) 1996-2018 Free Software Foundation, Inc. + Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _AR_H #define _AR_H 1 diff --git a/misc/bits/err-ldbl.h b/misc/bits/err-ldbl.h new file mode 100644 index 0000000000..ca6e299b59 --- /dev/null +++ b/misc/bits/err-ldbl.h @@ -0,0 +1,30 @@ +/* Redirections for err.h functions for -mlong-double-64. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef _ERR_H +# error "Never include <bits/err-ldbl.h> directly; use <err.h> instead." +#endif + +__LDBL_REDIR_DECL (warn) +__LDBL_REDIR_DECL (vwarn) +__LDBL_REDIR_DECL (warnx) +__LDBL_REDIR_DECL (vwarnx) +__LDBL_REDIR_DECL (err) +__LDBL_REDIR_DECL (verr) +__LDBL_REDIR_DECL (errx) +__LDBL_REDIR_DECL (verrx) diff --git a/misc/bits/error-ldbl.h b/misc/bits/error-ldbl.h new file mode 100644 index 0000000000..4392340a52 --- /dev/null +++ b/misc/bits/error-ldbl.h @@ -0,0 +1,24 @@ +/* Redirections for error.h functions for -mlong-double-64. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef _ERROR_H +# error "Never include <bits/error-ldbl.h> directly; use <error.h> instead." +#endif + +__LDBL_REDIR_DECL (error) +__LDBL_REDIR_DECL (error_at_line) diff --git a/misc/bits/error.h b/misc/bits/error.h index 682cf2060e..ecde4b7850 100644 --- a/misc/bits/error.h +++ b/misc/bits/error.h @@ -1,5 +1,5 @@ /* Specializations for error functions. - Copyright (C) 2007-2018 Free Software Foundation, Inc. + Copyright (C) 2007-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _ERROR_H # error "Never include <bits/error.h> directly; use <error.h> instead." diff --git a/misc/bits/select2.h b/misc/bits/select2.h index 7194148997..d6b1f22c29 100644 --- a/misc/bits/select2.h +++ b/misc/bits/select2.h @@ -1,5 +1,5 @@ /* Checking macros for select functions. - Copyright (C) 2011-2018 Free Software Foundation, Inc. + Copyright (C) 2011-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SYS_SELECT_H # error "Never include <bits/select2.h> directly; use <sys/select.h> instead." diff --git a/misc/bits/stab.def b/misc/bits/stab.def index ab44580e95..c61feb1171 100644 --- a/misc/bits/stab.def +++ b/misc/bits/stab.def @@ -1,5 +1,5 @@ /* Table of DBX symbol codes for the GNU system. - Copyright (C) 1988, 1997-2018 Free Software Foundation, Inc. + Copyright (C) 1988, 1997-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ /* This contains contribution from Cygnus Support. */ diff --git a/misc/bits/syslog-ldbl.h b/misc/bits/syslog-ldbl.h index 977f90a9fe..8d60fb8e44 100644 --- a/misc/bits/syslog-ldbl.h +++ b/misc/bits/syslog-ldbl.h @@ -1,5 +1,5 @@ /* -mlong-double-64 compatibility mode for syslog functions. - Copyright (C) 2006-2018 Free Software Foundation, Inc. + Copyright (C) 2006-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SYS_SYSLOG_H # error "Never include <bits/syslog-ldbl.h> directly; use <sys/syslog.h> instead." diff --git a/misc/bits/syslog.h b/misc/bits/syslog.h index 6719fbe795..f6b107ffe9 100644 --- a/misc/bits/syslog.h +++ b/misc/bits/syslog.h @@ -1,5 +1,5 @@ /* Checking macros for syslog functions. - Copyright (C) 2005-2018 Free Software Foundation, Inc. + Copyright (C) 2005-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SYS_SYSLOG_H # error "Never include <bits/syslog.h> directly; use <sys/syslog.h> instead." diff --git a/misc/bits/types/struct_iovec.h b/misc/bits/types/struct_iovec.h index 490b06b89b..5ce2dfcb48 100644 --- a/misc/bits/types/struct_iovec.h +++ b/misc/bits/types/struct_iovec.h @@ -1,5 +1,5 @@ /* Define struct iovec. - Copyright (C) 1996-2018 Free Software Foundation, Inc. + Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef __iovec_defined #define __iovec_defined 1 diff --git a/misc/brk.c b/misc/brk.c index 2dea69acb3..b18e9a3a0b 100644 --- a/misc/brk.c +++ b/misc/brk.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/bug18240.c b/misc/bug18240.c index b1471698d0..d08e1c49ca 100644 --- a/misc/bug18240.c +++ b/misc/bug18240.c @@ -1,5 +1,5 @@ /* Test integer wraparound in hcreate. - Copyright (C) 2016-2018 Free Software Foundation, Inc. + Copyright (C) 2016-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <limits.h> diff --git a/misc/chflags.c b/misc/chflags.c index 7e6a21478e..d8b6d140a8 100644 --- a/misc/chflags.c +++ b/misc/chflags.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <stddef.h> diff --git a/misc/chroot.c b/misc/chroot.c index 630f88329c..e7d1a96b43 100644 --- a/misc/chroot.c +++ b/misc/chroot.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/dirname.c b/misc/dirname.c index 11797a1492..1928fc95e2 100644 --- a/misc/dirname.c +++ b/misc/dirname.c @@ -1,5 +1,5 @@ /* dirname - return directory part of PATH. - Copyright (C) 1996-2018 Free Software Foundation, Inc. + Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <libgen.h> #include <string.h> diff --git a/misc/efgcvt.c b/misc/efgcvt.c index 0081c1a499..492e4e8086 100644 --- a/misc/efgcvt.c +++ b/misc/efgcvt.c @@ -1,5 +1,5 @@ /* Compatibility functions for floating point formatting. - Copyright (C) 1995-2018 Free Software Foundation, Inc. + Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <math.h> #include <stdio.h> diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c index aa3a3cd279..981249850c 100644 --- a/misc/efgcvt_r.c +++ b/misc/efgcvt_r.c @@ -1,5 +1,5 @@ /* Compatibility functions for floating point formatting, reentrant versions. - Copyright (C) 1995-2018 Free Software Foundation, Inc. + Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <float.h> diff --git a/misc/err.c b/misc/err.c index 2b836e8358..106abc4e4c 100644 --- a/misc/err.c +++ b/misc/err.c @@ -1,5 +1,5 @@ /* 4.4BSD utility functions for error messages. - Copyright (C) 1995-2018 Free Software Foundation, Inc. + Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <stdarg.h> #include <err.h> @@ -37,104 +37,53 @@ extern char *__progname; va_end (ap); \ } -static void -convert_and_print (const char *format, __gnuc_va_list ap) -{ -#define ALLOCA_LIMIT 2000 - size_t len; - wchar_t *wformat = NULL; - mbstate_t st; - size_t res; - const char *tmp; - - if (format == NULL) - return; - - len = strlen (format) + 1; - - do - { - if (len < ALLOCA_LIMIT) - wformat = (wchar_t *) alloca (len * sizeof (wchar_t)); - else - { - if (wformat != NULL && len / 2 < ALLOCA_LIMIT) - wformat = NULL; - - wformat = (wchar_t *) realloc (wformat, len * sizeof (wchar_t)); - - if (wformat == NULL) - { - fputws_unlocked (L"out of memory\n", stderr); - return; - } - } - - memset (&st, '\0', sizeof (st)); - tmp =format; - } - while ((res = __mbsrtowcs (wformat, &tmp, len, &st)) == len); - - if (res == (size_t) -1) - /* The string cannot be converted. */ - wformat = (wchar_t *) L"???"; - - __vfwprintf (stderr, wformat, ap); -} - void -vwarnx (const char *format, __gnuc_va_list ap) +__vwarnx_internal (const char *format, __gnuc_va_list ap, + unsigned int mode_flags) { flockfile (stderr); - if (_IO_fwide (stderr, 0) > 0) - { - __fwprintf (stderr, L"%s: ", __progname); - convert_and_print (format, ap); - putwc_unlocked (L'\n', stderr); - } - else - { - fprintf (stderr, "%s: ", __progname); - if (format) - vfprintf (stderr, format, ap); - putc_unlocked ('\n', stderr); - } + __fxprintf (stderr, "%s: ", __progname); + if (format != NULL) + __vfxprintf (stderr, format, ap, mode_flags); + __fxprintf (stderr, "\n"); funlockfile (stderr); } -libc_hidden_def (vwarnx) void -vwarn (const char *format, __gnuc_va_list ap) +__vwarn_internal (const char *format, __gnuc_va_list ap, + unsigned int mode_flags) { int error = errno; flockfile (stderr); - if (_IO_fwide (stderr, 0) > 0) + if (format != NULL) { - __fwprintf (stderr, L"%s: ", __progname); - if (format) - { - convert_and_print (format, ap); - fputws_unlocked (L": ", stderr); - } + __fxprintf (stderr, "%s: ", __progname); + __vfxprintf (stderr, format, ap, mode_flags); __set_errno (error); - __fwprintf (stderr, L"%m\n"); + __fxprintf (stderr, ": %m\n"); } else { - fprintf (stderr, "%s: ", __progname); - if (format) - { - vfprintf (stderr, format, ap); - fputs_unlocked (": ", stderr); - } __set_errno (error); - fprintf (stderr, "%m\n"); + __fxprintf (stderr, "%s: %m\n", __progname); } funlockfile (stderr); } + +void +vwarn (const char *format, __gnuc_va_list ap) +{ + __vwarn_internal (format, ap, 0); +} libc_hidden_def (vwarn) +void +vwarnx (const char *format, __gnuc_va_list ap) +{ + __vwarnx_internal (format, ap, 0); +} +libc_hidden_def (vwarnx) void warn (const char *format, ...) diff --git a/misc/err.h b/misc/err.h index fec4fd2f77..a71b3fafe0 100644 --- a/misc/err.h +++ b/misc/err.h @@ -1,5 +1,5 @@ /* 4.4BSD utility functions for error messages. - Copyright (C) 1995-2018 Free Software Foundation, Inc. + Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _ERR_H #define _ERR_H 1 @@ -52,6 +52,10 @@ extern void errx (int __status, const char *__format, ...) extern void verrx (int __status, const char *, __gnuc_va_list) __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0))); +#ifdef __LDBL_COMPAT +# include <bits/err-ldbl.h> +#endif + __END_DECLS #endif /* err.h */ diff --git a/misc/error.c b/misc/error.c index b4e8b6c938..c407b01e21 100644 --- a/misc/error.c +++ b/misc/error.c @@ -1,5 +1,5 @@ /* Error handler for noninteractive utilities - Copyright (C) 1990-2018 Free Software Foundation, Inc. + Copyright (C) 1990-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ /* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */ @@ -200,75 +200,18 @@ print_errno_message (int errnum) } static void _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) _GL_ARG_NONNULL ((3)) -error_tail (int status, int errnum, const char *message, va_list args) +error_tail (int status, int errnum, const char *message, va_list args, + unsigned int mode_flags) { #if _LIBC - if (_IO_fwide (stderr, 0) > 0) - { - size_t len = strlen (message) + 1; - wchar_t *wmessage = NULL; - mbstate_t st; - size_t res; - const char *tmp; - bool use_malloc = false; - - while (1) - { - if (__libc_use_alloca (len * sizeof (wchar_t))) - wmessage = (wchar_t *) alloca (len * sizeof (wchar_t)); - else - { - if (!use_malloc) - wmessage = NULL; - - wchar_t *p = (wchar_t *) realloc (wmessage, - len * sizeof (wchar_t)); - if (p == NULL) - { - free (wmessage); - fputws_unlocked (L"out of memory\n", stderr); - return; - } - wmessage = p; - use_malloc = true; - } - - memset (&st, '\0', sizeof (st)); - tmp = message; - - res = mbsrtowcs (wmessage, &tmp, len, &st); - if (res != len) - break; - - if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0)) - { - /* This really should not happen if everything is fine. */ - res = (size_t) -1; - break; - } - - len *= 2; - } - - if (res == (size_t) -1) - { - /* The string cannot be converted. */ - if (use_malloc) - { - free (wmessage); - use_malloc = false; - } - wmessage = (wchar_t *) L"???"; - } - - __vfwprintf (stderr, wmessage, args); - - if (use_malloc) - free (wmessage); - } - else + int ret = __vfxprintf (stderr, message, args, mode_flags); + if (ret < 0 && errno == ENOMEM && _IO_fwide (stderr, 0) > 0) + /* Leave a trace in case the heap allocation of the message string + failed. */ + fputws_unlocked (L"out of memory\n", stderr); +#else + vfprintf (stderr, message, args); #endif - vfprintf (stderr, message, args); va_end (args); ++error_message_count; @@ -290,10 +233,9 @@ error_tail (int status, int errnum, const char *message, va_list args) If ERRNUM is nonzero, print its corresponding system error message. Exit with status STATUS if it is nonzero. */ void -error (int status, int errnum, const char *message, ...) +__error_internal (int status, int errnum, const char *message, + va_list args, unsigned int mode_flags) { - va_list args; - #if defined _LIBC && defined __libc_ptf_call /* We do not want this call to be cut short by a thread cancellation. Therefore disable cancellation for now. */ @@ -317,8 +259,7 @@ error (int status, int errnum, const char *message, ...) #endif } - va_start (args, message); - error_tail (status, errnum, message, args); + error_tail (status, errnum, message, args, mode_flags); #ifdef _LIBC _IO_funlockfile (stderr); @@ -327,17 +268,25 @@ error (int status, int errnum, const char *message, ...) # endif #endif } + +void +error (int status, int errnum, const char *message, ...) +{ + va_list ap; + va_start (ap, message); + __error_internal (status, errnum, message, ap, 0); + va_end (ap); +} /* Sometimes we want to have at most one error per line. This variable controls whether this mode is selected or not. */ int error_one_per_line; void -error_at_line (int status, int errnum, const char *file_name, - unsigned int line_number, const char *message, ...) +__error_at_line_internal (int status, int errnum, const char *file_name, + unsigned int line_number, const char *message, + va_list args, unsigned int mode_flags) { - va_list args; - if (error_one_per_line) { static const char *old_file_name; @@ -388,8 +337,7 @@ error_at_line (int status, int errnum, const char *file_name, file_name, line_number); #endif - va_start (args, message); - error_tail (status, errnum, message, args); + error_tail (status, errnum, message, args, mode_flags); #ifdef _LIBC _IO_funlockfile (stderr); @@ -399,6 +347,17 @@ error_at_line (int status, int errnum, const char *file_name, #endif } +void +error_at_line (int status, int errnum, const char *file_name, + unsigned int line_number, const char *message, ...) +{ + va_list ap; + va_start (ap, message); + __error_at_line_internal (status, errnum, file_name, line_number, + message, ap, 0); + va_end (ap); +} + #ifdef _LIBC /* Make the weak alias. */ # undef error diff --git a/misc/error.h b/misc/error.h index fcd5ad90dc..79840bf0f7 100644 --- a/misc/error.h +++ b/misc/error.h @@ -1,5 +1,5 @@ /* Declaration for error-reporting function - Copyright (C) 1995-2018 Free Software Foundation, Inc. + Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _ERROR_H #define _ERROR_H 1 @@ -47,9 +47,15 @@ extern unsigned int error_message_count; variable controls whether this mode is selected or not. */ extern int error_one_per_line; - -#if defined __extern_always_inline && defined __va_arg_pack -# include <bits/error.h> +#ifdef __LDBL_COMPAT +# include <bits/error-ldbl.h> +#else +/* Do not inline error and error_at_line when long double has the same + size of double, because that would invalidate the redirections to the + compatibility functions. */ +# if defined __extern_always_inline && defined __va_arg_pack +# include <bits/error.h> +# endif #endif __END_DECLS diff --git a/misc/fchflags.c b/misc/fchflags.c index 53ec953f54..d700c69554 100644 --- a/misc/fchflags.c +++ b/misc/fchflags.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <stddef.h> diff --git a/misc/fdatasync.c b/misc/fdatasync.c index 67a95eb818..54f61588a8 100644 --- a/misc/fdatasync.c +++ b/misc/fdatasync.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2018 Free Software Foundation, Inc. +/* Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <unistd.h> diff --git a/misc/fgetxattr.c b/misc/fgetxattr.c index 5c8e20accc..89dbc8fb60 100644 --- a/misc/fgetxattr.c +++ b/misc/fgetxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. +/* Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/xattr.h> diff --git a/misc/flistxattr.c b/misc/flistxattr.c index 46e371964c..266e2fdd2e 100644 --- a/misc/flistxattr.c +++ b/misc/flistxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. +/* Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/xattr.h> diff --git a/misc/fremovexattr.c b/misc/fremovexattr.c index b03ce2e535..5b8561a005 100644 --- a/misc/fremovexattr.c +++ b/misc/fremovexattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. +/* Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/xattr.h> diff --git a/misc/fsetxattr.c b/misc/fsetxattr.c index 635ab1cc96..5c53b3240b 100644 --- a/misc/fsetxattr.c +++ b/misc/fsetxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. +/* Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/xattr.h> diff --git a/misc/fstab.c b/misc/fstab.c index 8fbe3c7767..7a6282127b 100644 --- a/misc/fstab.c +++ b/misc/fstab.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2018 Free Software Foundation, Inc. +/* Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <fstab.h> #include <mntent.h> @@ -163,12 +163,12 @@ fstab_convert (struct fstab_state *state) f->fs_file = m->mnt_dir; f->fs_vfstype = m->mnt_type; f->fs_mntops = m->mnt_opts; - f->fs_type = (__hasmntopt (m, FSTAB_RW) ? FSTAB_RW : - __hasmntopt (m, FSTAB_RQ) ? FSTAB_RQ : - __hasmntopt (m, FSTAB_RO) ? FSTAB_RO : - __hasmntopt (m, FSTAB_SW) ? FSTAB_SW : - __hasmntopt (m, FSTAB_XX) ? FSTAB_XX : - "??"); + f->fs_type = (__hasmntopt (m, FSTAB_RW) ? FSTAB_RW + : __hasmntopt (m, FSTAB_RQ) ? FSTAB_RQ + : __hasmntopt (m, FSTAB_RO) ? FSTAB_RO + : __hasmntopt (m, FSTAB_SW) ? FSTAB_SW + : __hasmntopt (m, FSTAB_XX) ? FSTAB_XX + : "??"); f->fs_freq = m->mnt_freq; f->fs_passno = m->mnt_passno; return f; diff --git a/misc/fsync.c b/misc/fsync.c index e52be4cc6a..2f051d3e8d 100644 --- a/misc/fsync.c +++ b/misc/fsync.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/ftruncate.c b/misc/ftruncate.c index 7e30b159d5..ac20dae9e4 100644 --- a/misc/ftruncate.c +++ b/misc/ftruncate.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/types.h> diff --git a/misc/ftruncate64.c b/misc/ftruncate64.c index a90e949f93..a5f599e957 100644 --- a/misc/ftruncate64.c +++ b/misc/ftruncate64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2018 Free Software Foundation, Inc. +/* Copyright (C) 1997-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <errno.h> diff --git a/misc/futimes.c b/misc/futimes.c index 3ffa40b0b1..6b130c2d8a 100644 --- a/misc/futimes.c +++ b/misc/futimes.c @@ -1,5 +1,5 @@ /* futimes -- change access and modification times of open file. Stub version. - Copyright (C) 2002-2018 Free Software Foundation, Inc. + Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/time.h> #include <errno.h> diff --git a/misc/futimesat.c b/misc/futimesat.c index b467184b41..f7966b914b 100644 --- a/misc/futimesat.c +++ b/misc/futimesat.c @@ -1,5 +1,5 @@ /* futimesat -- Change access and modification times of file. Stub version. - Copyright (C) 2005-2018 Free Software Foundation, Inc. + Copyright (C) 2005-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <fcntl.h> diff --git a/misc/getauxval.c b/misc/getauxval.c index 0a5c1ec384..a8ccb39d9e 100644 --- a/misc/getauxval.c +++ b/misc/getauxval.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2018 Free Software Foundation, Inc. +/* Copyright (C) 2012-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/auxv.h> #include <errno.h> diff --git a/misc/getclktck.c b/misc/getclktck.c index 19a69f6806..3f49aa9676 100644 --- a/misc/getclktck.c +++ b/misc/getclktck.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2018 Free Software Foundation, Inc. +/* Copyright (C) 2000-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <time.h> diff --git a/misc/getdomain.c b/misc/getdomain.c index c25f8ae128..c9faef9dba 100644 --- a/misc/getdomain.c +++ b/misc/getdomain.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-2018 Free Software Foundation, Inc. +/* Copyright (C) 1994-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ /* Put the name of the current YP domain in no more than LEN bytes of NAME. The result is null-terminated if LEN is large enough for the full diff --git a/misc/getdtsz.c b/misc/getdtsz.c index fe5cc1e9b2..8a78ecf4ad 100644 --- a/misc/getdtsz.c +++ b/misc/getdtsz.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/gethostid.c b/misc/gethostid.c index bec2b03dc6..d041414498 100644 --- a/misc/gethostid.c +++ b/misc/gethostid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/gethostname.c b/misc/gethostname.c index a78ce235d8..dac379529c 100644 --- a/misc/gethostname.c +++ b/misc/gethostname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/getloadavg.c b/misc/getloadavg.c index bb5613de65..6ca040ea45 100644 --- a/misc/getloadavg.c +++ b/misc/getloadavg.c @@ -1,5 +1,5 @@ /* Get system load averages. Stub version. - Copyright (C) 1999-2018 Free Software Foundation, Inc. + Copyright (C) 1999-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/getpagesize.c b/misc/getpagesize.c index 5fc162773d..e6df1b8b1f 100644 --- a/misc/getpagesize.c +++ b/misc/getpagesize.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/getpass.c b/misc/getpass.c index a7023e37a8..11685d37f9 100644 --- a/misc/getpass.c +++ b/misc/getpass.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2018 Free Software Foundation, Inc. +/* Copyright (C) 1992-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <stdio.h> #include <stdio_ext.h> diff --git a/misc/getsysstats.c b/misc/getsysstats.c index 4b886f2f88..833ef80024 100644 --- a/misc/getsysstats.c +++ b/misc/getsysstats.c @@ -1,5 +1,5 @@ /* getsysstats - Determine various system internal values, stub version. - Copyright (C) 1996-2018 Free Software Foundation, Inc. + Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/sysinfo.h> diff --git a/misc/getxattr.c b/misc/getxattr.c index 003eeb82ec..c7443ac11b 100644 --- a/misc/getxattr.c +++ b/misc/getxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. +/* Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/xattr.h> diff --git a/misc/gtty.c b/misc/gtty.c index c84d07fc0b..314fa5d494 100644 --- a/misc/gtty.c +++ b/misc/gtty.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sgtty.h> diff --git a/misc/hsearch.c b/misc/hsearch.c index 1c061170b5..ec76a4c88a 100644 --- a/misc/hsearch.c +++ b/misc/hsearch.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993-2018 Free Software Foundation, Inc. +/* Copyright (C) 1993-2019 Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu> This file is part of the GNU C Library. @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <search.h> diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c index 83c6b0a512..0dc53c6fab 100644 --- a/misc/hsearch_r.c +++ b/misc/hsearch_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993-2018 Free Software Foundation, Inc. +/* Copyright (C) 1993-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1993. @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <malloc.h> diff --git a/misc/ifunc-impl-list.c b/misc/ifunc-impl-list.c index a161ece386..c3fc0463be 100644 --- a/misc/ifunc-impl-list.c +++ b/misc/ifunc-impl-list.c @@ -1,5 +1,5 @@ /* Enumerate available IFUNC implementations of a function. Stub version. - Copyright (C) 2012-2018 Free Software Foundation, Inc. + Copyright (C) 2012-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <ifunc-impl-list.h> diff --git a/misc/init-misc.c b/misc/init-misc.c index 2a1b82710e..2b9147f8c2 100644 --- a/misc/init-misc.c +++ b/misc/init-misc.c @@ -1,5 +1,5 @@ /* Define and initialize `__progname' et. al. - Copyright (C) 1994-2018 Free Software Foundation, Inc. + Copyright (C) 1994-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <string.h> #include <libc-internal.h> diff --git a/misc/insremque.c b/misc/insremque.c index d5552316f9..e67d73574c 100644 --- a/misc/insremque.c +++ b/misc/insremque.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2018 Free Software Foundation, Inc. +/* Copyright (C) 1992-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <stddef.h> #include <search.h> diff --git a/misc/ioctl.c b/misc/ioctl.c index b2b3787ff0..92b9ae9d29 100644 --- a/misc/ioctl.c +++ b/misc/ioctl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/ioctl.h> diff --git a/misc/lgetxattr.c b/misc/lgetxattr.c index 453c36221e..d60469c747 100644 --- a/misc/lgetxattr.c +++ b/misc/lgetxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. +/* Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/xattr.h> diff --git a/misc/libgen.h b/misc/libgen.h index f1d7b28e40..aad0a497b1 100644 --- a/misc/libgen.h +++ b/misc/libgen.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2018 Free Software Foundation, Inc. +/* Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _LIBGEN_H #define _LIBGEN_H 1 diff --git a/misc/listxattr.c b/misc/listxattr.c index f749b6db8b..5714e971c0 100644 --- a/misc/listxattr.c +++ b/misc/listxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. +/* Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/xattr.h> diff --git a/misc/llistxattr.c b/misc/llistxattr.c index ae76c44b93..615bab1b0f 100644 --- a/misc/llistxattr.c +++ b/misc/llistxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. +/* Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/xattr.h> diff --git a/misc/lremovexattr.c b/misc/lremovexattr.c index 9e556d9a85..d344e5bae1 100644 --- a/misc/lremovexattr.c +++ b/misc/lremovexattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. +/* Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/xattr.h> diff --git a/misc/lsearch.c b/misc/lsearch.c index 3d37c072ee..35b7624819 100644 --- a/misc/lsearch.c +++ b/misc/lsearch.c @@ -1,5 +1,5 @@ /* Linear search functions. - Copyright (C) 1996-2018 Free Software Foundation, Inc. + Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <search.h> #include <string.h> diff --git a/misc/lsetxattr.c b/misc/lsetxattr.c index 8898dd97bf..7a5aba54ce 100644 --- a/misc/lsetxattr.c +++ b/misc/lsetxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. +/* Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/xattr.h> diff --git a/misc/lutimes.c b/misc/lutimes.c index b241c14c56..aefec30a78 100644 --- a/misc/lutimes.c +++ b/misc/lutimes.c @@ -1,5 +1,5 @@ /* lutimes -- change access and modification times of a symlink. Stub version. - Copyright (C) 2002-2018 Free Software Foundation, Inc. + Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/time.h> #include <errno.h> diff --git a/misc/madvise.c b/misc/madvise.c index 988f7b09d5..c9201c3256 100644 --- a/misc/madvise.c +++ b/misc/madvise.c @@ -1,5 +1,5 @@ /* Advise system about intentions for a memory region. Stub version. - Copyright (C) 1994-2018 Free Software Foundation, Inc. + Copyright (C) 1994-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/mman.h> diff --git a/misc/makedev.c b/misc/makedev.c index bc5bfc577a..e4d295ec8a 100644 --- a/misc/makedev.c +++ b/misc/makedev.c @@ -1,5 +1,5 @@ /* Definitions of functions to access `dev_t' values. - Copyright (C) 2003-2018 Free Software Foundation, Inc. + Copyright (C) 2003-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <features.h> diff --git a/misc/mincore.c b/misc/mincore.c index 984eace7ee..35564a8b0a 100644 --- a/misc/mincore.c +++ b/misc/mincore.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2018 Free Software Foundation, Inc. +/* Copyright (C) 2000-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/mman.h> #include <errno.h> diff --git a/misc/mkdtemp.c b/misc/mkdtemp.c index 6673f36858..3e4c520423 100644 --- a/misc/mkdtemp.c +++ b/misc/mkdtemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999-2018 Free Software Foundation, Inc. +/* Copyright (C) 1999-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <stdio.h> #include <stdlib.h> diff --git a/misc/mkostemp.c b/misc/mkostemp.c index 4ef55003bf..be951344ac 100644 --- a/misc/mkostemp.c +++ b/misc/mkostemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2018 Free Software Foundation, Inc. +/* Copyright (C) 1998-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <fcntl.h> #include <stdio.h> diff --git a/misc/mkostemp64.c b/misc/mkostemp64.c index 6563112921..dc3450952a 100644 --- a/misc/mkostemp64.c +++ b/misc/mkostemp64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2018 Free Software Foundation, Inc. +/* Copyright (C) 2000-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <fcntl.h> #include <stdio.h> diff --git a/misc/mkostemps.c b/misc/mkostemps.c index 3f93670092..1f1db30e43 100644 --- a/misc/mkostemps.c +++ b/misc/mkostemps.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2018 Free Software Foundation, Inc. +/* Copyright (C) 2009-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <fcntl.h> diff --git a/misc/mkostemps64.c b/misc/mkostemps64.c index 279d5d9a93..5218b3dda8 100644 --- a/misc/mkostemps64.c +++ b/misc/mkostemps64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2018 Free Software Foundation, Inc. +/* Copyright (C) 2000-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <fcntl.h> diff --git a/misc/mkstemp.c b/misc/mkstemp.c index 373141353a..0251df16b8 100644 --- a/misc/mkstemp.c +++ b/misc/mkstemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2018 Free Software Foundation, Inc. +/* Copyright (C) 1998-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <fcntl.h> #include <stdio.h> diff --git a/misc/mkstemp64.c b/misc/mkstemp64.c index f83f207b6b..a1236bbefd 100644 --- a/misc/mkstemp64.c +++ b/misc/mkstemp64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2018 Free Software Foundation, Inc. +/* Copyright (C) 2000-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <fcntl.h> #include <stdio.h> diff --git a/misc/mkstemps.c b/misc/mkstemps.c index 8b90b095bc..fa6dd7fdce 100644 --- a/misc/mkstemps.c +++ b/misc/mkstemps.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2018 Free Software Foundation, Inc. +/* Copyright (C) 2009-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <fcntl.h> diff --git a/misc/mkstemps64.c b/misc/mkstemps64.c index 37bda50646..82afad1aa5 100644 --- a/misc/mkstemps64.c +++ b/misc/mkstemps64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2018 Free Software Foundation, Inc. +/* Copyright (C) 2000-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <fcntl.h> diff --git a/misc/mktemp.c b/misc/mktemp.c index 1417ab37f4..8c0c1bddf7 100644 --- a/misc/mktemp.c +++ b/misc/mktemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2018 Free Software Foundation, Inc. +/* Copyright (C) 1998-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <stdio.h> #include <stdlib.h> diff --git a/misc/mlock.c b/misc/mlock.c index 49827d0d6a..822b66a5d0 100644 --- a/misc/mlock.c +++ b/misc/mlock.c @@ -1,5 +1,5 @@ /* mlock -- guarantee pages are resident in memory. Stub version. - Copyright (C) 2001-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/mman.h> diff --git a/misc/mlockall.c b/misc/mlockall.c index 98dbbd3814..38929eabf1 100644 --- a/misc/mlockall.c +++ b/misc/mlockall.c @@ -1,5 +1,5 @@ /* mlockall -- lock in core all the pages in this process. Stub version. - Copyright (C) 2001-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/mman.h> diff --git a/misc/mmap.c b/misc/mmap.c index f92218ce57..3607a7fda1 100644 --- a/misc/mmap.c +++ b/misc/mmap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-2018 Free Software Foundation, Inc. +/* Copyright (C) 1994-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/mman.h> diff --git a/misc/mmap64.c b/misc/mmap64.c index e4a22742f4..1a8aa4c16a 100644 --- a/misc/mmap64.c +++ b/misc/mmap64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2018 Free Software Foundation, Inc. +/* Copyright (C) 1997-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/mman.h> diff --git a/misc/mntent.c b/misc/mntent.c index 6718b56553..326c9cd641 100644 --- a/misc/mntent.c +++ b/misc/mntent.c @@ -1,5 +1,5 @@ /* Utilities for reading/writing fstab, mtab, etc. - Copyright (C) 1995-2018 Free Software Foundation, Inc. + Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,40 +14,45 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <mntent.h> #include <stdlib.h> -#include <libc-lock.h> +#include <allocate_once.h> -/* We don't want to allocate the static buffer all the time since it - is not always used (in fact, rather infrequently). Accept the - extra cost of a `malloc'. */ -libc_freeres_ptr (static char *getmntent_buffer); +struct mntent_buffer +{ + struct mntent m; + char buffer[4096]; +}; -/* This is the size of the buffer. This is really big. */ -#define BUFFER_SIZE 4096 +/* We don't want to allocate the static buffer all the time since it + is not always used (in fact, rather infrequently). */ +libc_freeres_ptr (static void *mntent_buffer); +static void * +allocate (void *closure) +{ + return malloc (sizeof (struct mntent_buffer)); +} static void -allocate (void) +deallocate (void *closure, void *ptr) { - getmntent_buffer = (char *) malloc (BUFFER_SIZE); + free (ptr); } - struct mntent * getmntent (FILE *stream) { - static struct mntent m; - __libc_once_define (static, once); - __libc_once (once, allocate); - - if (getmntent_buffer == NULL) + struct mntent_buffer *buffer = allocate_once (&mntent_buffer, + allocate, deallocate, NULL); + if (buffer == NULL) /* If no core is available we don't have a chance to run the program successfully and so returning NULL is an acceptable result. */ return NULL; - return __getmntent_r (stream, &m, getmntent_buffer, BUFFER_SIZE); + return __getmntent_r (stream, &buffer->m, + buffer->buffer, sizeof (buffer->buffer)); } diff --git a/misc/mntent.h b/misc/mntent.h index 9af685fae0..8cc0844492 100644 --- a/misc/mntent.h +++ b/misc/mntent.h @@ -1,5 +1,5 @@ /* Utilities for reading/writing fstab, mtab, etc. - Copyright (C) 1995-2018 Free Software Foundation, Inc. + Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _MNTENT_H #define _MNTENT_H 1 diff --git a/misc/mntent_r.c b/misc/mntent_r.c index 7a82658654..cc849f8613 100644 --- a/misc/mntent_r.c +++ b/misc/mntent_r.c @@ -1,5 +1,5 @@ /* Utilities for reading/writing fstab, mtab, etc. - Copyright (C) 1995-2018 Free Software Foundation, Inc. + Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,10 +14,11 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <alloca.h> #include <mntent.h> +#include <stdbool.h> #include <stdio.h> #include <stdio_ext.h> #include <string.h> @@ -112,26 +113,18 @@ decode_name (char *buf) return buf; } - -/* Read one mount table entry from STREAM. Returns a pointer to storage - reused on the next call, or null for EOF or error (use feof/ferror to - check). */ -struct mntent * -__getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz) +static bool +get_mnt_entry (FILE *stream, struct mntent *mp, char *buffer, int bufsiz) { char *cp; char *head; - flockfile (stream); do { char *end_ptr; if (__fgets_unlocked (buffer, bufsiz, stream) == NULL) - { - funlockfile (stream); - return NULL; - } + return false; end_ptr = strchr (buffer, '\n'); if (end_ptr != NULL) /* chop newline */ @@ -174,14 +167,47 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz) { case 0: mp->mnt_freq = 0; + /* Fall through. */ case 1: mp->mnt_passno = 0; + /* Fall through. */ case 2: break; } + + return true; +} + +/* Read one mount table entry from STREAM. Returns a pointer to storage + reused on the next call, or null for EOF or error (use feof/ferror to + check). */ +struct mntent * +__getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz) +{ + struct mntent *result; + + flockfile (stream); + while (true) + if (get_mnt_entry (stream, mp, buffer, bufsiz)) + { + /* If the file system is autofs look for a mount option hint + ("ignore") to skip the entry. */ + if (strcmp (mp->mnt_type, "autofs") == 0 && __hasmntopt (mp, "ignore")) + memset (mp, 0, sizeof (*mp)); + else + { + result = mp; + break; + } + } + else + { + result = NULL; + break; + } funlockfile (stream); - return mp; + return result; } libc_hidden_def (__getmntent_r) weak_alias (__getmntent_r, getmntent_r) diff --git a/misc/mprotect.c b/misc/mprotect.c index 4a08f2f67b..bd3a6f62a7 100644 --- a/misc/mprotect.c +++ b/misc/mprotect.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-2018 Free Software Foundation, Inc. +/* Copyright (C) 1994-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/mman.h> diff --git a/misc/msync.c b/misc/msync.c index 9785068444..bc953d74fe 100644 --- a/misc/msync.c +++ b/misc/msync.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-2018 Free Software Foundation, Inc. +/* Copyright (C) 1994-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/mman.h> diff --git a/misc/munlock.c b/misc/munlock.c index 710aedf4ad..be3461f0b8 100644 --- a/misc/munlock.c +++ b/misc/munlock.c @@ -1,5 +1,5 @@ /* munlock -- undo the effects of prior mlock calls. Stub version. - Copyright (C) 2001-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/mman.h> diff --git a/misc/munlockall.c b/misc/munlockall.c index a948d07d42..131b522861 100644 --- a/misc/munlockall.c +++ b/misc/munlockall.c @@ -1,5 +1,5 @@ /* munlockall -- undo the effects of all prior mlock calls. Stub version. - Copyright (C) 2001-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/mman.h> diff --git a/misc/munmap.c b/misc/munmap.c index 5237e4ed69..2fc08f9186 100644 --- a/misc/munmap.c +++ b/misc/munmap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-2018 Free Software Foundation, Inc. +/* Copyright (C) 1994-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/mman.h> diff --git a/misc/preadv.c b/misc/preadv.c index da6a325db0..8d1ae0ff3f 100644 --- a/misc/preadv.c +++ b/misc/preadv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2018 Free Software Foundation, Inc. +/* Copyright (C) 2009-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/preadv2.c b/misc/preadv2.c index 63fd8942c1..38d4f27c10 100644 --- a/misc/preadv2.c +++ b/misc/preadv2.c @@ -1,5 +1,5 @@ /* Default implementation of preadv2. - Copyright (C) 2017-2018 Free Software Foundation, Inc. + Copyright (C) 2017-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/uio.h> diff --git a/misc/preadv64.c b/misc/preadv64.c index 810e364433..7303b97a9c 100644 --- a/misc/preadv64.c +++ b/misc/preadv64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2018 Free Software Foundation, Inc. +/* Copyright (C) 2009-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/preadv64v2.c b/misc/preadv64v2.c index 728ebc35da..3612934693 100644 --- a/misc/preadv64v2.c +++ b/misc/preadv64v2.c @@ -1,5 +1,5 @@ /* Default implementation of preadv2 (LFS version). - Copyright (C) 2017-2018 Free Software Foundation, Inc. + Copyright (C) 2017-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/uio.h> diff --git a/misc/pselect.c b/misc/pselect.c index 2c29230596..b53d9cdcc1 100644 --- a/misc/pselect.c +++ b/misc/pselect.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2018 Free Software Foundation, Inc. +/* Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -14,15 +14,10 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> -#include <signal.h> -#include <stddef.h> /* For NULL. */ -#include <sys/time.h> #include <sys/select.h> -#include <sysdep-cancel.h> - /* Check the first NFDS descriptors each in READFDS (if not NULL) for read readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS @@ -34,45 +29,8 @@ int __pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timespec *timeout, const sigset_t *sigmask) { - struct timeval tval; - int retval; - sigset_t savemask; - - /* Change nanosecond number to microseconds. This might mean losing - precision and therefore the `pselect` should be available. But - for now it is hardly found. */ - if (timeout != NULL) - { - /* Catch bugs which would be hidden by the TIMESPEC_TO_TIMEVAL - computations. The division by 1000 truncates values. */ - if (__glibc_unlikely (timeout->tv_nsec < 0)) - { - __set_errno (EINVAL); - return -1; - } - - TIMESPEC_TO_TIMEVAL (&tval, timeout); - } - - /* The setting and restoring of the signal mask and the select call - should be an atomic operation. This can't be done without kernel - help. */ - if (sigmask != NULL) - __sigprocmask (SIG_SETMASK, sigmask, &savemask); - - /* Note the pselect() is a cancellation point. But since we call - select() which itself is a cancellation point we do not have - to do anything here. */ - retval = __select (nfds, readfds, writefds, exceptfds, - timeout != NULL ? &tval : NULL); - - if (sigmask != NULL) - __sigprocmask (SIG_SETMASK, &savemask, NULL); - - return retval; + __set_errno (ENOSYS); + return -1; } -#ifndef __pselect weak_alias (__pselect, pselect) -/* __select handles cancellation. */ -LIBC_CANCEL_HANDLED (); -#endif +stub_warning (pselect) diff --git a/misc/ptrace.c b/misc/ptrace.c index 244f130610..5c06c4c024 100644 --- a/misc/ptrace.c +++ b/misc/ptrace.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/ptrace.h> diff --git a/misc/pwritev.c b/misc/pwritev.c index 7a9e7c8dbf..643f9b159f 100644 --- a/misc/pwritev.c +++ b/misc/pwritev.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2018 Free Software Foundation, Inc. +/* Copyright (C) 2009-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/pwritev2.c b/misc/pwritev2.c index 69f11d8922..3208c87db2 100644 --- a/misc/pwritev2.c +++ b/misc/pwritev2.c @@ -1,5 +1,5 @@ /* Default implementation of pwritev2. - Copyright (C) 2017-2018 Free Software Foundation, Inc. + Copyright (C) 2017-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/uio.h> diff --git a/misc/pwritev64.c b/misc/pwritev64.c index 348e10c3d0..cb01cb9d55 100644 --- a/misc/pwritev64.c +++ b/misc/pwritev64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2018 Free Software Foundation, Inc. +/* Copyright (C) 2009-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/pwritev64v2.c b/misc/pwritev64v2.c index 6230e72222..2031b8e9cc 100644 --- a/misc/pwritev64v2.c +++ b/misc/pwritev64v2.c @@ -1,5 +1,5 @@ /* Default implementation of pwritev2 (LFS version). - Copyright (C) 2017-2018 Free Software Foundation, Inc. + Copyright (C) 2017-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/uio.h> diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c index 88033a5ac7..4fcadfcdc2 100644 --- a/misc/qefgcvt.c +++ b/misc/qefgcvt.c @@ -1,5 +1,5 @@ /* Compatibility functions for floating point formatting, long double version. - Copyright (C) 1996-2018 Free Software Foundation, Inc. + Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <float.h> diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c index 341d06a58b..8f4d8b9f7a 100644 --- a/misc/qefgcvt_r.c +++ b/misc/qefgcvt_r.c @@ -1,6 +1,6 @@ /* Compatibility functions for floating point formatting, reentrant, long double versions. - Copyright (C) 1996-2018 Free Software Foundation, Inc. + Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <float.h> diff --git a/misc/readv.c b/misc/readv.c index 17d967a496..23475a29d4 100644 --- a/misc/readv.c +++ b/misc/readv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/reboot.c b/misc/reboot.c index 640c7a32f1..deb51fc65a 100644 --- a/misc/reboot.c +++ b/misc/reboot.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2018 Free Software Foundation, Inc. +/* Copyright (C) 1992-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/regexp.c b/misc/regexp.c index 0996f1d939..5c8a441b0e 100644 --- a/misc/regexp.c +++ b/misc/regexp.c @@ -1,5 +1,5 @@ /* Compatibility symbols for the obsolete <regexp.h> interface. - Copyright (C) 1996-2018 Free Software Foundation, Inc. + Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ /* regexp.h now contains only an #error directive, so it cannot be used in this file. diff --git a/misc/regexp.h b/misc/regexp.h index b15f43b909..c4249b0270 100644 --- a/misc/regexp.h +++ b/misc/regexp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2018 Free Software Foundation, Inc. +/* Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _REGEXP_H #define _REGEXP_H 1 diff --git a/misc/remap_file_pages.c b/misc/remap_file_pages.c index 36e942fd96..de7a41319f 100644 --- a/misc/remap_file_pages.c +++ b/misc/remap_file_pages.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2018 Free Software Foundation, Inc. +/* Copyright (C) 2003-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/mman.h> #include <errno.h> diff --git a/misc/removexattr.c b/misc/removexattr.c index 56d29fce9e..f3da81d742 100644 --- a/misc/removexattr.c +++ b/misc/removexattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. +/* Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/xattr.h> diff --git a/misc/revoke.c b/misc/revoke.c index 28269a05d0..9e14385b0c 100644 --- a/misc/revoke.c +++ b/misc/revoke.c @@ -1,5 +1,5 @@ /* Revoke the access of all descriptors currently open on a file. - Copyright (C) 1995-2018 Free Software Foundation, Inc. + Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <unistd.h> #include <errno.h> diff --git a/misc/sbrk.c b/misc/sbrk.c index e0747ace8d..96b48e99d3 100644 --- a/misc/sbrk.c +++ b/misc/sbrk.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <stdint.h> diff --git a/misc/search.h b/misc/search.h index 4cd1bff09f..71ad9db42d 100644 --- a/misc/search.h +++ b/misc/search.h @@ -1,5 +1,5 @@ /* Declarations for System V style searching functions. - Copyright (C) 1995-2018 Free Software Foundation, Inc. + Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SEARCH_H #define _SEARCH_H 1 @@ -150,6 +150,13 @@ typedef void (*__action_fn_t) (const void *__nodep, VISIT __value, extern void twalk (const void *__root, __action_fn_t __action); #ifdef __USE_GNU +/* Like twalk, but pass down a closure parameter instead of the + level. */ +extern void twalk_r (const void *__root, + void (*) (const void *__nodep, VISIT __value, + void *__closure), + void *__closure); + /* Callback type for function to free a tree node. If the keys are atomic data this function should do nothing. */ typedef void (*__free_fn_t) (void *__nodep); diff --git a/misc/select.c b/misc/select.c index 58c4688876..16b4a49197 100644 --- a/misc/select.c +++ b/misc/select.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/time.h> #include <sys/types.h> diff --git a/misc/setdomain.c b/misc/setdomain.c index e2990939a1..1febb5546a 100644 --- a/misc/setdomain.c +++ b/misc/setdomain.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-2018 Free Software Foundation, Inc. +/* Copyright (C) 1994-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/setegid.c b/misc/setegid.c index 5c70e4545d..ba7803350b 100644 --- a/misc/setegid.c +++ b/misc/setegid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2018 Free Software Foundation, Inc. +/* Copyright (C) 1992-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/seteuid.c b/misc/seteuid.c index 4c8bf10945..38c917a5af 100644 --- a/misc/seteuid.c +++ b/misc/seteuid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2018 Free Software Foundation, Inc. +/* Copyright (C) 1992-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/sethostid.c b/misc/sethostid.c index 5249ed123f..3dcc26cd34 100644 --- a/misc/sethostid.c +++ b/misc/sethostid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/sethostname.c b/misc/sethostname.c index 98608e519a..2d9bf0a20b 100644 --- a/misc/sethostname.c +++ b/misc/sethostname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/setregid.c b/misc/setregid.c index b4400fcfd9..4a509ef212 100644 --- a/misc/setregid.c +++ b/misc/setregid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/setreuid.c b/misc/setreuid.c index 696c54760c..60f181739c 100644 --- a/misc/setreuid.c +++ b/misc/setreuid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/setxattr.c b/misc/setxattr.c index 0877a0e299..7ea8a40fb6 100644 --- a/misc/setxattr.c +++ b/misc/setxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. +/* Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sys/xattr.h> diff --git a/misc/sgtty.h b/misc/sgtty.h index baa7005446..089efbca2f 100644 --- a/misc/sgtty.h +++ b/misc/sgtty.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SGTTY_H #define _SGTTY_H 1 diff --git a/misc/sstk.c b/misc/sstk.c index 4caa01f7c2..40b3077959 100644 --- a/misc/sstk.c +++ b/misc/sstk.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> diff --git a/misc/stty.c b/misc/stty.c index 3c7d0d042e..8e74511de2 100644 --- a/misc/stty.c +++ b/misc/stty.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <sgtty.h> diff --git a/misc/swapoff.c b/misc/swapoff.c index c0853febdc..0562eb960b 100644 --- a/misc/swapoff.c +++ b/misc/swapoff.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2018 Free Software Foundation, Inc. +/* Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/swapon.c b/misc/swapon.c index 6224fe3aa9..2fa11da1e2 100644 --- a/misc/swapon.c +++ b/misc/swapon.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/sync.c b/misc/sync.c index f8c51e780d..84794b327e 100644 --- a/misc/sync.c +++ b/misc/sync.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/syncfs.c b/misc/syncfs.c index 5195e56b4e..0d994663be 100644 --- a/misc/syncfs.c +++ b/misc/syncfs.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2011-2018 Free Software Foundation, Inc. +/* Copyright (C) 2011-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/sys/auxv.h b/misc/sys/auxv.h index 0d75a1d1cc..74c8c029a6 100644 --- a/misc/sys/auxv.h +++ b/misc/sys/auxv.h @@ -1,5 +1,5 @@ /* Access to the auxiliary vector. - Copyright (C) 2012-2018 Free Software Foundation, Inc. + Copyright (C) 2012-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SYS_AUXV_H #define _SYS_AUXV_H 1 diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index 3f6fe3cc85..467dbd9547 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2018 Free Software Foundation, Inc. +/* Copyright (C) 1992-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SYS_CDEFS_H #define _SYS_CDEFS_H 1 @@ -256,8 +256,8 @@ /* Since version 4.5, gcc also allows one to specify the message printed when a deprecated function is used. clang claims to be gcc 4.2, but may also support this feature. */ -#if __GNUC_PREREQ (4,5) || \ - __glibc_clang_has_extension (__attribute_deprecated_with_message__) +#if __GNUC_PREREQ (4,5) \ + || __glibc_clang_has_extension (__attribute_deprecated_with_message__) # define __attribute_deprecated_msg__(msg) \ __attribute__ ((__deprecated__ (msg))) #else @@ -337,7 +337,7 @@ semantics. clang++ identifies itself as gcc-4.2, but has support for GNU inlining - semantics, that can be checked fot by using the __GNUC_STDC_INLINE_ and + semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and __GNUC_GNU_INLINE__ macro definitions. */ #if (!defined __cplusplus || __GNUC_PREREQ (4,3) \ || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \ @@ -431,6 +431,16 @@ # define __attribute_nonstring__ #endif +/* Undefine (also defined in libc-symbols.h). */ +#undef __attribute_copy__ +#if __GNUC_PREREQ (9, 0) +/* Copies attributes from the declaration or type referenced by + the argument. */ +# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg))) +#else +# define __attribute_copy__(arg) +#endif + #if (!defined _Static_assert && !defined __cplusplus \ && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__)) diff --git a/misc/sys/dir.h b/misc/sys/dir.h index c4dbfcce71..f17844fbe5 100644 --- a/misc/sys/dir.h +++ b/misc/sys/dir.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SYS_DIR_H #define _SYS_DIR_H 1 diff --git a/misc/sys/file.h b/misc/sys/file.h index 86abfa18de..06184d67c2 100644 --- a/misc/sys/file.h +++ b/misc/sys/file.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SYS_FILE_H #define _SYS_FILE_H 1 diff --git a/misc/sys/ioctl.h b/misc/sys/ioctl.h index 49f7ff1294..177b692540 100644 --- a/misc/sys/ioctl.h +++ b/misc/sys/ioctl.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SYS_IOCTL_H #define _SYS_IOCTL_H 1 diff --git a/misc/sys/mman.h b/misc/sys/mman.h index 12e1b069d6..58c12de1b0 100644 --- a/misc/sys/mman.h +++ b/misc/sys/mman.h @@ -1,5 +1,5 @@ /* Definitions for BSD-style memory management. - Copyright (C) 1994-2018 Free Software Foundation, Inc. + Copyright (C) 1994-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SYS_MMAN_H #define _SYS_MMAN_H 1 diff --git a/misc/sys/param.h b/misc/sys/param.h index 359bc96056..0e1a6f7887 100644 --- a/misc/sys/param.h +++ b/misc/sys/param.h @@ -1,5 +1,5 @@ /* Compatibility header for old-style Unix parameters and limits. - Copyright (C) 1995-2018 Free Software Foundation, Inc. + Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SYS_PARAM_H #define _SYS_PARAM_H 1 diff --git a/misc/sys/select.h b/misc/sys/select.h index 6dd0c83227..4e47f3fe13 100644 --- a/misc/sys/select.h +++ b/misc/sys/select.h @@ -1,5 +1,5 @@ /* `fd_set' type and related macros, and `select'/`pselect' declarations. - Copyright (C) 1996-2018 Free Software Foundation, Inc. + Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ /* POSIX 1003.1g: 6.2 Select from File Descriptor Sets <sys/select.h> */ diff --git a/misc/sys/sysmacros.h b/misc/sys/sysmacros.h index 699e03865f..cfadaff0d9 100644 --- a/misc/sys/sysmacros.h +++ b/misc/sys/sysmacros.h @@ -1,5 +1,5 @@ /* Definitions of macros to access `dev_t' values. - Copyright (C) 1996-2018 Free Software Foundation, Inc. + Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SYS_SYSMACROS_H #define _SYS_SYSMACROS_H 1 diff --git a/misc/sys/uio.h b/misc/sys/uio.h index ff586c7b16..b496cf4554 100644 --- a/misc/sys/uio.h +++ b/misc/sys/uio.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SYS_UIO_H #define _SYS_UIO_H 1 diff --git a/misc/sys/xattr.h b/misc/sys/xattr.h index 5278cc2727..93393bbc94 100644 --- a/misc/sys/xattr.h +++ b/misc/sys/xattr.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. +/* Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _SYS_XATTR_H #define _SYS_XATTR_H 1 diff --git a/misc/syscall.c b/misc/syscall.c index f15b64c570..5100c2b5b3 100644 --- a/misc/syscall.c +++ b/misc/syscall.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993-2018 Free Software Foundation, Inc. +/* Copyright (C) 1993-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sysdep.h> #include <errno.h> diff --git a/misc/syslog.c b/misc/syslog.c index 644dbe80ec..fd6537edf6 100644 --- a/misc/syslog.c +++ b/misc/syslog.c @@ -53,7 +53,7 @@ static char sccsid[] = "@(#)syslog.c 8.4 (Berkeley) 3/18/94"; #include <stdarg.h> -#include <libio/iolibio.h> +#include <libio/libioP.h> #include <math_ldbl_opt.h> #include <kernel-features.h> @@ -114,25 +114,39 @@ __syslog(int pri, const char *fmt, ...) va_list ap; va_start(ap, fmt); - __vsyslog_chk(pri, -1, fmt, ap); + __vsyslog_internal(pri, fmt, ap, 0); va_end(ap); } ldbl_hidden_def (__syslog, syslog) ldbl_strong_alias (__syslog, syslog) void +__vsyslog(int pri, const char *fmt, va_list ap) +{ + __vsyslog_internal(pri, fmt, ap, 0); +} +ldbl_weak_alias (__vsyslog, vsyslog) + +void __syslog_chk(int pri, int flag, const char *fmt, ...) { va_list ap; va_start(ap, fmt); - __vsyslog_chk(pri, flag, fmt, ap); + __vsyslog_internal(pri, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0); va_end(ap); } void __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap) { + __vsyslog_internal(pri, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0); +} + +void +__vsyslog_internal(int pri, const char *fmt, va_list ap, + unsigned int mode_flags) +{ struct tm now_tm; time_t now; int fd; @@ -191,7 +205,7 @@ __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap) { __fsetlocking (f, FSETLOCKING_BYCALLER); fprintf (f, "<%d>", pri); - (void) time (&now); + now = time_now (); f->_IO_write_ptr += __strftime_l (f->_IO_write_ptr, f->_IO_write_end - f->_IO_write_ptr, @@ -215,11 +229,8 @@ __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap) __set_errno (saved_errno); /* We have the header. Print the user's format into the - buffer. */ - if (flag == -1) - vfprintf (f, fmt, ap); - else - __vfprintf_chk (f, flag, fmt, ap); + buffer. */ + __vfprintf_internal (f, fmt, ap, mode_flags); /* Close the memory stream; this will finalize the data into a malloc'd buffer in BUF. */ @@ -316,15 +327,6 @@ __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap) if (buf != failbuf) free (buf); } -libc_hidden_def (__vsyslog_chk) - -void -__vsyslog(int pri, const char *fmt, va_list ap) -{ - __vsyslog_chk (pri, -1, fmt, ap); -} -ldbl_hidden_def (__vsyslog, vsyslog) -ldbl_weak_alias (__vsyslog, vsyslog) static struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */ diff --git a/misc/truncate.c b/misc/truncate.c index 52a2682050..8a9e50ade5 100644 --- a/misc/truncate.c +++ b/misc/truncate.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <errno.h> diff --git a/misc/truncate64.c b/misc/truncate64.c index fd50da2531..98e903d42c 100644 --- a/misc/truncate64.c +++ b/misc/truncate64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2018 Free Software Foundation, Inc. +/* Copyright (C) 1997-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <errno.h> diff --git a/misc/tsearch.c b/misc/tsearch.c index caca1b496c..5f0dc77192 100644 --- a/misc/tsearch.c +++ b/misc/tsearch.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2018 Free Software Foundation, Inc. +/* Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Bernd Schmidt <crux@Pool.Informatik.RWTH-Aachen.DE>, 1997. @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ /* Tree search for red/black trees. The algorithm for adding nodes is taken from one of the many "Algorithms" @@ -719,7 +719,41 @@ __twalk (const void *vroot, __action_fn_t action) libc_hidden_def (__twalk) weak_alias (__twalk, twalk) +/* twalk_r is the same as twalk, but with a closure parameter instead + of the level. */ +static void +trecurse_r (const void *vroot, void (*action) (const void *, VISIT, void *), + void *closure) +{ + const_node root = (const_node) vroot; + if (LEFT(root) == NULL && RIGHT(root) == NULL) + (*action) (root, leaf, closure); + else + { + (*action) (root, preorder, closure); + if (LEFT(root) != NULL) + trecurse_r (LEFT(root), action, closure); + (*action) (root, postorder, closure); + if (RIGHT(root) != NULL) + trecurse_r (RIGHT(root), action, closure); + (*action) (root, endorder, closure); + } +} + +void +__twalk_r (const void *vroot, void (*action) (const void *, VISIT, void *), + void *closure) +{ + const_node root = (const_node) vroot; + + CHECK_TREE ((node) root); + + if (root != NULL && action != NULL) + trecurse_r (root, action, closure); +} +libc_hidden_def (__twalk_r) +weak_alias (__twalk_r, twalk_r) /* The standardized functions miss an important functionality: the tree cannot be removed easily. We provide a function to do this. */ diff --git a/misc/tst-allocate_once.c b/misc/tst-allocate_once.c index 89277b33b7..3df70ae3b4 100644 --- a/misc/tst-allocate_once.c +++ b/misc/tst-allocate_once.c @@ -1,5 +1,5 @@ /* Test the allocate_once function. - Copyright (C) 2018 Free Software Foundation, Inc. + Copyright (C) 2018-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <allocate_once.h> #include <mcheck.h> diff --git a/misc/tst-atomic-long.c b/misc/tst-atomic-long.c index e5caa10760..0afbe87ad7 100644 --- a/misc/tst-atomic-long.c +++ b/misc/tst-atomic-long.c @@ -1,5 +1,5 @@ /* Tests for atomic.h macros. - Copyright (C) 2003-2018 Free Software Foundation, Inc. + Copyright (C) 2003-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <bits/wordsize.h> diff --git a/misc/tst-atomic.c b/misc/tst-atomic.c index 90a309bcd3..03d0dadbf3 100644 --- a/misc/tst-atomic.c +++ b/misc/tst-atomic.c @@ -1,5 +1,5 @@ /* Tests for atomic.h macros. - Copyright (C) 2003-2018 Free Software Foundation, Inc. + Copyright (C) 2003-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <stdio.h> #include <atomic.h> diff --git a/misc/tst-dbl-efgcvt.c b/misc/tst-dbl-efgcvt.c new file mode 100644 index 0000000000..a6cf28f929 --- /dev/null +++ b/misc/tst-dbl-efgcvt.c @@ -0,0 +1,36 @@ +/* Tests for *cvt function, double version. + Copyright (C) 1998-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <float.h> + +#define ECVT ecvt +#define FCVT fcvt +#define ECVT_R ecvt_r +#define FCVT_R fcvt_r +#define FLOAT double +#define PRINTF_CONVERSION "%f" + +#if DBL_MANT_DIG == 53 +# define EXTRA_ECVT_TESTS \ + { 0x1p-1074, 3, -323, "494" }, \ + { -0x1p-1074, 3, -323, "494" }, +#else +# define EXTRA_ECVT_TESTS +#endif + +#include <tst-efgcvt-template.c> diff --git a/misc/tst-dirname.c b/misc/tst-dirname.c index 714b67aa53..4f16bf2609 100644 --- a/misc/tst-dirname.c +++ b/misc/tst-dirname.c @@ -1,5 +1,5 @@ /* Test program for dirname function a la XPG. - Copyright (C) 1996-2018 Free Software Foundation, Inc. + Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #define _GNU_SOURCE 1 #include <libgen.h> diff --git a/misc/tst-efgcvt.c b/misc/tst-efgcvt-template.c index bb716d5198..9b7ad0e1a1 100644 --- a/misc/tst-efgcvt.c +++ b/misc/tst-efgcvt-template.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2018 Free Software Foundation, Inc. +/* Copyright (C) 1998-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,31 +13,52 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ + +/* This template provides testing for the *cvt family of functions, + which deal with double or long double types. In order to use the + template, the following macros must be defined before inclusion of + this template: + + FLOAT: The floating-point type, i.e. double or long double. + + ECVT: Appropriate *ecvt function for FLOAT, i.e. ecvt or qecvt. + FCVT: Likewise for *fcvt, i.e. fcvt or qfcvt. + ECVT_R: Likewise for *ecvt_r, i.e. ecvt_r or qecvt_r. + FCVT_R: Likewise for *fcvt_r, i.e. fcvt_r or qfcvt_r. + + PRINTF_CONVERSION: The appropriate printf conversion specifier with + length modifier for FLOAT, i.e. "%f" or "%Lf". + + EXTRA_ECVT_TESTS: Additional tests for the ecvt or qecvt function + that are only relevant to a particular floating-point type and + cannot be represented generically. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 #endif -#include <float.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -int error_count; +#include <support/check.h> + +#define NAME(x) NAMEX(x) +#define NAMEX(x) #x typedef struct { - double value; + FLOAT value; int ndigit; int decpt; char result[30]; } testcase; -typedef char * ((*efcvt_func) (double, int, int *, int *)); +typedef char * ((*efcvt_func) (FLOAT, int, int *, int *)); -typedef int ((*efcvt_r_func) (double, int, int *, int *, char *, size_t)); +typedef int ((*efcvt_r_func) (FLOAT, int, int *, int *, char *, size_t)); static testcase ecvt_tests[] = @@ -59,10 +80,7 @@ static testcase ecvt_tests[] = { 123.01, -4, 3, "" }, { 126.71, -4, 3, "" }, { 0.0, 4, 1, "0000" }, -#if DBL_MANT_DIG == 53 - { 0x1p-1074, 3, -323, "494" }, - { -0x1p-1074, 3, -323, "494" }, -#endif + EXTRA_ECVT_TESTS /* -1.0 is end marker. */ { -1.0, 0, 0, "" } }; @@ -91,32 +109,34 @@ static testcase fcvt_tests[] = }; static void -output_error (const char *name, double value, int ndigit, +output_error (const char *name, FLOAT value, int ndigit, const char *exp_p, int exp_decpt, int exp_sign, char *res_p, int res_decpt, int res_sign) { - printf ("%s returned wrong result for value: %f, ndigits: %d\n", + printf ("%s returned wrong result for value: " PRINTF_CONVERSION + ", ndigits: %d\n", name, value, ndigit); printf ("Result was p: \"%s\", decpt: %d, sign: %d\n", res_p, res_decpt, res_sign); printf ("Should be p: \"%s\", decpt: %d, sign: %d\n", exp_p, exp_decpt, exp_sign); - ++error_count; + support_record_failure (); } static void -output_r_error (const char *name, double value, int ndigit, +output_r_error (const char *name, FLOAT value, int ndigit, const char *exp_p, int exp_decpt, int exp_sign, int exp_return, char *res_p, int res_decpt, int res_sign, int res_return) { - printf ("%s returned wrong result for value: %f, ndigits: %d\n", + printf ("%s returned wrong result for value: " PRINTF_CONVERSION + ", ndigits: %d\n", name, value, ndigit); printf ("Result was buf: \"%s\", decpt: %d, sign: %d return value: %d\n", res_p, res_decpt, res_sign, res_return); printf ("Should be buf: \"%s\", decpt: %d, sign: %d\n", exp_p, exp_decpt, exp_sign); - ++error_count; + support_record_failure (); } static void @@ -171,31 +191,31 @@ special (void) char *p; char buf [1024]; - p = ecvt (NAN, 10, &decpt, &sign); + p = ECVT (NAN, 10, &decpt, &sign); if (sign != 0 || strcmp (p, "nan") != 0) - output_error ("ecvt", NAN, 10, "nan", 0, 0, p, decpt, sign); + output_error (NAME (ECVT), NAN, 10, "nan", 0, 0, p, decpt, sign); - p = ecvt (INFINITY, 10, &decpt, &sign); + p = ECVT (INFINITY, 10, &decpt, &sign); if (sign != 0 || strcmp (p, "inf") != 0) - output_error ("ecvt", INFINITY, 10, "inf", 0, 0, p, decpt, sign); + output_error (NAME (ECVT), INFINITY, 10, "inf", 0, 0, p, decpt, sign); /* Simply make sure these calls with large NDIGITs don't crash. */ - (void) ecvt (123.456, 10000, &decpt, &sign); - (void) fcvt (123.456, 10000, &decpt, &sign); + (void) ECVT (123.456, 10000, &decpt, &sign); + (void) FCVT (123.456, 10000, &decpt, &sign); /* Some tests for the reentrant functions. */ /* Use a too small buffer. */ - res = ecvt_r (123.456, 10, &decpt, &sign, buf, 1); + res = ECVT_R (123.456, 10, &decpt, &sign, buf, 1); if (res == 0) { - printf ("ecvt_r with a too small buffer was succesful.\n"); - ++error_count; + printf (NAME (ECVT_R) " with a too small buffer was succesful.\n"); + support_record_failure (); } - res = fcvt_r (123.456, 10, &decpt, &sign, buf, 1); + res = FCVT_R (123.456, 10, &decpt, &sign, buf, 1); if (res == 0) { - printf ("fcvt_r with a too small buffer was succesful.\n"); - ++error_count; + printf (NAME (FCVT_R) " with a too small buffer was succesful.\n"); + support_record_failure (); } } @@ -203,14 +223,13 @@ special (void) static int do_test (void) { - test (ecvt_tests, ecvt, "ecvt"); - test (fcvt_tests, fcvt, "fcvt"); - test_r (ecvt_tests, ecvt_r, "ecvt_r"); - test_r (fcvt_tests, fcvt_r, "fcvt_r"); + test (ecvt_tests, ECVT, NAME (ECVT)); + test (fcvt_tests, FCVT, NAME (FCVT)); + test_r (ecvt_tests, ECVT_R, NAME (ECVT_R)); + test_r (fcvt_tests, FCVT_R, NAME (FCVT_R)); special (); - return error_count; + return 0; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/misc/tst-fdset.c b/misc/tst-fdset.c index 5452485a31..ad2a2ae528 100644 --- a/misc/tst-fdset.c +++ b/misc/tst-fdset.c @@ -1,5 +1,5 @@ /* Test FD* macros. - Copyright (C) 1997-2018 Free Software Foundation, Inc. + Copyright (C) 1997-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Robert Bihlmeyer <robbe@orcus.priv.at>. @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <stdio.h> #include <sys/types.h> diff --git a/misc/tst-gethostid.c b/misc/tst-gethostid.c new file mode 100644 index 0000000000..9961568492 --- /dev/null +++ b/misc/tst-gethostid.c @@ -0,0 +1,108 @@ +/* Basic test for gethostid. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <gnu/lib-names.h> +#include <nss.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <support/namespace.h> +#include <support/support.h> +#include <support/temp_file.h> +#include <support/xdlfcn.h> +#include <support/xstdio.h> +#include <support/xunistd.h> +#include <unistd.h> + +/* Initial test is run outside a chroot, to increase the likelihood of + success. */ +static void +outside_chroot (void *closure) +{ + long id = gethostid (); + printf ("info: host ID outside chroot: 0x%lx\n", id); +} + +/* The same, but this time perform a chroot operation. */ +static void +in_chroot (void *closure) +{ + const char *chroot_path = closure; + xchroot (chroot_path); + long id = gethostid (); + printf ("info: host ID in chroot: 0x%lx\n", id); +} + +static int +do_test (void) +{ + support_isolate_in_subprocess (outside_chroot, NULL); + + /* Now run the test inside a chroot. */ + support_become_root (); + if (!support_can_chroot ()) + /* Cannot perform further tests. */ + return 0; + + /* Only use nss_files. */ + __nss_configure_lookup ("hosts", "files"); + + /* Load the DSO outside of the chroot. */ + xdlopen (LIBNSS_FILES_SO, RTLD_LAZY); + + char *chroot_dir = support_create_temp_directory ("tst-gethostid-"); + support_isolate_in_subprocess (in_chroot, chroot_dir); + + /* Tests with /etc/hosts in the chroot. */ + { + char *path = xasprintf ("%s/etc", chroot_dir); + add_temp_file (path); + xmkdir (path, 0777); + free (path); + path = xasprintf ("%s/etc/hosts", chroot_dir); + add_temp_file (path); + + FILE *fp = xfopen (path, "w"); + xfclose (fp); + printf ("info: chroot test with an empty /etc/hosts file\n"); + support_isolate_in_subprocess (in_chroot, chroot_dir); + + char hostname[1024]; + int ret = gethostname (hostname, sizeof (hostname)); + if (ret < 0) + printf ("warning: invalid result from gethostname: %d\n", ret); + else if (strlen (hostname) == 0) + puts ("warning: gethostname returned empty string"); + else + { + printf ("info: chroot test with IPv6 address in /etc/hosts for: %s\n", + hostname); + fp = xfopen (path, "w"); + /* Use an IPv6 address to induce another lookup failure. */ + fprintf (fp, "2001:db8::1 %s\n", hostname); + xfclose (fp); + support_isolate_in_subprocess (in_chroot, chroot_dir); + } + free (path); + } + free (chroot_dir); + + return 0; +} + +#include <support/test-driver.c> diff --git a/misc/tst-ldbl-efgcvt.c b/misc/tst-ldbl-efgcvt.c new file mode 100644 index 0000000000..da1703f9ef --- /dev/null +++ b/misc/tst-ldbl-efgcvt.c @@ -0,0 +1,28 @@ +/* Tests for *cvt function, long double version. + Copyright (C) 1998-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#define ECVT qecvt +#define FCVT qfcvt +#define ECVT_R qecvt_r +#define FCVT_R qfcvt_r +#define FLOAT long double +#define PRINTF_CONVERSION "%Lf" + +#define EXTRA_ECVT_TESTS + +#include <tst-efgcvt-template.c> diff --git a/misc/tst-ldbl-error.c b/misc/tst-ldbl-error.c new file mode 100644 index 0000000000..f1a8e09331 --- /dev/null +++ b/misc/tst-ldbl-error.c @@ -0,0 +1,124 @@ +/* Test for the long double conversions in *err* functions. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <err.h> +#include <errno.h> +#include <error.h> +#include <stdarg.h> +#include <string.h> + +#include <support/capture_subprocess.h> +#include <support/check.h> + +struct tests +{ + void *callback; + const char *expected; +}; + +va_list args; + +static void +callback_err (void *closure) +{ + errno = 0; + err (0, "%Lf", (long double) -1); +} + +static void +callback_errx (void *closure) +{ + errno = 0; + errx (0, "%Lf", (long double) -1); +} + +static void +callback_verr (void *closure) +{ + errno = 0; + verr (0, "%Lf", args); +} + +static void +callback_verrx (void *closure) +{ + errno = 0; + verrx (0, "%Lf", args); +} + +static void +callback_error (void *closure) +{ + errno = 0; + error (0, 0, "%Lf", (long double) -1); +} + +static void +callback_error_at_line (void *closure) +{ + errno = 0; + error_at_line (0, 0, "", 0, "%Lf", (long double) -1); +} + +static void +do_one_test (void *callback, const char *expected, ...) +{ + struct support_capture_subprocess result; + + va_start (args, expected); + + /* Call 'callback', which fills in the output and error buffers. */ + result = support_capture_subprocess (callback, NULL); + + /* Filter out the name of the program (which should always end with + -error), so that the test case can be reused by ldbl-opt and + ldbl-128ibm-compat. */ + const char *needle = "-error:"; + char *message; + message = strstr (result.err.buffer, needle); + if (message == NULL) + FAIL_EXIT1 ("test case error"); + message += strlen (needle); + + /* Verify that the output message is as expected. */ + TEST_COMPARE_STRING (message, expected); + + va_end (args); +} + +static int +do_test (void) +{ + struct tests tests[] = { + { &callback_err, " -1.000000: Success\n" }, + { &callback_errx, " -1.000000\n" }, + { &callback_verr, " -1.000000: Success\n" }, + { &callback_verrx, " -1.000000\n" }, + { &callback_error, " -1.000000\n" }, + { &callback_error_at_line, ":0: -1.000000\n" } + }; + + for (int i = 0; i < sizeof (tests) / sizeof (tests[0]); i++) + { + do_one_test (tests[i].callback, tests[i].expected, (long double) -1); + } + + return 0; +} + +#include <support/test-driver.c> diff --git a/misc/tst-ldbl-warn.c b/misc/tst-ldbl-warn.c new file mode 100644 index 0000000000..2f41e9a75f --- /dev/null +++ b/misc/tst-ldbl-warn.c @@ -0,0 +1,124 @@ +/* Test for the long double conversions in *warn* functions. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <err.h> +#include <errno.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <support/check.h> +#include <support/xmemstream.h> + +enum {WARN, WARNX, VWARN, VWARNX}; + +static void +do_one_test (int select, const char *format, va_list args, + long double arg1, double arg2, long double arg3, + double arg4, const char *expected) +{ + /* Prepare in-memory buffer to hold the output. */ + struct xmemstream stream; + xopen_memstream (&stream); + FILE *old_stderr = stderr; + stderr = stream.out; + + /* Write to the buffer using one of the *warn* functions. */ + errno = 0; + switch (select) + { + case WARN: + warn (format, arg1, arg2, arg3, arg4); + break; + case WARNX: + warnx (format, arg1, arg2, arg3, arg4); + break; + case VWARN: + vwarn (format, args); + break; + case VWARNX: + vwarnx (format, args); + break; + } + + stderr = old_stderr; + + /* Close the in-memory stream. */ + xfclose_memstream (&stream); + + /* Filter out the name of the program (which should always end with + warn), so that the test case can be reused by ldbl-opt and + ldbl-128ibm-compat. */ + const char *needle = "warn: "; + char *message; + message = strstr (stream.buffer, needle); + if (message == NULL) + FAIL_EXIT1 ("test case error"); + message += strlen (needle); + + /* Check that the rest of the output is as expected. */ + TEST_COMPARE_STRING (message, expected); + + if (stream.buffer != NULL) + free (stream.buffer); +} + +static void +do_test_call_varg (const char *format, ...) +{ + va_list args; + + va_start (args, format); + do_one_test (VWARN, format, args, 0, 0, 0, 0, + "-1.000000 - -2.000000 - -3.000000 - -4.000000: Success\n"); + va_end (args); + + va_start (args, format); + do_one_test (VWARNX, format, args, 0, 0, 0, 0, + "-1.000000 - -2.000000 - -3.000000 - -4.000000\n"); + va_end (args); +} + +static void +do_test_call_rarg (const char *format, long double arg1, double arg2, + long double arg3, double arg4) +{ + va_list args; + memset (&args, 0, sizeof (args)); + do_one_test (WARN, format, args, arg1, arg2, arg3, arg4, + "-1.000000 - -2.000000 - -3.000000 - -4.000000: Success\n"); + do_one_test (WARNX, format, args, arg1, arg2, arg3, arg4, + "-1.000000 - -2.000000 - -3.000000 - -4.000000\n"); +} + +static int +do_test (void) +{ + long double arg1 = -1; + long double arg3 = -3; + double arg2 = -2; + double arg4 = -4; + + do_test_call_rarg ("%Lf - %f - %Lf - %f", arg1, arg2, arg3, arg4); + do_test_call_varg ("%Lf - %f - %Lf - %f", arg1, arg2, arg3, arg4); + + return 0; +} + +#include <support/test-driver.c> diff --git a/misc/tst-makedev.c b/misc/tst-makedev.c index 0a38060cd1..b6b813cc2c 100644 --- a/misc/tst-makedev.c +++ b/misc/tst-makedev.c @@ -1,5 +1,5 @@ /* Tests of functions to access `dev_t' values. - Copyright (C) 2016-2018 Free Software Foundation, Inc. + Copyright (C) 2016-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/sysmacros.h> diff --git a/misc/tst-mntent-autofs.c b/misc/tst-mntent-autofs.c new file mode 100644 index 0000000000..d14673daa6 --- /dev/null +++ b/misc/tst-mntent-autofs.c @@ -0,0 +1,141 @@ +/* Test autofs "ignore" filtering for getment_r. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <array_length.h> +#include <errno.h> +#include <mntent.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <support/check.h> +#include <support/temp_file.h> +#include <support/xstdio.h> +#include <support/xunistd.h> + +struct test_case +{ + const char *line; + struct + { + /* Like struct mntent, but with const pointers. */ + const char *mnt_fsname; + const char *mnt_dir; + const char *mnt_type; + const char *mnt_opts; + int mnt_freq; + int mnt_passno; + } expected; +}; + +static struct test_case test_cases[] = + { + { "/etc/auto.direct /mnt/auto/1 autofs defaults 0 0", + { "/etc/auto.direct", "/mnt/auto/1", "autofs", "defaults", 0, 0 } }, + + /* These entries are filtered out. */ + { "/etc/auto.2 /mnt/auto/2 autofs ignore 0 0", { NULL, } }, + { "/etc/auto.3 /mnt/auto/3 autofs ignore,other 1 2", { NULL, } }, + { "/etc/auto.4 /mnt/auto/4 autofs other,ignore 3 4", { NULL, } }, + { "/etc/auto.5 /mnt/auto/5 autofs opt1,ignore,opt2 5 6", { NULL, } }, + + /* Dummy entry to make the desynchronization more obvious. */ + { "/dev/sda1 / xfs defaults 0 0", + { "/dev/sda1", "/", "xfs", "defaults", 0, 0 } }, + + /* These are not filtered because the file system is not autofs. */ + { "/etc/auto.direct /mnt/auto/6 autofs1 ignore 0 0", + { "/etc/auto.direct", "/mnt/auto/6", "autofs1", "ignore", 0, 0 } }, + { "/etc/auto.direct /mnt/auto/7 autofs1 ignore,other 0 0", + { "/etc/auto.direct", "/mnt/auto/7", "autofs1", "ignore,other", 0, 0 } }, + { "/etc/auto.direct /mnt/auto/8 autofs1 other,ignore 0 0", + { "/etc/auto.direct", "/mnt/auto/8", "autofs1", "other,ignore", 0, 0 } }, + { "/etc/auto.direct /mnt/auto/9 autofs1 opt1,ignore,opt2 0 0", + { "/etc/auto.direct", "/mnt/auto/9", "autofs1", "opt1,ignore,opt2", } }, + + /* These are not filtered because the string "ignore" is not an + option name. */ + { "/etc/auto.direct /mnt/auto/10 autofs noignore 1 2", + { "/etc/auto.direct", "/mnt/auto/10", "autofs", "noignore", 1, 2 } }, + { "/etc/auto.direct /mnt/auto/11 autofs noignore,other 0 0", + { "/etc/auto.direct", "/mnt/auto/11", "autofs", "noignore,other", } }, + { "/etc/auto.direct /mnt/auto/12 autofs other,noignore 0 0", + { "/etc/auto.direct", "/mnt/auto/12", "autofs", "other,noignore", } }, + { "/etc/auto.direct /mnt/auto/13 autofs errors=ignore 0 0", + { "/etc/auto.direct", "/mnt/auto/13", "autofs", "errors=ignore", } }, + { "/etc/auto.direct /mnt/auto/14 autofs errors=ignore,other 0 0", + { "/etc/auto.direct", "/mnt/auto/14", "autofs", + "errors=ignore,other", } }, + { "/etc/auto.direct /mnt/auto/15 autofs other,errors=ignore 0 0", + { "/etc/auto.direct", "/mnt/auto/15", "autofs", + "other,errors=ignore", } }, + + /* These are not filtered because the string is escaped. '\151' + is 'i', but it is not actually decoded by the parser. */ + { "/etc/auto.\\151gnore /mnt/auto/16 autofs \\151gnore 0 0", + { "/etc/auto.\\151gnore", "/mnt/auto/16", "autofs", + "\\151gnore", } }, + }; + +static int +do_test (void) +{ + char *path; + xclose (create_temp_file ("tst-mntent-autofs-", &path)); + + /* Write the test file. */ + FILE *fp = xfopen (path, "w"); + for (size_t i = 0; i < array_length (test_cases); ++i) + fprintf (fp, "%s\n", test_cases[i].line); + xfclose (fp); + + /* Open the test file again, this time for parsing. */ + fp = setmntent (path, "r"); + TEST_VERIFY_EXIT (fp != NULL); + char buffer[512]; + struct mntent me; + + for (size_t i = 0; i < array_length (test_cases); ++i) + { + if (test_cases[i].expected.mnt_type == NULL) + continue; + + memset (buffer, 0xcc, sizeof (buffer)); + memset (&me, 0xcc, sizeof (me)); + struct mntent *pme = getmntent_r (fp, &me, buffer, sizeof (buffer)); + TEST_VERIFY_EXIT (pme != NULL); + TEST_VERIFY (pme == &me); + TEST_COMPARE_STRING (test_cases[i].expected.mnt_fsname, me.mnt_fsname); + TEST_COMPARE_STRING (test_cases[i].expected.mnt_dir, me.mnt_dir); + TEST_COMPARE_STRING (test_cases[i].expected.mnt_type, me.mnt_type); + TEST_COMPARE_STRING (test_cases[i].expected.mnt_opts, me.mnt_opts); + TEST_COMPARE (test_cases[i].expected.mnt_freq, me.mnt_freq); + TEST_COMPARE (test_cases[i].expected.mnt_passno, me.mnt_passno); + } + + TEST_VERIFY (getmntent_r (fp, &me, buffer, sizeof (buffer)) == NULL); + + TEST_COMPARE (feof (fp), 1); + TEST_COMPARE (ferror (fp), 0); + errno = 0; + TEST_COMPARE (endmntent (fp), 1); + TEST_COMPARE (errno, 0); + free (path); + return 0; +} + +#include <support/test-driver.c> diff --git a/misc/tst-mntent-blank-corrupt.c b/misc/tst-mntent-blank-corrupt.c index bb9939779c..5f257df0d4 100644 --- a/misc/tst-mntent-blank-corrupt.c +++ b/misc/tst-mntent-blank-corrupt.c @@ -1,6 +1,6 @@ /* Make sure blank lines does not cause memory corruption BZ #18887. - Copyright (C) 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2009-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <mntent.h> #include <stdio.h> diff --git a/misc/tst-mntent-blank-passno.c b/misc/tst-mntent-blank-passno.c index 17b0536a77..b3a2fe1fd8 100644 --- a/misc/tst-mntent-blank-passno.c +++ b/misc/tst-mntent-blank-passno.c @@ -1,6 +1,6 @@ /* Make sure trailing whitespace is handled properly BZ #17273. - Copyright (C) 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2009-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <mntent.h> #include <stdio.h> diff --git a/misc/tst-preadvwritev-common.c b/misc/tst-preadvwritev-common.c index b59a3de465..3233a4d9e3 100644 --- a/misc/tst-preadvwritev-common.c +++ b/misc/tst-preadvwritev-common.c @@ -1,5 +1,5 @@ /* Common definitions for preadv and pwritev. - Copyright (C) 2016-2018 Free Software Foundation, Inc. + Copyright (C) 2016-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,9 +14,10 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <array_length.h> +#include <stdbool.h> #include <stdio.h> #include <stdint.h> #include <errno.h> @@ -26,10 +27,12 @@ #include <support/check.h> #include <support/temp_file.h> +#include <support/support.h> #include <support/xunistd.h> static char *temp_filename; static int temp_fd; +static bool temp_fd_supports_holes; static int do_test (void); @@ -39,6 +42,7 @@ do_prepare (int argc, char **argv) temp_fd = create_temp_file ("tst-preadvwritev.", &temp_filename); if (temp_fd == -1) FAIL_EXIT1 ("cannot create temporary file"); + temp_fd_supports_holes = support_descriptor_supports_holes (temp_fd); } #define PREPARE do_prepare diff --git a/misc/tst-preadvwritev.c b/misc/tst-preadvwritev.c index 1b0c9af435..d6b9d37c41 100644 --- a/misc/tst-preadvwritev.c +++ b/misc/tst-preadvwritev.c @@ -1,5 +1,5 @@ /* Tests for preadv and pwritev. - Copyright (C) 2016-2018 Free Software Foundation, Inc. + Copyright (C) 2016-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include "tst-preadvwritev-common.c" diff --git a/misc/tst-preadvwritev2-common.c b/misc/tst-preadvwritev2-common.c index f889a21544..ff728ee6c1 100644 --- a/misc/tst-preadvwritev2-common.c +++ b/misc/tst-preadvwritev2-common.c @@ -1,5 +1,5 @@ /* Common function for preadv2 and pwritev2 tests. - Copyright (C) 2017-2018 Free Software Foundation, Inc. + Copyright (C) 2017-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,14 +14,11 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <limits.h> #include <support/check.h> -static void -do_test_with_invalid_flags (void) -{ #ifndef RWF_HIPRI # define RWF_HIPRI 0 #endif @@ -39,6 +36,73 @@ do_test_with_invalid_flags (void) #endif #define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT \ | RWF_APPEND) + +/* Generic uio_lim.h does not define IOV_MAX. */ +#ifndef IOV_MAX +# define IOV_MAX 1024 +#endif + +static void +do_test_with_invalid_fd (void) +{ + char buf[256]; + struct iovec iov = { buf, sizeof buf }; + + /* Check with flag being 0 to use the fallback code which calls pwritev + or writev. */ + TEST_VERIFY (preadv2 (-1, &iov, 1, -1, 0) == -1); + TEST_COMPARE (errno, EBADF); + TEST_VERIFY (pwritev2 (-1, &iov, 1, -1, 0) == -1); + TEST_COMPARE (errno, EBADF); + + /* Same tests as before but with flags being different than 0. Since + there is no emulation for any flag value, fallback code returns + ENOTSUP. This is different running on a kernel with preadv2/pwritev2 + support, where EBADF is returned). */ + TEST_VERIFY (preadv2 (-1, &iov, 1, 0, RWF_HIPRI) == -1); + TEST_VERIFY (errno == EBADF || errno == ENOTSUP); + TEST_VERIFY (pwritev2 (-1, &iov, 1, 0, RWF_HIPRI) == -1); + TEST_VERIFY (errno == EBADF || errno == ENOTSUP); +} + +static void +do_test_with_invalid_iov (void) +{ + { + char buf[256]; + struct iovec iov; + + iov.iov_base = buf; + iov.iov_len = (size_t)SSIZE_MAX + 1; + + TEST_VERIFY (preadv2 (temp_fd, &iov, 1, 0, 0) == -1); + TEST_COMPARE (errno, EINVAL); + TEST_VERIFY (pwritev2 (temp_fd, &iov, 1, 0, 0) == -1); + TEST_COMPARE (errno, EINVAL); + + /* Same as for invalid file descriptor tests, emulation fallback + first checks for flag value and return ENOTSUP. */ + TEST_VERIFY (preadv2 (temp_fd, &iov, 1, 0, RWF_HIPRI) == -1); + TEST_VERIFY (errno == EINVAL || errno == ENOTSUP); + TEST_VERIFY (pwritev2 (temp_fd, &iov, 1, 0, RWF_HIPRI) == -1); + TEST_VERIFY (errno == EINVAL || errno == ENOTSUP); + } + + { + /* An invalid iovec buffer should trigger an invalid memory access + or an error (Linux for instance returns EFAULT). */ + struct iovec iov[IOV_MAX+1] = { 0 }; + + TEST_VERIFY (preadv2 (temp_fd, iov, IOV_MAX + 1, 0, RWF_HIPRI) == -1); + TEST_VERIFY (errno == EINVAL || errno == ENOTSUP); + TEST_VERIFY (pwritev2 (temp_fd, iov, IOV_MAX + 1, 0, RWF_HIPRI) == -1); + TEST_VERIFY (errno == EINVAL || errno == ENOTSUP); + } +} + +static void +do_test_with_invalid_flags (void) +{ /* Set the next bit from the mask of all supported flags. */ int invalid_flag = RWF_SUPPORTED != 0 ? __builtin_clz (RWF_SUPPORTED) : 2; invalid_flag = 0x1 << ((sizeof (int) * CHAR_BIT) - invalid_flag); diff --git a/misc/tst-preadvwritev2.c b/misc/tst-preadvwritev2.c index be22802dbe..bbd5fc84d4 100644 --- a/misc/tst-preadvwritev2.c +++ b/misc/tst-preadvwritev2.c @@ -1,5 +1,5 @@ /* Tests for preadv2 and pwritev2. - Copyright (C) 2016-2018 Free Software Foundation, Inc. + Copyright (C) 2016-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #define PREADV(__fd, __iov, __iovcnt, __offset) \ preadv2 (__fd, __iov, __iovcnt, __offset, 0) @@ -30,6 +30,8 @@ do_test (void) { do_test_with_invalid_flags (); do_test_without_offset (); + do_test_with_invalid_fd (); + do_test_with_invalid_iov (); return do_test_with_offset (0); } diff --git a/misc/tst-preadvwritev64.c b/misc/tst-preadvwritev64.c index b718da6be5..6598eee134 100644 --- a/misc/tst-preadvwritev64.c +++ b/misc/tst-preadvwritev64.c @@ -1,5 +1,5 @@ /* Tests for pread64 and pwrite64. - Copyright (C) 2016-2018 Free Software Foundation, Inc. + Copyright (C) 2016-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #define _FILE_OFFSET_BITS 64 #include "tst-preadvwritev-common.c" @@ -26,6 +26,12 @@ do_test (void) ret = do_test_with_offset (0); + if (!temp_fd_supports_holes) + { + puts ("warning: partial test due to lack of support for holes"); + return ret; + } + /* Create a sparse file larger than 4GB to check if offset is handled correctly in p{write,read}v64. */ off_t base_offset = UINT32_MAX + 2048LL; diff --git a/misc/tst-preadvwritev64v2.c b/misc/tst-preadvwritev64v2.c index 8d3cc32b28..2e3f4ddcfa 100644 --- a/misc/tst-preadvwritev64v2.c +++ b/misc/tst-preadvwritev64v2.c @@ -1,5 +1,5 @@ /* Tests for preadv2 and pwritev2 (LFS version). - Copyright (C) 2017-2018 Free Software Foundation, Inc. + Copyright (C) 2017-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #define _FILE_OFFSET_BITS 64 @@ -32,6 +32,8 @@ do_test (void) { do_test_with_invalid_flags (); do_test_without_offset (); + do_test_with_invalid_fd (); + do_test_with_invalid_iov (); return do_test_with_offset (0); } diff --git a/misc/tst-pselect.c b/misc/tst-pselect.c index fc28d64238..4c336b0329 100644 --- a/misc/tst-pselect.c +++ b/misc/tst-pselect.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006-2018 Free Software Foundation, Inc. +/* Copyright (C) 2006-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <signal.h> diff --git a/misc/tst-tsearch.c b/misc/tst-tsearch.c index 7d164f9a0a..abb7d26f38 100644 --- a/misc/tst-tsearch.c +++ b/misc/tst-tsearch.c @@ -1,5 +1,5 @@ /* Test program for tsearch et al. - Copyright (C) 1997-2018 Free Software Foundation, Inc. + Copyright (C) 1997-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 @@ -25,6 +25,7 @@ #include <string.h> #include <search.h> #include <tst-stack-align.h> +#include <support/check.h> #define SEED 0 #define BALANCED 1 @@ -74,6 +75,20 @@ static int max_depth; static int stack_align_check[2]; +/* Used to compare walk traces between the two implementations. */ +struct walk_trace_element +{ + const void *key; + VISIT which; + int depth; +}; +#define DYNARRAY_STRUCT walk_trace_list +#define DYNARRAY_ELEMENT struct walk_trace_element +#define DYNARRAY_PREFIX walk_trace_ +#define DYNARRAY_INITIAL_SIZE 0 +#include <malloc/dynarray-skeleton.c> +static struct walk_trace_list walk_trace; + /* Compare two keys. */ static int cmp_fn (const void *a, const void *b) @@ -102,11 +117,54 @@ memfry (int *string) } } +struct twalk_with_twalk_r_closure +{ + void (*action) (const void *, VISIT, int); + int depth; +}; + +static void +twalk_with_twalk_r_action (const void *nodep, VISIT which, void *closure0) +{ + struct twalk_with_twalk_r_closure *closure = closure0; + + switch (which) + { + case leaf: + closure->action (nodep, which, closure->depth); + break; + case preorder: + closure->action (nodep, which, closure->depth); + ++closure->depth; + break; + case postorder: + /* The preorder action incremented the depth. */ + closure->action (nodep, which, closure->depth - 1); + break; + case endorder: + --closure->depth; + closure->action (nodep, which, closure->depth); + break; + } +} + +static void +twalk_with_twalk_r (const void *root, + void (*action) (const void *, VISIT, int)) +{ + struct twalk_with_twalk_r_closure closure = { action, 0 }; + twalk_r (root, twalk_with_twalk_r_action, &closure); + TEST_COMPARE (closure.depth, 0); +} + static void walk_action (const void *nodep, const VISIT which, const int depth) { int key = **(int **) nodep; + walk_trace_add (&walk_trace, + (struct walk_trace_element) { nodep, which, depth }); + if (!stack_align_check[1]) stack_align_check[1] = TEST_STACK_ALIGN () ? -1 : 1; @@ -128,14 +186,16 @@ walk_action (const void *nodep, const VISIT which, const int depth) } static void -walk_tree (void *root, int expected_count) +walk_tree_with (void *root, int expected_count, + void (*walk) (const void *, + void (*) (const void *, VISIT, int))) { int i; memset (z, 0, sizeof z); max_depth = 0; - twalk (root, walk_action); + walk (root, walk_action); for (i = 0; i < expected_count; ++i) if (z[i] != 1) { @@ -154,6 +214,33 @@ walk_tree (void *root, int expected_count) } } +static void +walk_tree (void *root, int expected_count) +{ + walk_trace_clear (&walk_trace); + walk_tree_with (root, expected_count, twalk); + TEST_VERIFY (!walk_trace_has_failed (&walk_trace)); + size_t first_list_size; + struct walk_trace_element *first_list + = walk_trace_finalize (&walk_trace, &first_list_size); + TEST_VERIFY_EXIT (first_list != NULL); + + walk_tree_with (root, expected_count, twalk_with_twalk_r); + TEST_VERIFY (!walk_trace_has_failed (&walk_trace)); + + /* Compare the two traces. */ + TEST_COMPARE (first_list_size, walk_trace_size (&walk_trace)); + for (size_t i = 0; i < first_list_size && i < walk_trace_size (&walk_trace); + ++i) + { + TEST_VERIFY (first_list[i].key == walk_trace_at (&walk_trace, i)->key); + TEST_COMPARE (first_list[i].which, walk_trace_at (&walk_trace, i)->which); + TEST_COMPARE (first_list[i].depth, walk_trace_at (&walk_trace, i)->depth); + } + + walk_trace_free (&walk_trace); +} + /* Perform an operation on a tree. */ static void mangle_tree (enum order how, enum action what, void **root, int lag) diff --git a/misc/tst-warn-wide.c b/misc/tst-warn-wide.c new file mode 100644 index 0000000000..a3f02c745b --- /dev/null +++ b/misc/tst-warn-wide.c @@ -0,0 +1,88 @@ +/* Test wide output conversion for warn. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <err.h> +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <support/check.h> +#include <support/xmemstream.h> +#include <wchar.h> + +/* Used to trigger the large-string path in __fxprintf. */ +#define PADDING \ + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + +#define LPADDING \ + L"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + + +static void +one_test (const char *message, int error_code, const wchar_t *expected) +{ + wchar_t *buffer = NULL; + size_t length = 0; + FILE *fp = open_wmemstream (&buffer, &length); + TEST_VERIFY_EXIT (fp != NULL); + FILE *old_stderr = stderr; + stderr = fp; + errno = error_code; + switch (error_code) + { + case E2BIG: + warn ("%s with padding " PADDING, message); + break; + case EAGAIN: + warn ("%s", message); + break; + case -1: + warnx ("%s", message); + break; + case -2: + warnx ("%s with padding " PADDING, message); + break; + } + stderr = old_stderr; + TEST_VERIFY_EXIT (!ferror (fp)); + TEST_COMPARE (fclose (fp), 0); + if (wcscmp (buffer, expected) != 0) + FAIL_EXIT1 ("unexpected output: %ls", buffer); + free (buffer); +} + +static int +do_test (void) +{ + one_test ("no errno", -1, + L"tst-warn-wide: no errno\n"); + one_test ("no errno", -2, + L"tst-warn-wide: no errno with padding " PADDING "\n"); + one_test ("with errno", EAGAIN, + L"tst-warn-wide: with errno: Resource temporarily unavailable\n"); + one_test ("with errno", E2BIG, + L"tst-warn-wide: with errno with padding " PADDING + ": Argument list too long\n"); + return 0; +} + +#include <support/test-driver.c> diff --git a/misc/ualarm.c b/misc/ualarm.c index 7974076367..288db1f03e 100644 --- a/misc/ualarm.c +++ b/misc/ualarm.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/usleep.c b/misc/usleep.c index 7903cbe8ba..eba18ef05e 100644 --- a/misc/usleep.c +++ b/misc/usleep.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/ustat.c b/misc/ustat.c index 2c40e2a3cb..1f6352e352 100644 --- a/misc/ustat.c +++ b/misc/ustat.c @@ -1,5 +1,5 @@ /* Return info on filesystem. - Copyright (C) 1995-2018 Free Software Foundation, Inc. + Copyright (C) 1995-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <shlib-compat.h> diff --git a/misc/utimes.c b/misc/utimes.c index 0ae6946142..3d6db182aa 100644 --- a/misc/utimes.c +++ b/misc/utimes.c @@ -1,5 +1,5 @@ /* utimes -- Change access and modification times of file. Stub version. - Copyright (C) 1991-2018 Free Software Foundation, Inc. + Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <sys/time.h> #include <errno.h> diff --git a/misc/vhangup.c b/misc/vhangup.c index 4a31aa6f26..b732fea6cb 100644 --- a/misc/vhangup.c +++ b/misc/vhangup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> diff --git a/misc/writev.c b/misc/writev.c index 92f93889f8..0ea67bc85d 100644 --- a/misc/writev.c +++ b/misc/writev.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2018 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <unistd.h> |