Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Aug 2019 18:17:04 +0000 (UTC)
From:      Emmanuel Vadot <manu@FreeBSD.org>
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
Message-ID:  <201908051817.x75IH44v016272@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908051817.x75IH44v016272>