test_session.c: fix warning for taken absolute value of unsigned int

This change replaces the call of abs(v - ref) to avoid a compiler
warning for -Wabsolute-value:

test_session.c:95:11: warning: taking the absolute value of unsigned type 'unsigned int' has no effect
      [-Wabsolute-value]
  return (abs(v - ref) / 100.0) <= FP_ERR_THRESHOLD;
This commit is contained in:
Olaf Bergmann committed 2018-05-28 13:26:10 +02:00
1 parent 90cd1ac193
commit 56caa06677
1 file changed
+2 -1
+2 -1
View File
@@ -92,7 +92,8 @@ timeout(const coap_fixed_point_t ack_timeout,
*/
COAP_STATIC_INLINE int
good_enough(unsigned int v, unsigned int ref) {
return (abs(v - ref) / 100.0) <= FP_ERR_THRESHOLD;
#define delta(a,b) (((a) < (b)) ? ((b) - (a)) : ((a) - (b)))
return (delta(v,ref) / 100.0) <= FP_ERR_THRESHOLD;
}
static void