summaryrefslogtreecommitdiff
path: root/gpsd.c
diff options
context:
space:
mode:
authorZbigniew Chyla <zbigniew.chyla@nsn.com>2015-01-16 15:46:59 +0100
committerEric S. Raymond <esr@thyrsus.com>2015-01-21 10:47:00 -0500
commitd0174ca4e78831bbdd798d02a481ba2569425722 (patch)
tree3bcdd83bb0e0fabcbc2e1e8e84c7befffc19c3cc /gpsd.c
parent39554efdf0416e35236ad3d23a3a893d90c68be6 (diff)
downloadgpsd-d0174ca4e78831bbdd798d02a481ba2569425722.tar.gz
Add str_starts_with macro, use it instead of strncmp.
This change doesn't affect generated binary code.
Diffstat (limited to 'gpsd.c')
-rw-r--r--gpsd.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/gpsd.c b/gpsd.c
index e8d93b0b..eaa2ebdc 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -48,6 +48,7 @@
#include "sockaddr.h"
#include "gps_json.h"
#include "revision.h"
+#include "strfuncs.h"
#if defined(SYSTEMD_ENABLE)
#include "sd_socket.h"
@@ -1107,10 +1108,10 @@ static void handle_request(struct subscriber_t *sub,
if (buf[0] == '?')
++buf;
- if (strncmp(buf, "DEVICES;", 8) == 0) {
+ if (str_starts_with(buf, "DEVICES;")) {
buf += 8;
json_devicelist_dump(reply, replylen);
- } else if (strncmp(buf, "WATCH", 5) == 0
+ } else if (str_starts_with(buf, "WATCH")
&& (buf[5] == ';' || buf[5] == '=')) {
const char *start = buf;
buf += 5;
@@ -1173,7 +1174,7 @@ static void handle_request(struct subscriber_t *sub,
json_devicelist_dump(reply + strlen(reply), replylen - strlen(reply));
json_watch_dump(&sub->policy,
reply + strlen(reply), replylen - strlen(reply));
- } else if (strncmp(buf, "DEVICE", 6) == 0
+ } else if (str_starts_with(buf, "DEVICE")
&& (buf[6] == ';' || buf[6] == '=')) {
struct devconfig_t devconf;
buf += 6;
@@ -1304,7 +1305,7 @@ static void handle_request(struct subscriber_t *sub,
reply + strlen(reply),
replylen - strlen(reply));
}
- } else if (strncmp(buf, "POLL;", 5) == 0) {
+ } else if (str_starts_with(buf, "POLL;")) {
char tbuf[JSON_DATE_MAX+1];
int active = 0;
buf += 5;
@@ -1357,7 +1358,7 @@ static void handle_request(struct subscriber_t *sub,
if (reply[strlen(reply) - 1] == ',')
reply[strlen(reply) - 1] = '\0'; /* trim trailing comma */
(void)strlcat(reply, "]}\r\n", replylen);
- } else if (strncmp(buf, "VERSION;", 8) == 0) {
+ } else if (str_starts_with(buf, "VERSION;")) {
buf += 8;
json_version_dump(reply, replylen);
} else {