From owner-svn-src-head@freebsd.org Thu Dec 27 13:02:17 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 51379135E779; Thu, 27 Dec 2018 13:02:17 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E68CF72908; Thu, 27 Dec 2018 13:02:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AE9C0BE5B; Thu, 27 Dec 2018 13:02:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBRD2G0W085001; Thu, 27 Dec 2018 13:02:16 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBRD2GjU084998; Thu, 27 Dec 2018 13:02:16 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201812271302.wBRD2GjU084998@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 27 Dec 2018 13:02:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r342551 - in head/lib/libc: gen include string X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in head/lib/libc: gen include string X-SVN-Commit-Revision: 342551 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E68CF72908 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.956,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Dec 2018 13:02:17 -0000 Author: kib Date: Thu Dec 27 13:02:15 2018 New Revision: 342551 URL: https://svnweb.freebsd.org/changeset/base/342551 Log: Bump sys_errlist size to keep ABI backward-compatible for some time. Addition of the new errno values requires adding new elements to sys_errlist array, which is actually ABI-incompatible, since ELF records the object size. Expand array in advance to 150 elements so that we have our users to go over the issue only once, at least until more than 53 new errors are added. I did not bumped the symbol version, same as it was not done for previous increases of the array size. Runtime linker only copies as much data into binary object on copy relocation as the binary'object specifies. This is not fixable for binaries which access sys_errlist directly. While there, correct comment and calculation of the temporary buffer size for the message printed for unknown error. The on-stack buffer is used only for the number and delimiter since r108603. Requested by: mckusick Reviewed by: mckusick, yuripv MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D18656 Modified: head/lib/libc/gen/errlst.c head/lib/libc/include/errlst.h head/lib/libc/string/strerror.c Modified: head/lib/libc/gen/errlst.c ============================================================================== --- head/lib/libc/gen/errlst.c Thu Dec 27 08:48:54 2018 (r342550) +++ head/lib/libc/gen/errlst.c Thu Dec 27 13:02:15 2018 (r342551) @@ -33,9 +33,12 @@ __SCCSID("@(#)errlst.c 8.2 (Berkeley) 11/16/93"); __FBSDID("$FreeBSD$"); +#include #include #include "errlst.h" +const char __uprefix[] = "Unknown error"; + const char *const sys_errlist[] = { "No error: 0", /* 0 - ENOERROR */ "Operation not permitted", /* 1 - EPERM */ @@ -155,8 +158,67 @@ const char *const sys_errlist[] = { "Not permitted in capability mode", /* 94 - ECAPMODE */ "State not recoverable", /* 95 - ENOTRECOVERABLE */ "Previous owner died", /* 96 - EOWNERDEAD */ + +/* + * Reserved space in sys_errlist, take the next slot for a next error code. + * Reserve prevents the array size from changing for some time. + */ + __uprefix, /* 97 */ + __uprefix, /* 98 */ + __uprefix, /* 99 */ + __uprefix, /* 100 */ + __uprefix, /* 101 */ + __uprefix, /* 102 */ + __uprefix, /* 103 */ + __uprefix, /* 104 */ + __uprefix, /* 105 */ + __uprefix, /* 106 */ + __uprefix, /* 107 */ + __uprefix, /* 108 */ + __uprefix, /* 109 */ + __uprefix, /* 110 */ + __uprefix, /* 111 */ + __uprefix, /* 112 */ + __uprefix, /* 113 */ + __uprefix, /* 114 */ + __uprefix, /* 115 */ + __uprefix, /* 116 */ + __uprefix, /* 117 */ + __uprefix, /* 118 */ + __uprefix, /* 119 */ + __uprefix, /* 120 */ + __uprefix, /* 121 */ + __uprefix, /* 122 */ + __uprefix, /* 123 */ + __uprefix, /* 124 */ + __uprefix, /* 125 */ + __uprefix, /* 126 */ + __uprefix, /* 127 */ + __uprefix, /* 128 */ + __uprefix, /* 129 */ + __uprefix, /* 130 */ + __uprefix, /* 131 */ + __uprefix, /* 132 */ + __uprefix, /* 133 */ + __uprefix, /* 134 */ + __uprefix, /* 135 */ + __uprefix, /* 136 */ + __uprefix, /* 137 */ + __uprefix, /* 138 */ + __uprefix, /* 139 */ + __uprefix, /* 140 */ + __uprefix, /* 141 */ + __uprefix, /* 142 */ + __uprefix, /* 143 */ + __uprefix, /* 144 */ + __uprefix, /* 145 */ + __uprefix, /* 146 */ + __uprefix, /* 147 */ + __uprefix, /* 148 */ + __uprefix, /* 149 */ + __uprefix, /* 150 */ }; -const int sys_nerr = sizeof(sys_errlist) / sizeof(sys_errlist[0]); +const int sys_nerr = ELAST + 1; #ifdef PIC __strong_reference(sys_errlist, __hidden_sys_errlist); Modified: head/lib/libc/include/errlst.h ============================================================================== --- head/lib/libc/include/errlst.h Thu Dec 27 08:48:54 2018 (r342550) +++ head/lib/libc/include/errlst.h Thu Dec 27 13:02:15 2018 (r342551) @@ -42,4 +42,6 @@ extern const int __hidden_sys_nerr __hidden; #define __hidden_sys_nerr sys_nerr #endif +extern const char __uprefix[] __hidden; + #endif /* __ERRLST_H__ */ Modified: head/lib/libc/string/strerror.c ============================================================================== --- head/lib/libc/string/strerror.c Thu Dec 27 08:48:54 2018 (r342550) +++ head/lib/libc/string/strerror.c Thu Dec 27 13:02:15 2018 (r342551) @@ -46,15 +46,12 @@ __FBSDID("$FreeBSD$"); #include "errlst.h" -#define UPREFIX "Unknown error" - /* - * Define a buffer size big enough to describe a 64-bit signed integer - * converted to ASCII decimal (19 bytes), with an optional leading sign - * (1 byte); finally, we get the prefix, delimiter (": ") and a trailing - * NUL from UPREFIX. + * Define buffer big enough to contain delimiter (": ", 2 bytes), + * 64-bit signed integer converted to ASCII decimal (19 bytes) with + * optional leading sign (1 byte), and a trailing NUL. */ -#define EBUFSIZE (20 + 2 + sizeof(UPREFIX)) +#define EBUFSIZE (2 + 19 + 1 + 1) /* * Doing this by hand instead of linking with stdio(3) avoids bloat for @@ -94,9 +91,9 @@ strerror_r(int errnum, char *strerrbuf, size_t buflen) if (errnum < 0 || errnum >= __hidden_sys_nerr) { errstr(errnum, #if defined(NLS) - catgets(catd, 1, 0xffff, UPREFIX), + catgets(catd, 1, 0xffff, __uprefix), #else - UPREFIX, + __uprefix, #endif strerrbuf, buflen); retval = EINVAL;