From nobody Wed Dec 07 18:06:28 2022 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 4NS4wh61jyz4jRNR; Wed, 7 Dec 2022 18:06:28 +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 4NS4wh5YRwz4Lmf; Wed, 7 Dec 2022 18:06:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670436388; 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=Po/Syn40lqQ2eN3xT5u4WIHOK37ira0ZMqVVskYJPh0=; b=Ln2eKZgso5odOIT8eYJYmDsidGxYQzvNzI6JyqZdUjYropPD2qX726Q5eD+QPt062+sR17 55KTjmxJRfEtFOphO6SCPK2UTD5i67160O+K/PWJQvpmek+Vl8s9j8rTildqPSOH7xF2L1 qh2sD6fVshmQslLOX84agvj4CbN3HF42p1c9og3uzQpB8NZSoTAclPorL2bWlqNuUVQHWQ v+uWQ7ZjbfMFL0k+MpgPMgmkbHeDZWxWimsz/A5GvNdsnOQt0U/8TJeBA33YbylOgzYNze Rq9Natlxp3fp+/vXlbNchcG6tC607GAbc/YFhDjZXt99f6kKKmZBzIAF8oTaUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670436388; 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=Po/Syn40lqQ2eN3xT5u4WIHOK37ira0ZMqVVskYJPh0=; b=eyJzidYOBWdiroqzJgbUqx6HszGeTysdh3fqnBlPAe4uQo7Xs+GgosukzELhDR9VElOLd3 3Zr/j7MCcsYw8HYP/ZuvfWkrBsjTgT4AChwdjGEkA88dOzbAqDu3xoAp6ezP6opMupTDnO /Qv7u1wAPqMCjfSKLAMYxPH9c1Ph7EO+h4EnuB50WPWpYYV2VKQzjKZmCWsR+oBrnLA7r/ Xph8XorUAUdUALAECuBmdJ+ekVkZIs0wt9z+vPcm3wAf9yE7TKpkrYR9jOBpe0LIwxXXhs Aeff69djhfEozDSrFcYTbjanM+s7Qy7trZdWRwL4nc3n+F9Hmta/pj01aQH7rg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670436388; a=rsa-sha256; cv=none; b=YpOvee+pPBqYlJPuKYiHGZdEWRoFcXrkuRXAeadfdZ6FrHgh6Q8oeGyIt63has6jx9lLzE ZjXzG7j5SR+wyjkWi5fhbhxDAh9T4sMOWU66t09mVti1J2RzHQP5L0rqeehrHkkxHgANb+ czfOk2HO9O4k0iPow9309nPfr9d74sK7xpZLUWA/tJRLPDvoUytgXNtAOp6dSdnBZofaXb ZsvkRMEqTM6CQQ5LUQOjkU3/Utvkt4lRqXbvZgNgbPsWfbENrDEocbPp5oJEa2hk3m6GR8 lL9DxlBpsZgfI6/BFuiRALOaQ5cj7p4sUBpZfnTmDr4YbwaEaGgWx+MESOcE0g== 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 4NS4wh4fjczQqf; Wed, 7 Dec 2022 18:06:28 +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 2B7I6Sn3072472; Wed, 7 Dec 2022 18:06:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B7I6S4k072471; Wed, 7 Dec 2022 18:06:28 GMT (envelope-from git) Date: Wed, 7 Dec 2022 18:06:28 GMT Message-Id: <202212071806.2B7I6S4k072471@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: ed56dcfc6b1f - main - boot: pass in args as const 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: ed56dcfc6b1f4de2a5ae4f0f86dff5dfe0a5541c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ed56dcfc6b1f4de2a5ae4f0f86dff5dfe0a5541c commit ed56dcfc6b1f4de2a5ae4f0f86dff5dfe0a5541c Author: Warner Losh AuthorDate: 2022-12-07 00:36:29 +0000 Commit: Warner Losh CommitDate: 2022-12-07 18:00:54 +0000 boot: pass in args as const Copy the arg that sets a variable to maximize the reuse of this routine. There are places we call it from that are const char * and it might not be safe to cast that away. Sponsored by: Netflix --- sys/kern/subr_boot.c | 13 +++++++++---- sys/sys/boot.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sys/kern/subr_boot.c b/sys/kern/subr_boot.c index 82dd4195edfd..49c7769afce4 100644 --- a/sys/kern/subr_boot.c +++ b/sys/kern/subr_boot.c @@ -125,7 +125,7 @@ boot_howto_to_env(int howto) * variable and set that instead. */ int -boot_parse_arg(char *v) +boot_parse_arg(const char *v) { char *n; int howto; @@ -170,11 +170,16 @@ static int howto_masks[] = { } } } else { - n = strsep(&v, "="); - if (v == NULL) + char buf[128]; + char *vv = buf; + + strlcpy(buf, v, sizeof(buf)); + n = strsep(&vv, "="); + if (vv == NULL) SETENV(n, "1"); else - SETENV(n, v); + SETENV(n, vv); + free(vv); } #endif return (howto); diff --git a/sys/sys/boot.h b/sys/sys/boot.h index 7874d9663736..26e39d70fd51 100644 --- a/sys/sys/boot.h +++ b/sys/sys/boot.h @@ -36,7 +36,7 @@ int boot_env_to_howto(void); void boot_howto_to_env(int howto); -int boot_parse_arg(char *v); +int boot_parse_arg(const char *v); int boot_parse_cmdline_delim(char *cmdline, const char *delim); int boot_parse_cmdline(char *cmdline); int boot_parse_args(int argc, char *argv[]);