Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Oct 2024 18:30:13 GMT
From:      Li-Wen Hsu <lwhsu@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: aaa302d17fe1 - main - last(1): Complete libxo transition
Message-ID:  <202410121830.49CIUDdl089132@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by lwhsu:

URL: https://cgit.FreeBSD.org/src/commit/?id=aaa302d17fe1ac0e7075ce9189c1452fe49dce36

commit aaa302d17fe1ac0e7075ce9189c1452fe49dce36
Author:     Yan-Hao Wang <yanhaowang@FreeBSD.org>
AuthorDate: 2024-10-12 14:05:14 +0000
Commit:     Li-Wen Hsu <lwhsu@FreeBSD.org>
CommitDate: 2024-10-12 18:21:45 +0000

    last(1): Complete libxo transition
    
    Reviewed by:    des
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D41424
---
 usr.bin/last/last.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c
index c6b1b646ab70..69848f359d79 100644
--- a/usr.bin/last/last.c
+++ b/usr.bin/last/last.c
@@ -36,7 +36,6 @@
 #include <sys/stat.h>
 
 #include <capsicum_helpers.h>
-#include <err.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <langinfo.h>
@@ -106,7 +105,7 @@ usage(void)
 	xo_error(
 "usage: last [-swy] [-d [[CC]YY][MMDD]hhmm[.SS]] [-f file] [-h host]\n"
 "            [-n maxrec] [-t tty] [user ...]\n");
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 int
@@ -120,8 +119,7 @@ main(int argc, char *argv[])
 
 	argc = xo_parse_args(argc, argv);
 	if (argc < 0)
-		exit(1);
-	atexit(xo_finish_atexit);
+		exit(EXIT_FAILURE);
 
 	maxrec = -1;
 	snaptime = 0;
@@ -138,8 +136,11 @@ main(int argc, char *argv[])
 				if (p == NULL)
 					p = strchr(argv[optind], ch);
 				maxrec = atol(p);
-				if (!maxrec)
-					exit(0);
+				if (!maxrec) {
+					if (xo_finish() < 0)
+						xo_err(EXIT_FAILURE, "stdout");
+					exit(EXIT_SUCCESS);
+				}
 			}
 			break;
 		case 'd':
@@ -205,7 +206,9 @@ main(int argc, char *argv[])
 		}
 	}
 	wtmp();
-	exit(0);
+	if (xo_finish() < 0)
+		xo_err(EXIT_FAILURE, "stdout");
+	exit(EXIT_SUCCESS);
 }
 
 /*
@@ -278,8 +281,11 @@ doentry(struct utmpx *bp)
 		 * shutdown/reboot appears while we are tracking the
 		 * active range
 		 */
-		if (snaptime && snapfound)
-			exit(0);
+		if (snaptime && snapfound) {
+			if (xo_finish() < 0)
+				xo_err(EXIT_FAILURE, "stdout");
+			exit(EXIT_SUCCESS);
+		}
 		/*
 		 * don't print shutdown/reboot entries unless flagged for
 		 */
@@ -340,8 +346,11 @@ printentry(struct utmpx *bp, struct idtab *tt)
 	time_t	delta;				/* time difference */
 	time_t	t;
 
-	if (maxrec != -1 && !maxrec--)
-		exit(0);
+	if (maxrec != -1 && !maxrec--) {
+		if (xo_finish() < 0)
+			xo_err(EXIT_FAILURE, "stdout");
+		exit(EXIT_SUCCESS);
+	}
 	xo_open_instance("last");
 	t = bp->ut_tv.tv_sec;
 	tm = localtime(&t);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202410121830.49CIUDdl089132>