From owner-svn-src-all@freebsd.org Mon Aug 5 18:17:04 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CB1E5A9D5F; Mon, 5 Aug 2019 18:17:04 +0000 (UTC) (envelope-from manu@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 462Qw050zzz423p; Mon, 5 Aug 2019 18:17:04 +0000 (UTC) (envelope-from manu@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 8D9221FA9E; Mon, 5 Aug 2019 18:17:04 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x75IH4us016273; Mon, 5 Aug 2019 18:17:04 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x75IH44v016272; Mon, 5 Aug 2019 18:17:04 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201908051817.x75IH44v016272@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Mon, 5 Aug 2019 18:17:04 +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: r350604 - stable/12/usr.sbin/config X-SVN-Group: stable-12 X-SVN-Commit-Author: manu X-SVN-Commit-Paths: stable/12/usr.sbin/config X-SVN-Commit-Revision: 350604 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Mon, 05 Aug 2019 18:17:04 -0000 Author: manu Date: Mon Aug 5 18:17:03 2019 New Revision: 350604 URL: https://svnweb.freebsd.org/changeset/base/350604 Log: MFC r346298: config: Only warn if duplicate option/device comes from the same file This is useful for arm (possibly other arches too) where we want to have a GENERIC kernel that only include files for the different SoC. Since multiple SoCs/Board needs the same device we would need to do either : Include the device in a generic file Include the device in each file that really needs it Option 1 works but if someone wants to create a specific kernel config (which isn't uncommon for embedded system), he will need to add a lots of nodevice to it. Option 2 also works but produce a lots of warnings. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D19424 Modified: stable/12/usr.sbin/config/config.h stable/12/usr.sbin/config/config.y Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/config/config.h ============================================================================== --- stable/12/usr.sbin/config/config.h Mon Aug 5 18:13:13 2019 (r350603) +++ stable/12/usr.sbin/config/config.h Mon Aug 5 18:17:03 2019 (r350604) @@ -86,6 +86,7 @@ struct files_name { struct device { int d_done; /* processed */ char *d_name; /* name of device (e.g. rk11) */ + char *yyfile; /* name of the file that first include the device */ #define UNKNOWN -2 /* -2 means not set yet */ STAILQ_ENTRY(device) d_next; /* Next one in list */ }; @@ -125,6 +126,7 @@ struct opt { char *op_name; char *op_value; int op_ownfile; /* true = own file, false = makefile */ + char *yyfile; /* name of the file that first include the option */ SLIST_ENTRY(opt) op_next; SLIST_ENTRY(opt) op_append; }; Modified: stable/12/usr.sbin/config/config.y ============================================================================== --- stable/12/usr.sbin/config/config.y Mon Aug 5 18:13:13 2019 (r350603) +++ stable/12/usr.sbin/config/config.y Mon Aug 5 18:17:03 2019 (r350604) @@ -382,11 +382,13 @@ finddev(struct device_head *dlist, char *name) static void newdev(char *name) { - struct device *np; + struct device *np, *dp; - if (finddev(&dtab, name)) { - fprintf(stderr, - "WARNING: duplicate device `%s' encountered.\n", name); + if ((dp = finddev(&dtab, name)) != NULL) { + if (strcmp(dp->yyfile, yyfile) == 0) + fprintf(stderr, + "WARNING: duplicate device `%s' encountered in %s\n", + name, yyfile); return; } @@ -394,6 +396,7 @@ newdev(char *name) if (np == NULL) err(EXIT_FAILURE, "calloc"); np->d_name = name; + np->yyfile = strdup(yyfile); STAILQ_INSERT_TAIL(&dtab, np, d_next); } @@ -408,6 +411,7 @@ rmdev_schedule(struct device_head *dh, char *name) dp = finddev(dh, name); if (dp != NULL) { STAILQ_REMOVE(dh, dp, device, d_next); + free(dp->yyfile); free(dp->d_name); free(dp); } @@ -446,8 +450,9 @@ newopt(struct opt_head *list, char *name, char *value, op2 = findopt(list, name); if (op2 != NULL && !append && !dupe) { - fprintf(stderr, - "WARNING: duplicate option `%s' encountered.\n", name); + if (strcmp(op2->yyfile, yyfile) == 0) + fprintf(stderr, + "WARNING: duplicate option `%s' encountered.\n", name); return; } @@ -457,6 +462,7 @@ newopt(struct opt_head *list, char *name, char *value, op->op_name = name; op->op_ownfile = 0; op->op_value = value; + op->yyfile = strdup(yyfile); if (op2 != NULL) { if (append) { while (SLIST_NEXT(op2, op_append) != NULL) @@ -481,6 +487,7 @@ rmopt_schedule(struct opt_head *list, char *name) while ((op = findopt(list, name)) != NULL) { SLIST_REMOVE(list, op, opt, op_next); + free(op->yyfile); free(op->op_name); free(op); }