summaryrefslogtreecommitdiff
path: root/gpsd.c
diff options
context:
space:
mode:
authorZbigniew Chyla <zbigniew@chyla.pl>2015-01-16 15:46:59 +0100
committerEric S. Raymond <esr@thyrsus.com>2015-01-21 10:47:35 -0500
commitfca5b90829621e119a310225b4f1358cd6914d5c (patch)
treed45368bac641c99877370a2bf0e29828bd7a10df /gpsd.c
parent4abdcf1ac9a891a5010f238214150adbc2073b38 (diff)
downloadgpsd-fca5b90829621e119a310225b4f1358cd6914d5c.tar.gz
Add str_rstrip_char, use it everywhere.
This change doesn't affect generated binary code.
Diffstat (limited to 'gpsd.c')
-rw-r--r--gpsd.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/gpsd.c b/gpsd.c
index 0d68e154..14f877c8 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1069,8 +1069,7 @@ static void json_devicelist_dump(char *reply, size_t replylen)
(void)strlcat(reply, ",", replylen);
}
- if (reply[strlen(reply) - 1] == ',')
- reply[strlen(reply) - 1] = '\0';
+ str_rstrip_char(reply, ',');
(void)strlcat(reply, "]}\r\n", replylen);
}
#endif /* SOCKET_EXPORT_ENABLE */
@@ -1323,8 +1322,7 @@ static void handle_request(struct subscriber_t *sub,
}
}
}
- if (reply[strlen(reply) - 1] == ',')
- reply[strlen(reply) - 1] = '\0'; /* trim trailing comma */
+ str_rstrip_char(reply, ',');
(void)strlcat(reply, "],\"gst\":[", replylen);
for (devp = devices; devp < devices + MAXDEVICES; devp++) {
if (allocated_device(devp) && subscribed(sub, devp)) {
@@ -1337,8 +1335,7 @@ static void handle_request(struct subscriber_t *sub,
}
}
}
- if (reply[strlen(reply) - 1] == ',')
- reply[strlen(reply) - 1] = '\0'; /* trim trailing comma */
+ str_rstrip_char(reply, ',');
(void)strlcat(reply, "],\"sky\":[", replylen);
for (devp = devices; devp < devices + MAXDEVICES; devp++) {
if (allocated_device(devp) && subscribed(sub, devp)) {
@@ -1351,8 +1348,7 @@ static void handle_request(struct subscriber_t *sub,
}
}
}
- if (reply[strlen(reply) - 1] == ',')
- reply[strlen(reply) - 1] = '\0'; /* trim trailing comma */
+ str_rstrip_char(reply, ',');
(void)strlcat(reply, "]}\r\n", replylen);
} else if (str_starts_with(buf, "VERSION;")) {
buf += 8;