Module Name:    src
Committed By:   christos
Date:           Mon Apr  9 17:46:57 UTC 2018

Modified Files:
        src/usr.bin/config: defs.h sem.c

Log Message:
Keep previous location of device definitions so we can print them in error
messages.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/config/defs.h
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/config/sem.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/config/defs.h
diff -u src/usr.bin/config/defs.h:1.102 src/usr.bin/config/defs.h:1.103
--- src/usr.bin/config/defs.h:1.102	Sun Nov 26 19:25:46 2017
+++ src/usr.bin/config/defs.h	Mon Apr  9 13:46:56 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.102 2017/11/27 00:25:46 christos Exp $	*/
+/*	$NetBSD: defs.h,v 1.103 2018/04/09 17:46:56 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -277,6 +277,8 @@ struct devbase {
 	struct	deva *d_ahead;		/* first attachment, if any */
 	struct	deva **d_app;		/* used for tacking on attachments */
 	struct	attr *d_classattr;	/* device class attribute (if any) */
+	const char *d_srcfile;		/* file name where we are defined */
+	u_short	d_srcline;		/* line number where we are defined */
 };
 
 struct deva {
@@ -289,6 +291,8 @@ struct deva {
 	struct	attrlist *d_attrs;	/* attributes, if any */
 	struct	devi *d_ihead;		/* first instance, if any */
 	struct	devi **d_ipp;		/* used for tacking on more instances */
+	const char *d_srcfile;		/* file name where we are defined */
+	u_short	d_srcline;		/* line number where we are defined */
 };
 
 /*

Index: src/usr.bin/config/sem.c
diff -u src/usr.bin/config/sem.c:1.82 src/usr.bin/config/sem.c:1.83
--- src/usr.bin/config/sem.c:1.82	Sun Nov 26 19:25:46 2017
+++ src/usr.bin/config/sem.c	Mon Apr  9 13:46:56 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.82 2017/11/27 00:25:46 christos Exp $	*/
+/*	$NetBSD: sem.c,v 1.83 2018/04/09 17:46:56 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: sem.c,v 1.82 2017/11/27 00:25:46 christos Exp $");
+__RCSID("$NetBSD: sem.c,v 1.83 2018/04/09 17:46:56 christos Exp $");
 
 #include <sys/param.h>
 #include <ctype.h>
@@ -509,7 +509,8 @@ defdev(struct devbase *dev, struct locli
 	if (dev == &errdev)
 		goto bad;
 	if (dev->d_isdef) {
-		cfgerror("redefinition of `%s'", dev->d_name);
+		cfgerror("redefinition of `%s' (previously defined at %s:%d)",
+		    dev->d_name, dev->d_srcfile, dev->d_srcline);
 		goto bad;
 	}
 
@@ -624,6 +625,8 @@ getdevbase(const char *name)
 		dev->d_ahead = NULL;
 		dev->d_app = &dev->d_ahead;
 		dev->d_umax = 0;
+		dev->d_srcfile = yyfile;
+		dev->d_srcline = currentline();
 		TAILQ_INSERT_TAIL(&allbases, dev, d_next);
 		if (ht_insert(devbasetab, name, dev))
 			panic("%s: Can't insert %s", __func__, name);
@@ -655,7 +658,8 @@ defdevattach(struct deva *deva, struct d
 		goto bad;
 	}
 	if (deva->d_isdef) {
-		cfgerror("redefinition of `%s'", deva->d_name);
+		cfgerror("redefinition of `%s' (previously defined at %s:%d)",
+		    deva->d_name, deva->d_srcfile, deva->d_srcline);
 		goto bad;
 	}
 	if (dev->d_ispseudo) {
@@ -764,6 +768,8 @@ getdevattach(const char *name)
 		deva->d_attrs = NULL;
 		deva->d_ihead = NULL;
 		deva->d_ipp = &deva->d_ihead;
+		deva->d_srcfile = yyfile;
+		deva->d_srcline = currentline();
 		TAILQ_INSERT_TAIL(&alldevas, deva, d_next);
 		if (ht_insert(devatab, name, deva))
 			panic("%s: Can't insert %s", __func__, name);

Reply via email to