From nobody Mon May 01 21:04:19 2023 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 4Q9G0z3V9Yz491VM; Mon, 1 May 2023 21:04:19 +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 4Q9G0z2thKz3J26; Mon, 1 May 2023 21:04:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682975059; 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=2B8NEASbiy7uMb7Pd/KgrKb2sCo+DIt7mWyYypvEbM4=; b=QyqtdC6RlMFfNY2CtHP/rpTHOWiL3/lvAbvAyqaFlcYw5HLx2MNS1ONe6Bgm7odl7IwIg1 eOLOHmgeio2Nu2H4IaoAno+O/HqXVDRi8pk3/G2Hv/LBv4GH4Ll4xFciVL3LGysSv6PdJ0 m5kf5GWWxQXKTJOJYv2JZfrNarvP2sf0TqBm5GioddZRoIhfhmib0PzPynh+KLyG6dIxio 2e+deA9cOMZkAGbCm0VIE/9KRDpHSfNjyQqspzAp3xQF3nbfXYkUOCR5P7TgoBe5w1vle7 bRH8k45csIKA8wLduac0OFY/DivwhXIAiZoeJTVulLPWp8QPZ39CM6A+HsOgig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682975059; 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=2B8NEASbiy7uMb7Pd/KgrKb2sCo+DIt7mWyYypvEbM4=; b=i/Dy5S+mb/WlyZCYUIZFcn99PBMCCbdBRSNYYyF94UzvYtk1/z5D2QNUXd99GQUu2uei7C ERkKkHksvNLWI6PoWA4tceackaOuceoiSh6l2kyPpLbwPuBsFh20zesd+n0D+p0TyOjzJ8 WCaGrOR6djA+1zyDfGJ4dF9J8HECLBNvD5cwvWgqO1EtndkrBKDHyYMKVOaXoLscemBhOO KX1qDhzXHtgnDYmNpuXT76+xsZdtVImeLUGIjHH3cTdsbq5ro0gZnXCwes1/8CxPAATEby yIFyBBvwk9DYlz45a9xNFOzho/2UJoFKnXbX4wMWwtBv7n9FEDu6sI+WDhL8Qg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682975059; a=rsa-sha256; cv=none; b=yZRML6uyMidIMktnYcPV5/YbD/m9blNFzxoZrnv61xTN/w/aElVbR6phB5BLtx9uTYjMHM UcmLeFG7Yi+HNsjYRQ6YlBF8my6r0wpEQxn/RTMTjsa6L6Eyqo4wE2y+ZKYT3tLcjVp4qx FGpWSpegibD3ANpETyF23QvJGVL0EVZ1zMq+xa8W3rtiTNHZqRTf2ldlZc4UsIofmQbxF4 WVy4SNym4BLceZ1oFVU5V9Tdtlrg6/IfGWh7sRNZs61f3+WjotGx2lslmWPp2eb1zjSi1p zNYfMa5PPxCcJvbyIVEq+3EZmwHlxtw/EgY1cNlU3PEU7qN9TVDoAywu7vuaPg== 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 4Q9G0z1mygzL9k; Mon, 1 May 2023 21:04:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 341L4JY7051873; Mon, 1 May 2023 21:04:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 341L4JTS051872; Mon, 1 May 2023 21:04:19 GMT (envelope-from git) Date: Mon, 1 May 2023 21:04:19 GMT Message-Id: <202305012104.341L4JTS051872@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 5ce98ee5f42d - main - stand/userboot: Simplify code 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5ce98ee5f42de10d29f3a99719652c272d13c2e7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=5ce98ee5f42de10d29f3a99719652c272d13c2e7 commit 5ce98ee5f42de10d29f3a99719652c272d13c2e7 Author: Warner Losh AuthorDate: 2023-05-01 15:28:17 +0000 Commit: Warner Losh CommitDate: 2023-05-01 21:02:53 +0000 stand/userboot: Simplify code We have way more than 8k of stack for the current value of the zfs bootonce attribute. Allocate buf on the stack rather than the complicated malloc / free dance. Sponsored by: Netflix Reviewed by: tsoome, kevans, jhb Differential Revision: https://reviews.freebsd.org/D39414 --- stand/userboot/userboot/main.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/stand/userboot/userboot/main.c b/stand/userboot/userboot/main.c index b134d86de9bd..3dde6f6b4109 100644 --- a/stand/userboot/userboot/main.c +++ b/stand/userboot/userboot/main.c @@ -235,7 +235,6 @@ extract_currdev(void) struct devdesc *dd; #if defined(USERBOOT_ZFS_SUPPORT) struct zfs_devdesc zdev; - char *buf = NULL; if (userboot_zfs_found) { @@ -272,17 +271,14 @@ extract_currdev(void) #if defined(USERBOOT_ZFS_SUPPORT) if (userboot_zfs_found) { - buf = malloc(VDEV_PAD_SIZE); - if (buf != NULL) { - if (zfs_get_bootonce(&zdev, OS_BOOTONCE, buf, - VDEV_PAD_SIZE) == 0) { - printf("zfs bootonce: %s\n", buf); - set_currdev(buf); - setenv("zfs-bootonce", buf, 1); - } - free(buf); - (void) zfs_attach_nvstore(&zdev); + char buf[VDEV_PAD_SIZE]; + + if (zfs_get_bootonce(&zdev, OS_BOOTONCE, buf, sizeof(buf)) == 0) { + printf("zfs bootonce: %s\n", buf); + set_currdev(buf); + setenv("zfs-bootonce", buf, 1); } + (void)zfs_attach_nvstore(&zdev); } #endif }