From 26177387fc081d5dc9b851f1bf1c40cdb4e68283 Mon Sep 17 00:00:00 2001 From: lebrush Date: Wed, 15 May 2013 11:33:02 +0200 Subject: [PATCH 1/2] Use memcpy, memcmp functions for the rime compare and copy functions as they are already used all over contiki. --- core/net/rime/rimeaddr.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/core/net/rime/rimeaddr.c b/core/net/rime/rimeaddr.c index 80899f802..c0b039b48 100644 --- a/core/net/rime/rimeaddr.c +++ b/core/net/rime/rimeaddr.c @@ -43,6 +43,7 @@ */ #include "net/rime/rimeaddr.h" +#include rimeaddr_t rimeaddr_node_addr; #if RIMEADDR_SIZE == 2 @@ -58,22 +59,13 @@ const rimeaddr_t rimeaddr_null = { { 0, 0, 0, 0, 0, 0, 0, 0 } }; void rimeaddr_copy(rimeaddr_t *dest, const rimeaddr_t *src) { - uint8_t i; - for(i = 0; i < RIMEADDR_SIZE; i++) { - dest->u8[i] = src->u8[i]; - } + memcpy(dest, src, RIMEADDR_SIZE); } /*---------------------------------------------------------------------------*/ int rimeaddr_cmp(const rimeaddr_t *addr1, const rimeaddr_t *addr2) { - uint8_t i; - for(i = 0; i < RIMEADDR_SIZE; i++) { - if(addr1->u8[i] != addr2->u8[i]) { - return 0; - } - } - return 1; + return (memcmp( addr1, addr2, RIMEADDR_SIZE) == 0); } /*---------------------------------------------------------------------------*/ void From c2a7a25a9ec23b072e5ffcfde7a14e9207b07b3e Mon Sep 17 00:00:00 2001 From: lebrush Date: Tue, 21 May 2013 09:10:54 +0200 Subject: [PATCH 2/2] Code style fixes --- core/net/rime/rimeaddr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/net/rime/rimeaddr.c b/core/net/rime/rimeaddr.c index c0b039b48..d0293018b 100644 --- a/core/net/rime/rimeaddr.c +++ b/core/net/rime/rimeaddr.c @@ -65,7 +65,7 @@ rimeaddr_copy(rimeaddr_t *dest, const rimeaddr_t *src) int rimeaddr_cmp(const rimeaddr_t *addr1, const rimeaddr_t *addr2) { - return (memcmp( addr1, addr2, RIMEADDR_SIZE) == 0); + return (memcmp(addr1, addr2, RIMEADDR_SIZE) == 0); } /*---------------------------------------------------------------------------*/ void