diff options
author | Zbigniew Chyla <zbigniew@chyla.pl> | 2015-01-16 15:46:59 +0100 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2015-01-21 10:47:35 -0500 |
commit | fca5b90829621e119a310225b4f1358cd6914d5c (patch) | |
tree | d45368bac641c99877370a2bf0e29828bd7a10df /gpsd.c | |
parent | 4abdcf1ac9a891a5010f238214150adbc2073b38 (diff) | |
download | gpsd-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.c | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -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; |