From 6b77e4cceb5ca58479d86418e3b2f19af9ff95a9 Mon Sep 17 00:00:00 2001 From: Lucas Holt Date: Thu, 5 Sep 2024 00:42:10 -0400 Subject: [PATCH] Cleanup --- lib/libutil/_secure_path.3 | 1 - lib/libutil/_secure_path.c | 2 -- lib/libutil/auth.c | 4 +--- lib/libutil/expand_number.3 | 13 ++++++++++--- lib/libutil/expand_number.c | 18 +++++++++++++++--- lib/libutil/flopen.3 | 3 +-- lib/libutil/flopen.c | 5 ++--- lib/libutil/fparseln.3 | 1 - lib/libutil/fparseln.c | 1 - lib/libutil/pidfile.3 | 1 - lib/libutil/property.3 | 2 -- lib/libutil/property.c | 5 +---- lib/libutil/pty.3 | 1 - lib/libutil/pty.c | 8 ++------ lib/libutil/pw_util.3 | 1 - lib/libutil/quotafile.3 | 3 +-- lib/libutil/quotafile.c | 6 ++---- lib/libutil/realhostname.3 | 2 -- lib/libutil/realhostname.c | 3 +-- lib/libutil/realhostname_sa.3 | 1 - lib/libutil/stub.c | 4 +--- lib/libutil/trimdomain.3 | 1 - lib/libutil/trimdomain.c | 3 +-- lib/libutil/uucplock.3 | 1 - lib/libutil/uucplock.c | 5 +---- 25 files changed, 39 insertions(+), 56 deletions(-) diff --git a/lib/libutil/_secure_path.3 b/lib/libutil/_secure_path.3 index a0b91daeab2..8b89f0ec2b8 100644 --- a/lib/libutil/_secure_path.3 +++ b/lib/libutil/_secure_path.3 @@ -17,7 +17,6 @@ .\" 5. Modifications may be freely made to this file providing the above .\" conditions are met. .\" -.\" .Dd May 10, 2020 .Dt _SECURE_PATH 3 .Os diff --git a/lib/libutil/_secure_path.c b/lib/libutil/_secure_path.c index 548bd3daa97..3deee78abc8 100644 --- a/lib/libutil/_secure_path.c +++ b/lib/libutil/_secure_path.c @@ -20,8 +20,6 @@ */ #include -__FBSDID("$FreeBSD: stable/11/lib/libutil/_secure_path.c 139012 2004-12-18 12:31:12Z ru $"); - #include #include diff --git a/lib/libutil/auth.c b/lib/libutil/auth.c index 97dcaa7b65a..3414fc8e26e 100644 --- a/lib/libutil/auth.c +++ b/lib/libutil/auth.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Simple authentication database handling code. * @@ -31,8 +31,6 @@ */ #include -__MBSDID("$FreeBSD: src/lib/libutil/auth.c,v 1.6 2003/06/14 18:42:37 markm Exp $"); - #include #include diff --git a/lib/libutil/expand_number.3 b/lib/libutil/expand_number.3 index faea73ea80e..3609b1ad393 100644 --- a/lib/libutil/expand_number.3 +++ b/lib/libutil/expand_number.3 @@ -23,9 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: stable/11/lib/libutil/expand_number.3 354034 2019-10-24 19:14:37Z jhb $ -.\" -.Dd July 20, 2019 +.Dd June 13, 2023 .Dt EXPAND_NUMBER 3 .Os .Sh NAME @@ -63,6 +61,15 @@ The suffixes are: .It Li P Ta No peta Ta 1125899906842624 .It Li E Ta No exa Ta 1152921504606846976 .El +.Pp +For historical reasons, the +.Fn expand_number +function accepts and ignores a single +.Dq B +suffix at the end of the +.Fa buf +string. +However, the usage of this suffix is discouraged. .Sh RETURN VALUES .Rv -std .Sh ERRORS diff --git a/lib/libutil/expand_number.c b/lib/libutil/expand_number.c index 7dd0214edb1..8346a2e5f07 100644 --- a/lib/libutil/expand_number.c +++ b/lib/libutil/expand_number.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2007 Eric Anderson * Copyright (c) 2007 Pawel Jakub Dawidek @@ -28,8 +28,6 @@ */ #include -__FBSDID("$FreeBSD: stable/11/lib/libutil/expand_number.c 331722 2018-03-29 02:50:57Z eadler $"); - #include #include #include @@ -76,6 +74,8 @@ expand_number(const char *buf, uint64_t *num) shift = 10; break; case 'b': + shift = 0; + break; case '\0': /* No unit. */ *num = number; return (0); @@ -85,6 +85,18 @@ expand_number(const char *buf, uint64_t *num) return (-1); } + /* + * Treat 'b' as an ignored suffix for all unit except 'b', + * otherwise there should be no remaining character(s). + */ + endptr++; + if (shift != 0 && tolower((unsigned char)*endptr) == 'b') + endptr++; + if (*endptr != '\0') { + errno = EINVAL; + return (-1); + } + if ((number << shift) >> shift != number) { /* Overflow */ errno = ERANGE; diff --git a/lib/libutil/flopen.3 b/lib/libutil/flopen.3 index 3834cb81316..259bbe16e9f 100644 --- a/lib/libutil/flopen.3 +++ b/lib/libutil/flopen.3 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2007 Dag-Erling Coïdan Smørgrav +.\" Copyright (c) 2007 Dag-Erling Smørgrav .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -23,7 +23,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" .Dd July 28, 2017 .Dt FLOPEN 3 .Os diff --git a/lib/libutil/flopen.c b/lib/libutil/flopen.c index 50f8f53f818..9fb3ec8aeae 100644 --- a/lib/libutil/flopen.c +++ b/lib/libutil/flopen.c @@ -1,7 +1,7 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2007-2009 Dag-Erling Coïdan Smørgrav + * Copyright (c) 2007-2009 Dag-Erling Smørgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,7 +28,6 @@ */ #include - #include #include diff --git a/lib/libutil/fparseln.3 b/lib/libutil/fparseln.3 index d412af74603..7ddfaefcc94 100644 --- a/lib/libutil/fparseln.3 +++ b/lib/libutil/fparseln.3 @@ -1,5 +1,4 @@ .\" $NetBSD: fparseln.3,v 1.7 1999/07/02 15:49:12 simonb Exp $ -.\" $FreeBSD: stable/11/lib/libutil/fparseln.3 267803 2014-06-23 18:40:21Z joel $ .\" .\" Copyright (c) 1997 Christos Zoulas. All rights reserved. .\" diff --git a/lib/libutil/fparseln.c b/lib/libutil/fparseln.c index 9089274ebae..170080f8aec 100644 --- a/lib/libutil/fparseln.c +++ b/lib/libutil/fparseln.c @@ -32,7 +32,6 @@ */ #include - #include #include #include diff --git a/lib/libutil/pidfile.3 b/lib/libutil/pidfile.3 index da8353bdc00..c4786736d28 100644 --- a/lib/libutil/pidfile.3 +++ b/lib/libutil/pidfile.3 @@ -22,7 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" .Dd May 10, 2020 .Dt PIDFILE 3 .Os diff --git a/lib/libutil/property.3 b/lib/libutil/property.3 index c92b3b90bcb..4e13d67402a 100644 --- a/lib/libutil/property.3 +++ b/lib/libutil/property.3 @@ -22,8 +22,6 @@ .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD: stable/11/lib/libutil/property.3 236965 2012-06-12 17:02:53Z des $ .\" " .Dd October 7, 1998 .Dt PROPERTIES 3 diff --git a/lib/libutil/property.c b/lib/libutil/property.c index 1e11739e21a..8ce2c9bc72c 100644 --- a/lib/libutil/property.c +++ b/lib/libutil/property.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * * Simple property list handling code. @@ -34,9 +34,6 @@ */ #include -/* $FreeBSD: src/lib/libutil/property.c,v 1.14 2005/11/28 16:30:16 jhb Exp $ */ -__MBSDID("$MidnightBSD: src/lib/libutil/property.c,v 1.4 2011/03/19 23:37:16 laffer1 Exp $"); - #include #include #include diff --git a/lib/libutil/pty.3 b/lib/libutil/pty.3 index 5ac298361ed..9d7ecd185b1 100644 --- a/lib/libutil/pty.3 +++ b/lib/libutil/pty.3 @@ -22,7 +22,6 @@ .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" .\" " .Dd June 2, 2018 .Dt PTY 3 diff --git a/lib/libutil/pty.c b/lib/libutil/pty.c index 4ed9b1ae529..e5b42a666c7 100644 --- a/lib/libutil/pty.c +++ b/lib/libutil/pty.c @@ -30,12 +30,7 @@ */ #include - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)pty.c 8.3 (Berkeley) 5/16/94"; -#endif -#endif /* LIBC_SCCS and not lint */ +__SCCSID("@(#)pty.c 8.3 (Berkeley) 5/16/94"); #include #include @@ -100,6 +95,7 @@ forkpty(int *amaster, char *name, struct termios *termp, struct winsize *winp) return (-1); switch (pid = fork()) { case -1: + (void)close(master); (void)close(slave); return (-1); case 0: diff --git a/lib/libutil/pw_util.3 b/lib/libutil/pw_util.3 index d3540697bd4..ed05818cd16 100644 --- a/lib/libutil/pw_util.3 +++ b/lib/libutil/pw_util.3 @@ -22,7 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" .Dd May 10, 2020 .Dt PW_UTIL 3 .Os diff --git a/lib/libutil/quotafile.3 b/lib/libutil/quotafile.3 index 480bbc9dd6d..5d2bff56bab 100644 --- a/lib/libutil/quotafile.3 +++ b/lib/libutil/quotafile.3 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2009 Dag-Erling Coïdan Smørgrav and +.\" Copyright (c) 2009 Dag-Erling Smørgrav and .\" Marshall Kirk McKusick. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -23,7 +23,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" .Dd December 28, 2009 .Dt QUOTAFILE 3 .Os diff --git a/lib/libutil/quotafile.c b/lib/libutil/quotafile.c index 969f302ceb4..1f02813dee9 100644 --- a/lib/libutil/quotafile.c +++ b/lib/libutil/quotafile.c @@ -1,7 +1,7 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2008 Dag-Erling Coïdan Smørgrav + * Copyright (c) 2008 Dag-Erling Smørgrav * Copyright (c) 2008 Marshall Kirk McKusick * All rights reserved. * @@ -26,8 +26,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD: stable/11/lib/libutil/quotafile.c 351730 2019-09-03 04:50:39Z sef $ */ #include diff --git a/lib/libutil/realhostname.3 b/lib/libutil/realhostname.3 index 77505c108c1..7b1b8bd0a85 100644 --- a/lib/libutil/realhostname.3 +++ b/lib/libutil/realhostname.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: stable/11/lib/libutil/realhostname.3 230234 2012-01-16 21:25:41Z ghelmer $ -.\" .Dd April 6, 1999 .Dt REALHOSTNAME 3 .Os diff --git a/lib/libutil/realhostname.c b/lib/libutil/realhostname.c index a187c518a38..02dca54af7a 100644 --- a/lib/libutil/realhostname.c +++ b/lib/libutil/realhostname.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1999 Brian Somers * All rights reserved. @@ -27,7 +27,6 @@ */ #include - #include #include diff --git a/lib/libutil/realhostname_sa.3 b/lib/libutil/realhostname_sa.3 index 4dcf4379f2c..6c3d77118cc 100644 --- a/lib/libutil/realhostname_sa.3 +++ b/lib/libutil/realhostname_sa.3 @@ -49,7 +49,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" .Dd January 11, 2000 .Dt REALHOSTNAME_SA 3 .Os diff --git a/lib/libutil/stub.c b/lib/libutil/stub.c index ff5e681d6a2..997a9e2d970 100644 --- a/lib/libutil/stub.c +++ b/lib/libutil/stub.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000 Brian Fundakowski Feldman * All rights reserved. @@ -27,8 +27,6 @@ */ #include -__FBSDID("$FreeBSD: stable/11/lib/libutil/stub.c 331722 2018-03-29 02:50:57Z eadler $"); - #include #include #include diff --git a/lib/libutil/trimdomain.3 b/lib/libutil/trimdomain.3 index 58b38a70c69..0e65a864936 100644 --- a/lib/libutil/trimdomain.3 +++ b/lib/libutil/trimdomain.3 @@ -22,7 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" .Dd April 7, 1999 .Dt TRIMDOMAIN 3 .Os diff --git a/lib/libutil/trimdomain.c b/lib/libutil/trimdomain.c index 595c08d7169..ce91ac64bab 100644 --- a/lib/libutil/trimdomain.c +++ b/lib/libutil/trimdomain.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001 Brian Somers * Based on original work by Atsushi Murai @@ -29,7 +29,6 @@ */ #include - #include #include diff --git a/lib/libutil/uucplock.3 b/lib/libutil/uucplock.3 index 6433ef3a067..dd19d0311b4 100644 --- a/lib/libutil/uucplock.3 +++ b/lib/libutil/uucplock.3 @@ -22,7 +22,6 @@ .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" .\" " .Dd May 10, 2020 .Dt UUCPLOCK 3 diff --git a/lib/libutil/uucplock.c b/lib/libutil/uucplock.c index f889d14c2f3..c9103536d91 100644 --- a/lib/libutil/uucplock.c +++ b/lib/libutil/uucplock.c @@ -30,10 +30,7 @@ */ #include - -#ifndef lint -static const char sccsid[] = "@(#)uucplock.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ +__SCCSID("@(#)uucplock.c 8.1 (Berkeley) 6/6/93"); #include #include