summaryrefslogtreecommitdiff
path: root/drivers.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 /drivers.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 'drivers.c')
-rw-r--r--drivers.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers.c b/drivers.c
index 60304938..0003ad11 100644
--- a/drivers.c
+++ b/drivers.c
@@ -14,6 +14,7 @@
#include "gpsd.h"
#include "bits.h" /* for getbeu16(), to extract big-endian words */
+#include "strfuncs.h"
ssize_t generic_get(struct gps_device_t *session)
{
@@ -47,7 +48,7 @@ gps_mask_t generic_parse_input(struct gps_device_t *session)
for (dp = gpsd_drivers; *dp; dp++) {
char *trigger = (*dp)->trigger;
- if (trigger!=NULL && strncmp(sentence,trigger,strlen(trigger))==0) {
+ if (trigger!=NULL && str_starts_with(sentence, trigger)) {
gpsd_report(&session->context->errout, LOG_PROG,
"found trigger string %s.\n", trigger);
if (*dp != session->device_type) {
@@ -1240,7 +1241,7 @@ static bool aivdm_decode(const char *buf, size_t buflen,
* which makes sense as they don't come in over radio. This
* is going to break if there's ever an AIVDO type 24, though.
*/
- if (strncmp((const char *)field[0], "!AIVDO", 6) != 0)
+ if (!str_starts_with((const char *)field[0], "!AIVDO"))
gpsd_report(&session->context->errout, LOG_INF,
"invalid empty AIS channel. Assuming 'A'\n");
ais_context = &session->driver.aivdm.context[0];
@@ -1426,7 +1427,7 @@ static void path_rewrite(struct gps_device_t *session, char *prefix)
for (prefloc = (char *)session->lexer.outbuffer;
prefloc < (char *)session->lexer.outbuffer+session->lexer.outbuflen;
prefloc++)
- if (strncmp(prefloc, prefix, strlen(prefix)) == 0) {
+ if (str_starts_with(prefloc, prefix)) {
char copy[sizeof(session->lexer.outbuffer)+1];
(void)strlcpy(copy,
(char *)session->lexer.outbuffer,
@@ -1449,7 +1450,7 @@ static gps_mask_t json_pass_packet(struct gps_device_t *session)
gpsd_report(&session->context->errout, LOG_IO,
"<= GPS: %s\n", (char *)session->lexer.outbuffer);
- if (strncmp(session->gpsdata.dev.path, "gpsd://localhost:", 17) != 0)
+ if (!str_starts_with(session->gpsdata.dev.path, "gpsd://localhost:"))
{
/*@-nullpass@*/ /* required only because splint is buggy */
/* devices and paths need to be edited */