summaryrefslogtreecommitdiff
path: root/sys/kern/tty_nmea.c
diff options
context:
space:
mode:
authorMarc Balmer <mbalmer@cvs.openbsd.org>2008-06-11 17:11:37 +0000
committerMarc Balmer <mbalmer@cvs.openbsd.org>2008-06-11 17:11:37 +0000
commit518385c7479f708311cbbb6f5c066047903eb767 (patch)
treebc3d930609735a31650a86243e46e05fa1071751 /sys/kern/tty_nmea.c
parent069b512a15850dc9fb1df0cd0c89113259304049 (diff)
Don't use the reference count to create the sensor name; we can end up
with sensors with the same name. The sensor name is now ever increasing unless the reference count drops to zero, in which case the naming restarts at zero as well.
Diffstat (limited to 'sys/kern/tty_nmea.c')
-rw-r--r--sys/kern/tty_nmea.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/kern/tty_nmea.c b/sys/kern/tty_nmea.c
index b5c6a9022c5..4e10f2e1ccc 100644
--- a/sys/kern/tty_nmea.c
+++ b/sys/kern/tty_nmea.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_nmea.c,v 1.26 2008/05/05 19:57:01 mbalmer Exp $ */
+/* $OpenBSD: tty_nmea.c,v 1.27 2008/06/11 17:11:36 mbalmer Exp $ */
/*
* Copyright (c) 2006, 2007, 2008 Marc Balmer <mbalmer@openbsd.org>
@@ -49,7 +49,7 @@ void nmeaattach(int);
#define TRUSTTIME (10 * 60) /* 10 minutes */
#endif
-int nmea_count; /* this is wrong, it should really be a SLIST */
+int nmea_count, nmea_nxid;
static int t_trust;
struct nmea {
@@ -101,7 +101,8 @@ nmeaopen(dev_t dev, struct tty *tp)
return error;
np = malloc(sizeof(struct nmea), M_DEVBUF, M_WAITOK | M_ZERO);
snprintf(np->timedev.xname, sizeof(np->timedev.xname), "nmea%d",
- nmea_count++);
+ nmea_nxid++);
+ nmea_count++;
np->time.status = SENSOR_S_UNKNOWN;
np->time.type = SENSOR_TIMEDELTA;
np->time.value = 0LL;
@@ -144,6 +145,8 @@ nmeaclose(struct tty *tp, int flags)
free(np, M_DEVBUF);
tp->t_sc = NULL;
nmea_count--;
+ if (nmea_count == 0)
+ nmea_nxid = 0;
return linesw[TTYDISC].l_close(tp, flags);
}