diff options
author | Spencer Oliver <spen@spen-soft.co.uk> | 2012-10-26 12:47:06 +0100 |
---|---|---|
committer | Peter Stuge <peter@stuge.se> | 2012-10-28 01:40:21 +0000 |
commit | 538a86c3395d0476d2fdcc9bddc4e9e550734c96 (patch) | |
tree | 53aabde1956cc30f1d1198939375c88ad0b20d3c /src/server | |
parent | 6f65045b3791525e99d09d07b5f9d8dd5aa511e5 (diff) |
gdb: use strncmp rather than strstr
All the packets received will be at start of the packet buffer, so use
more efficient strncmp.
Change-Id: Ib9c45d8f53425367006b1f880c1bde27f03a6cf9
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/932
Tested-by: jenkins
Reviewed-by: Matthias Blaicher <matthias@blaicher.com>
Reviewed-by: Peter Stuge <peter@stuge.se>
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/gdb_server.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 0a8babe2..ee7683a6 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -1705,7 +1705,7 @@ static int gdb_query_packet(struct connection *connection, struct gdb_connection *gdb_connection = connection->priv; struct target *target = get_target_from_connection(connection); - if (strstr(packet, "qRcmd,")) { + if (strncmp(packet, "qRcmd,", 6) == 0) { if (packet_size > 6) { char *cmd; int i; @@ -1731,7 +1731,7 @@ static int gdb_query_packet(struct connection *connection, } gdb_put_packet(connection, "OK", 2); return ERROR_OK; - } else if (strstr(packet, "qCRC:")) { + } else if (strncmp(packet, "qCRC:", 5) == 0) { if (packet_size > 5) { int retval; char gdb_reply[10]; @@ -1765,7 +1765,7 @@ static int gdb_query_packet(struct connection *connection, return ERROR_OK; } - } else if (strstr(packet, "qSupported")) { + } else if (strncmp(packet, "qSupported", 10) == 0) { /* we currently support packet size and qXfer:memory-map:read (if enabled) * disable qXfer:features:read for the moment */ int retval = ERROR_OK; @@ -1790,10 +1790,10 @@ static int gdb_query_packet(struct connection *connection, free(buffer); return ERROR_OK; - } else if (strstr(packet, "qXfer:memory-map:read::") + } else if ((strncmp(packet, "qXfer:memory-map:read::", 23) == 0) && (flash_get_bank_count() > 0)) return gdb_memory_map(connection, packet, packet_size); - else if (strstr(packet, "qXfer:features:read:")) { + else if (strncmp(packet, "qXfer:features:read:", 20) == 0) { char *xml = NULL; int size = 0; int pos = 0; @@ -1831,7 +1831,7 @@ static int gdb_query_packet(struct connection *connection, free(xml); return ERROR_OK; - } else if (strstr(packet, "QStartNoAckMode")) { + } else if (strncmp(packet, "QStartNoAckMode", 15) == 0) { gdb_connection->noack_mode = 1; gdb_put_packet(connection, "OK", 2); return ERROR_OK; @@ -1855,7 +1855,7 @@ static int gdb_v_packet(struct connection *connection, return ERROR_OK; } - if (strstr(packet, "vFlashErase:")) { + if (strncmp(packet, "vFlashErase:", 12) == 0) { unsigned long addr; unsigned long length; @@ -1911,7 +1911,7 @@ static int gdb_v_packet(struct connection *connection, return ERROR_OK; } - if (strstr(packet, "vFlashWrite:")) { + if (strncmp(packet, "vFlashWrite:", 12) == 0) { int retval; unsigned long addr; unsigned long length; @@ -1945,7 +1945,7 @@ static int gdb_v_packet(struct connection *connection, return ERROR_OK; } - if (!strcmp(packet, "vFlashDone")) { + if (strncmp(packet, "vFlashDone", 10) == 0) { uint32_t written; /* process the flashing buffer. No need to erase as GDB |