From owner-svn-src-head@freebsd.org Wed Dec 5 19:18:17 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5F0771324F0E; Wed, 5 Dec 2018 19:18:17 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F05C085A3F; Wed, 5 Dec 2018 19:18:16 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CCDA118A9E; Wed, 5 Dec 2018 19:18:16 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wB5JIGEA060428; Wed, 5 Dec 2018 19:18:16 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wB5JIGxo060427; Wed, 5 Dec 2018 19:18:16 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201812051918.wB5JIGxo060427@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 5 Dec 2018 19:18:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r341604 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 341604 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: F05C085A3F X-Spamd-Result: default: False [-0.11 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.45)[-0.445,0]; NEURAL_SPAM_SHORT(0.41)[0.414,0]; NEURAL_HAM_LONG(-0.08)[-0.083,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Dec 2018 19:18:17 -0000 Author: brooks Date: Wed Dec 5 19:18:16 2018 New Revision: 341604 URL: https://svnweb.freebsd.org/changeset/base/341604 Log: Further simplify arguments to init. With the removal of BOOTCDROM and fastboot support, this code always passed "-s" or "--". The latter simply terminates getopt(3) processing in init so we only need to pass "-s" in the single user case, or nothing in other cases. The passing of "--" seems to have been done to ensure that the number of arguments passed to init was always the same and thus that argc was the same. Also GC the write-only variable pathlen (not in reviewed version). Reviewed by: kib, jhb Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D18441 Modified: head/sys/kern/init_main.c Modified: head/sys/kern/init_main.c ============================================================================== --- head/sys/kern/init_main.c Wed Dec 5 19:16:12 2018 (r341603) +++ head/sys/kern/init_main.c Wed Dec 5 19:18:16 2018 (r341604) @@ -718,9 +718,7 @@ static void start_init(void *dummy) { struct image_args args; - int options, error; - size_t pathlen; - char flags[8], *flagp; + int error; char *var, *path; char *free_init_path, *tmp_init_path; struct thread *td; @@ -744,7 +742,6 @@ start_init(void *dummy) free_init_path = tmp_init_path = strdup(init_path, M_TEMP); while ((path = strsep(&tmp_init_path, ":")) != NULL) { - pathlen = strlen(path) + 1; if (bootverbose) printf("start_init: trying %s\n", path); @@ -757,23 +754,11 @@ start_init(void *dummy) error = exec_args_add_fname(&args, path, UIO_SYSSPACE); if (error != 0) panic("%s: Can't add fname %d", __func__, error); - error = exec_args_add_arg(&args, path, UIO_SYSSPACE); if (error != 0) panic("%s: Can't add argv[0] %d", __func__, error); - - options = 0; - flagp = &flags[0]; - *flagp++ = '-'; - if (boothowto & RB_SINGLE) { - *flagp++ = 's'; - options++; - } - if (options == 0) - *flagp++ = '-'; - *flagp++ = 0; - KASSERT(flagp <= &flags[0] + sizeof(flags), ("Overran flags")); - error = exec_args_add_arg(&args, flags, UIO_SYSSPACE); + if (boothowto & RB_SINGLE) + error = exec_args_add_arg(&args, "-s", UIO_SYSSPACE); if (error != 0) panic("%s: Can't add argv[0] %d", __func__, error);