Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

src: Keep previous location of device definitions so we can prin...



details:   https://anonhg.NetBSD.org/src/rev/1066494eda03
branches:  trunk
changeset: 317982:1066494eda03
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Apr 09 17:46:56 2018 +0000
description:
Keep previous location of device definitions so we can print them in error
messages.

diffstat:

 usr.bin/config/defs.h |   6 +++++-
 usr.bin/config/sem.c  |  14 ++++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)

diffs (83 lines):

diff -r c1907f8432cc -r 1066494eda03 usr.bin/config/defs.h
--- a/usr.bin/config/defs.h     Mon Apr 09 17:27:11 2018 +0000
+++ b/usr.bin/config/defs.h     Mon Apr 09 17:46:56 2018 +0000
@@ -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  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  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 */
 };
 
 /*
diff -r c1907f8432cc -r 1066494eda03 usr.bin/config/sem.c
--- a/usr.bin/config/sem.c      Mon Apr 09 17:27:11 2018 +0000
+++ b/usr.bin/config/sem.c      Mon Apr 09 17:46:56 2018 +0000
@@ -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 @@
        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 @@
                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 @@
                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 @@
                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);



Home | Main Index | Thread Index | Old Index