From nobody Fri Jun 14 16:16:06 2024 X-Original-To: dev-commits-src-main@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 4W14CB6GWGz5P6N1; Fri, 14 Jun 2024 16:16:06 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4W14CB5hX3z4rZZ; Fri, 14 Jun 2024 16:16:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718381766; 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=HuefF3V4hF41ed7som96ZkokQvEJf2mU0aDdmdVNYFI=; b=WmpcHYThsUYSzqTuyPnQMAa5CjCNi4gL7tozD3b4ZK8FzWcu0LbCbRy5XuXU2FbTwOasAw xRVemH9IETUVIiw3Ob8S6behxE+czHybo9EpK26OhwCu4SjDH3962oEuYhE0QCtUdBrcjy dATS3pPw9JnXpFhOaZYZYevETK/2RWZII6Q9Kcr9eXdk3I7XIMuU9RjYIPw42pY8w4AyHo v9u3sXofr3XqIkMSUa0x/6qIihsZWPFLsCWAU7cG/oX3xhispOVsUOww9oJzSsQoc6S8KO 4M3WXucxohqxCyX3V36TdQ/hsdq/KjUjGJbcf4J84+ZYOgKq/ksGeW+zihJ9QQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718381766; a=rsa-sha256; cv=none; b=mq7gHqzpxRe6DpP373MILTkiDbupPKiaJZuf/QfRBv2OyxhTBXZs6E0FLTEjyO5Qga8NIB 8Q2OPVT6YMlOuqpjrNPhE24fQ9q82P5x5o3+ShHk8YYDe9ssCCYwtKO8SoKBhx/lnC/Hht 3OyCEnaZ5d1lJ/Py0jEBTOg+tt+15LzL6JB4IxZip0m9jxCO26JC1r8H0LgcqUKwwZcZXD mRLP+m8PP6+il6C0EBcAhBS2UvtgncsqejeIANWj4LOistlNpkEj5QCuLKvejIiojNDm+l UbGbNTXSgNlFWFIs0cKILRXW12xCiA01HpHfdhmFoTJs0n0+kbV5ZjzcggUhaA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718381766; 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=HuefF3V4hF41ed7som96ZkokQvEJf2mU0aDdmdVNYFI=; b=QTtT/4yLJ6T/SVkSF60c1Fv7Xx0LFvA+oumm/FpUYfX07/U/aro7WiF+1kTM5HzjxCFkEg dpYVz//pXqYKqGWCTL4O7YgbG7Cnommp+FAvUDCsmdjwtSXOnJKa7lCjXEPSbHJdSRJWAJ ZfEW/Rvm1WCGjjzQ6NUpe9jchz8TSrGsdbf8lgGLuW/1syQTHlW5b5mXe23yAk+l2xNJJE FokmmNEthk3NyEVCmMRYKCvCaQ3++dbYui88RAf76FzdeJQRewA6aICCv8Ia7TFmUgVbDt g/n9f6bP99H3osUO87skCfkRm6qGgmlAWxQb/HtqAir06vKentzzDJl4I8h48A== 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 4W14CB59PszR61; Fri, 14 Jun 2024 16:16:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45EGG621065858; Fri, 14 Jun 2024 16:16:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45EGG6U9065855; Fri, 14 Jun 2024 16:16:06 GMT (envelope-from git) Date: Fri, 14 Jun 2024 16:16:06 GMT Message-Id: <202406141616.45EGG6U9065855@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: aa6fb1d277be - main - tzsetup: ask local/UTC question only on x86 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aa6fb1d277be47c51abc309ac9305def0fce7f9d Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=aa6fb1d277be47c51abc309ac9305def0fce7f9d commit aa6fb1d277be47c51abc309ac9305def0fce7f9d Author: Ed Maste AuthorDate: 2024-06-12 23:48:24 +0000 Commit: Ed Maste CommitDate: 2024-06-14 16:15:48 +0000 tzsetup: ask local/UTC question only on x86 Storing local time in the RTC is a legacy of 1990s PCs; it's not relevant on other platforms of interest to FreeBSD. While here switch to C99 bool. Sponsored by: The FreeBSD Foundation Reviewed by: allanjude (earlier), imp (earlier) Differential Revision: https://reviews.freebsd.org/D45575 --- usr.sbin/tzsetup/tzsetup.8 | 3 ++- usr.sbin/tzsetup/tzsetup.c | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/usr.sbin/tzsetup/tzsetup.8 b/usr.sbin/tzsetup/tzsetup.8 index 499d25765541..4e70875ec74b 100644 --- a/usr.sbin/tzsetup/tzsetup.8 +++ b/usr.sbin/tzsetup/tzsetup.8 @@ -62,7 +62,8 @@ Skip the initial question about adjusting the clock if not set to UTC. .Nm will neither create nor delete .Pa /etc/wall_cmos_clock . -On a newly installed system the hardware clock will keep UTC. +On a newly installed system, the hardware clock will keep UTC. +This option is enabled automatically on non-x86 hardware. .El .Pp It is possible to short-circuit the menu system by specifying the diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c index 617de4efb765..6629dd81f250 100644 --- a/usr.sbin/tzsetup/tzsetup.c +++ b/usr.sbin/tzsetup/tzsetup.c @@ -826,23 +826,28 @@ main(int argc, char **argv) char prompt[128]; int fd; #endif - int c, rv, skiputc; + int c, rv; + bool skiputc; + char *dztpath; +#if defined(__i386__) || defined(__amd64__) char vm_guest[16] = ""; size_t len = sizeof(vm_guest); - char *dztpath; + skiputc = false; + + /* Default skiputc to true for VM guests */ + if (sysctlbyname("kern.vm_guest", vm_guest, &len, NULL, 0) == 0 && + strcmp(vm_guest, "none") != 0) + skiputc = true; +#else + skiputc = true; +#endif dztpath = NULL; - skiputc = 0; #ifdef HAVE_BSDDIALOG setlocale(LC_ALL, ""); #endif - /* Default skiputc to 1 for VM guests */ - if (sysctlbyname("kern.vm_guest", vm_guest, &len, NULL, 0) == 0 && - strcmp(vm_guest, "none") != 0) - skiputc = 1; - while ((c = getopt(argc, argv, "C:d:nrs")) != -1) { switch (c) { case 'C': @@ -861,7 +866,7 @@ main(int argc, char **argv) #endif break; case 's': - skiputc = 1; + skiputc = true; break; default: usage(); @@ -951,7 +956,7 @@ main(int argc, char **argv) if (bsddialog_init() == BSDDIALOG_ERROR) errx(1, "Error bsddialog: %s\n", bsddialog_geterror()); - if (skiputc == 0) { + if (!skiputc) { snprintf(prompt, sizeof(prompt), "Is this machine's CMOS clock set to UTC? " "If it is set to local time,\n"