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.
This commit is contained in:
Olaf Bergmann committed 2015-05-23 13:58:41 +02:00
1 parent a4c163937a
commit 8a96bfa5c2
1 file changed
+3 -2
+3 -2
View File
@@ -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
}