[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gpsd-dev] [PATCH 2/3] Fixes Ill-formed TOFF/PPS packet error in gpsmon.
From: |
Fred Wright |
Subject: |
[gpsd-dev] [PATCH 2/3] Fixes Ill-formed TOFF/PPS packet error in gpsmon. |
Date: |
Fri, 16 Sep 2016 18:18:27 -0700 |
The code for reporting the combined host address and device address
modifies the same 'path' field that it uses to form the combination
This was resulting in a growing accumulation of device names until the
string became too long. Although the way this code works could use
some improvement, a cheap fix is to check for the presence of the
device name in the path, and skip it when creating the new one.
TESTED:
On both OSX and Linux, ran "scons build-all check" and tested gpsmon
both with and without the -a option, verifying that it no longer
fails and that the reported "device" is the expected combined form.
---
drivers.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers.c b/drivers.c
index 98a2485..ebbcc6d 100644
--- a/drivers.c
+++ b/drivers.c
@@ -1608,7 +1608,7 @@ static void path_rewrite(struct gps_device_t *session,
char *prefix)
* beginning of the path attribute, followed by a # to separate it
* from the device.
*/
- char *prefloc;
+ char *prefloc, *sfxloc;
assert(prefix != NULL && session->lexer.outbuffer != NULL);
@@ -1628,6 +1628,8 @@ static void path_rewrite(struct gps_device_t *session,
char *prefix)
(void)strlcpy(prefloc,
session->gpsdata.dev.path,
sizeof(session->gpsdata.dev.path));
+ if ((sfxloc = strchr(prefloc, '#')))
+ *sfxloc = '\0'; /* Avoid accumulating multiple device names */
(void)strlcat((char *)session->lexer.outbuffer, "#",
sizeof(session->lexer.outbuffer));
(void)strlcat((char *)session->lexer.outbuffer,
--
2.9.3