From owner-svn-src-all@freebsd.org Sun Jan 6 02:12:56 2019 Return-Path: Delivered-To: svn-src-all@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 9F738142F87E; Sun, 6 Jan 2019 02:12:56 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3A0598317F; Sun, 6 Jan 2019 02:12:56 +0000 (UTC) (envelope-from kevans@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 2AEDB21A39; Sun, 6 Jan 2019 02:12:56 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x062Ctn3081895; Sun, 6 Jan 2019 02:12:55 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x062Ctgw081894; Sun, 6 Jan 2019 02:12:55 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201901060212.x062Ctgw081894@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 6 Jan 2019 02:12:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r342806 - stable/12/usr.sbin/config X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/usr.sbin/config X-SVN-Commit-Revision: 342806 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3A0598317F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.92 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.92)[-0.921,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jan 2019 02:12:56 -0000 Author: kevans Date: Sun Jan 6 02:12:55 2019 New Revision: 342806 URL: https://svnweb.freebsd.org/changeset/base/342806 Log: MFC r342362-r342363: config(8) duplicate option handling r342362: config(8): Allow duplicate options to be specified config(8)'s option handling has been written to allow duplicate options; if the value changes, then the latest value is used and an informative message is printed to stderr like so: /usr/src/sys/amd64/conf/TEST: option "VERBOSE_SYSINIT" redefined from 0 to 1 Currently, this is only a possibility for cpu types, MAXUSERS, and MACHINE_ARCH. Anything else duplicated in a config file will use the first value set and error about duplicated options on subsequent appearances, which is arguably unfriendly since one could specify: include GENERIC nooptions VERBOSE_SYSINIT options VERBOSE_SYSINIT to redefine the value later anyways. Reported by: mmacy r342363: config(8): Remove all instances of an option when opting out Quick follow-up to r342362: options can appear multiple times now, so clean up all of them as needed. For non-OPTIONS options, this has no effect since they're already de-duplicated. Modified: stable/12/usr.sbin/config/config.y Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/config/config.y ============================================================================== --- stable/12/usr.sbin/config/config.y Sun Jan 6 01:39:01 2019 (r342805) +++ stable/12/usr.sbin/config/config.y Sun Jan 6 02:12:55 2019 (r342806) @@ -99,7 +99,7 @@ static void newdev(char *name); static void newfile(char *name); static void newenvvar(char *name, bool is_file); static void rmdev_schedule(struct device_head *dh, char *name); -static void newopt(struct opt_head *list, char *name, char *value, int append); +static void newopt(struct opt_head *list, char *name, char *value, int append, int dupe); static void rmopt_schedule(struct opt_head *list, char *name); static char * @@ -212,7 +212,7 @@ System_spec: ; System_id: - Save_id { newopt(&mkopt, ns("KERNEL"), $1, 0); }; + Save_id { newopt(&mkopt, ns("KERNEL"), $1, 0, 0); }; System_parameter_list: System_parameter_list ID @@ -232,13 +232,13 @@ NoOpt_list: ; Option: Save_id { - newopt(&opt, $1, NULL, 0); + newopt(&opt, $1, NULL, 0, 1); if (strchr($1, '=') != NULL) errx(1, "%s:%d: The `=' in options should not be " "quoted", yyfile, yyline); } | Save_id EQUALS Opt_value { - newopt(&opt, $1, $3, 0); + newopt(&opt, $1, $3, 0, 1); } ; NoOption: @@ -266,10 +266,10 @@ Mkopt_list: ; Mkoption: - Save_id { newopt(&mkopt, $1, ns(""), 0); } | - Save_id EQUALS { newopt(&mkopt, $1, ns(""), 0); } | - Save_id EQUALS Opt_value { newopt(&mkopt, $1, $3, 0); } | - Save_id PLUSEQUALS Opt_value { newopt(&mkopt, $1, $3, 1); } ; + Save_id { newopt(&mkopt, $1, ns(""), 0, 0); } | + Save_id EQUALS { newopt(&mkopt, $1, ns(""), 0, 0); } | + Save_id EQUALS Opt_value { newopt(&mkopt, $1, $3, 0, 0); } | + Save_id PLUSEQUALS Opt_value { newopt(&mkopt, $1, $3, 1, 0); } ; Dev: ID { $$ = $1; } @@ -295,7 +295,7 @@ NoDev_list: Device: Dev { - newopt(&opt, devopt($1), ns("1"), 0); + newopt(&opt, devopt($1), ns("1"), 0, 0); /* and the device part */ newdev($1); } @@ -432,7 +432,7 @@ findopt(struct opt_head *list, char *name) * Add an option to the list of options. */ static void -newopt(struct opt_head *list, char *name, char *value, int append) +newopt(struct opt_head *list, char *name, char *value, int append, int dupe) { struct opt *op, *op2; @@ -445,7 +445,7 @@ newopt(struct opt_head *list, char *name, char *value, } op2 = findopt(list, name); - if (op2 != NULL && !append) { + if (op2 != NULL && !append && !dupe) { fprintf(stderr, "WARNING: duplicate option `%s' encountered.\n", name); return; @@ -458,9 +458,15 @@ newopt(struct opt_head *list, char *name, char *value, op->op_ownfile = 0; op->op_value = value; if (op2 != NULL) { - while (SLIST_NEXT(op2, op_append) != NULL) - op2 = SLIST_NEXT(op2, op_append); - SLIST_NEXT(op2, op_append) = op; + if (append) { + while (SLIST_NEXT(op2, op_append) != NULL) + op2 = SLIST_NEXT(op2, op_append); + SLIST_NEXT(op2, op_append) = op; + } else { + while (SLIST_NEXT(op2, op_next) != NULL) + op2 = SLIST_NEXT(op2, op_next); + SLIST_NEXT(op2, op_next) = op; + } } else SLIST_INSERT_HEAD(list, op, op_next); } @@ -473,8 +479,7 @@ rmopt_schedule(struct opt_head *list, char *name) { struct opt *op; - op = findopt(list, name); - if (op != NULL) { + while ((op = findopt(list, name)) != NULL) { SLIST_REMOVE(list, op, opt, op_next); free(op->op_name); free(op);