summaryrefslogtreecommitdiff
path: root/packet.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 /packet.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 'packet.c')
-rw-r--r--packet.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/packet.c b/packet.c
index 1cf2a5a9..02b18e5d 100644
--- a/packet.c
+++ b/packet.c
@@ -42,6 +42,7 @@ PERMISSIONS
#include "bits.h"
#include "gpsd.h"
#include "crc24q.h"
+#include "strfuncs.h"
/*
* The packet-recognition state machine. This takes an incoming byte stream
@@ -1503,7 +1504,7 @@ void packet_parse(struct gps_lexer_t *lexer)
* $PASHR packets have no checksum. Avoid the possibility
* that random garbage might make it look like they do.
*/
- if (strncmp((const char *)lexer->inbuffer, "$PASHR,", 7) != 0)
+ if (!str_starts_with((const char *)lexer->inbuffer, "$PASHR,"))
{
bool checksum_ok = true;
char csum[3] = { '0', '0', '0' };
@@ -1536,13 +1537,13 @@ void packet_parse(struct gps_lexer_t *lexer)
}
/* checksum passed or not present */
#ifdef AIVDM_ENABLE
- if (strncmp((char *)lexer->inbuffer, "!AIVDM", 6) == 0)
+ if (str_starts_with((char *)lexer->inbuffer, "!AIVDM"))
packet_accept(lexer, AIVDM_PACKET);
- else if (strncmp((char *)lexer->inbuffer, "!AIVDO", 6) == 0)
+ else if (str_starts_with((char *)lexer->inbuffer, "!AIVDO"))
packet_accept(lexer, AIVDM_PACKET);
- else if (strncmp((char *)lexer->inbuffer, "!BSVDM", 6) == 0)
+ else if (str_starts_with((char *)lexer->inbuffer, "!BSVDM"))
packet_accept(lexer, AIVDM_PACKET);
- else if (strncmp((char *)lexer->inbuffer, "!BSVDO", 6) == 0)
+ else if (str_starts_with((char *)lexer->inbuffer, "!BSVDO"))
packet_accept(lexer, AIVDM_PACKET);
else
#endif /* AIVDM_ENABLE */