From nobody Sat Oct 12 18:30:13 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XQsVY26Zrz5YnX5; Sat, 12 Oct 2024 18:30:13 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XQsVY1bmZz4Dbl; Sat, 12 Oct 2024 18:30:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728757813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5l6mNV90/Derdbc+5IAV4IOtDfqQMW2T18yJssexedk=; b=gYBRsVHux0HeYNtgcurVewPA+auEI9l35zI8IlFcGdAsqBKUJhR3WvyCRGNhzILBkkBBZf KuviiLRzo6cqsEZjUnEx8P3XqN/wVAMcwnV6/I5FGxTsigcDMrgw0a398TrEgVMYwoZsQU d6vPe06ws8oj9Yt5Y4qnmOgVrDAo4x4cQFZRnMQS9fEU4xxfB7XM8sA5x/T8e6jJ/b7nBX zV3p7LDQzT58GKGwjoSKhQexypvmGJ4zj/PySDgU5wRukaHZEtlxDjsAz6wOKsIUTK28So ESv1K7hSZH0xXDSKKEIT0QPG6ohG7qQL4GKZp60Jr/PHzLHmsrjajAvuSY1wsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728757813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5l6mNV90/Derdbc+5IAV4IOtDfqQMW2T18yJssexedk=; b=gOD5kk1HxZGOUB6Z8Be++jYp21PlXWD3pjEsVwryUJVWjIIfSc/UYGIAtE7MAwlRLzziog CIQcpoc2uyW0ZMyUhN68IbjQ7oz36lu1VxA/njfcbYJcVy8QqQeSFhEDg3Al+coRtnlliM SFAg5OTWVdMQ15dXpnE7VtOSzgXaKFbxuNtCCKmCM+Kq5QCLNxf1nnUn2E+zQ+JRr1/AIy g6vrA7irfPXgPs8azT8GE5Js4PvqMrXcpeWhjHq4fn+NacsQKYGbfQitENrinq4hz6nyku kFbVV/o8c4OrxI1kzqAfUCXN2ZynDhzHpKkL7g+DzVboc7F83p6fs168K2aA3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728757813; a=rsa-sha256; cv=none; b=XOnDYnhlFIt8Ef2K9t8kC8yfVczBevphv5qQkF3XUdIIctpytEFA2101McX39nXstghzV6 m38ESnGWAAUc2cbqjKLYxQ4SU59uTS2wqUpU4uhAiXYIYmZSrfaX79BL8/97V9bAMgECGG RB+stadrSc9JtkxqwffB7Nx2NYdK7ewErad7P0R2vEMUafwI3i7Dl0qgYiS1SWpzXkeymg tv0Pnuamc/wGrNUt7v7Td0MN7GqQOnpqMWAzbQzpKqw0i9fE9FbqiUs8up2pLbjtxnR4vK sQacdCNBMyqRghJ6P/H59Z/+lerWE+o+ig4fhDuBIUyQxw/x5ONpvImVsHSZ0A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XQsVY11HfzLmt; Sat, 12 Oct 2024 18:30:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49CIUDAc089137; Sat, 12 Oct 2024 18:30:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49CIUDdl089132; Sat, 12 Oct 2024 18:30:13 GMT (envelope-from git) Date: Sat, 12 Oct 2024 18:30:13 GMT Message-Id: <202410121830.49CIUDdl089132@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Li-Wen Hsu Subject: git: aaa302d17fe1 - main - last(1): Complete libxo transition List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: lwhsu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aaa302d17fe1ac0e7075ce9189c1452fe49dce36 Auto-Submitted: auto-generated The branch main has been updated by lwhsu: URL: https://cgit.FreeBSD.org/src/commit/?id=aaa302d17fe1ac0e7075ce9189c1452fe49dce36 commit aaa302d17fe1ac0e7075ce9189c1452fe49dce36 Author: Yan-Hao Wang AuthorDate: 2024-10-12 14:05:14 +0000 Commit: Li-Wen Hsu 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 #include -#include #include #include #include @@ -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);