summaryrefslogtreecommitdiff
path: root/gpsd.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-08-11 02:11:33 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-08-11 02:11:33 +0000
commit6ea4e4c7d2e356e449113609d9c19ad3cc8de8f2 (patch)
tree928828716938a83dd1ed6aa5749ee2cb0760e097 /gpsd.c
parent194f892c7fd5218d745d359d06efc86c12e8f0ed (diff)
downloadgpsd-6ea4e4c7d2e356e449113609d9c19ad3cc8de8f2.tar.gz
Paul Fox's fix for the F command.
Diffstat (limited to 'gpsd.c')
-rw-r--r--gpsd.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/gpsd.c b/gpsd.c
index 77268dd7..aa901bf4 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1037,7 +1037,7 @@ static int handle_oldstyle(struct subscriber_t *sub, char *buf, int buflen)
{
char reply[BUFSIZ], phrase[BUFSIZ], *p, *stash;
int i, j;
- struct channel_t *channel;
+ struct channel_t *channel = NULL;
(void)strlcpy(reply, "GPSD", BUFSIZ);
p = buf;
@@ -1157,7 +1157,7 @@ static int handle_oldstyle(struct subscriber_t *sub, char *buf, int buflen)
}
}
/*@ +branchstate @*/
- if (channel == NULL || channel->device != NULL)
+ if (channel != NULL && channel->device != NULL)
(void)snprintf(phrase, sizeof(phrase), ",F=%s",
channel->device->gpsdata.gps_device);
else
@@ -1194,15 +1194,18 @@ static int handle_oldstyle(struct subscriber_t *sub, char *buf, int buflen)
(void)strlcpy(phrase, ",I=?", BUFSIZ);
break;
case 'J':
- if (*p == '=') ++p;
- if (*p == '1' || *p == '+') {
- channel->conf.buffer_policy = nocasoc;
- p++;
- } else if (*p == '0' || *p == '-') {
- channel->conf.buffer_policy = casoc;
- p++;
- }
- (void)snprintf(phrase, sizeof(phrase), ",J=%u", channel->conf.buffer_policy);
+ if (channel != NULL) {
+ if (*p == '=') ++p;
+ if (*p == '1' || *p == '+') {
+ channel->conf.buffer_policy = nocasoc;
+ p++;
+ } else if (*p == '0' || *p == '-') {
+ channel->conf.buffer_policy = casoc;
+ p++;
+ }
+ (void)snprintf(phrase, sizeof(phrase), ",J=%u", channel->conf.buffer_policy);
+ } else
+ (void)strlcpy(phrase, ",J=?", BUFSIZ);
break;
case 'K':
for (j = i = 0; i < MAXDEVICES; i++)
@@ -1226,7 +1229,6 @@ static int handle_oldstyle(struct subscriber_t *sub, char *buf, int buflen)
else
(void)snprintf(phrase, sizeof(phrase), ",M=%d", channel->fixbuffer.mode);
break;
-#ifdef ALLOW_RECONFIGURE
case 'N':
if ((channel=assign_channel(sub, GPS, NULL))== NULL || channel->device->device_type == NULL)
(void)strlcpy(phrase, ",N=?", BUFSIZ);
@@ -1244,12 +1246,11 @@ static int handle_oldstyle(struct subscriber_t *sub, char *buf, int buflen)
}
}
#endif /* ALLOW_RECONFIGURE */
- if (!channel->device)
+ if (!channel || !channel->device)
(void)snprintf(phrase, sizeof(phrase), ",N=?");
else
(void)snprintf(phrase, sizeof(phrase), ",N=%u", channel->device->gpsdata.driver_mode);
break;
-#endif /* ALLOW_RECONFIGURE */
case 'O':
if ((channel=assign_channel(sub, GPS, NULL))== NULL || !have_fix(channel))
(void)strlcpy(phrase, ",O=?", BUFSIZ);