From 8a96bfa5c20ae637bbe905787f9c8e5db68b2d8a Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Sat, 23 May 2015 13:58:41 +0200 Subject: [PATCH] net.h: fixed ugly macro usage in coap_new_message_id() context->message_id has been incremented as a side-effect of calling the htons macro. To avoid potential issues with this, the increment operation has been moved outside the macro call. --- include/coap/net.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/coap/net.h b/include/coap/net.h index ca42342f..3f524a4a 100644 --- a/include/coap/net.h +++ b/include/coap/net.h @@ -208,10 +208,11 @@ coap_context_t *coap_new_context(const coap_address_t *listen_addr); */ static inline unsigned short coap_new_message_id(coap_context_t *context) { + context->message_id++; #ifndef WITH_CONTIKI - return htons(++(context->message_id)); + return htons(context->message_id); #else /* WITH_CONTIKI */ - return uip_htons(++context->message_id); + return uip_htons(context->message_id); #endif }