Skip to contentSkip to conversation

: Debug timeval operations

PATCH In review Gerrit Renker 2 participants 2 messages Dec 5, 2006 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 7/7 : Debug timeval operations

[DCCP]: Debug timeval operations

Problem:
--------
Most target types in the CCID3 code are u32, so subtle conversion errors can occur if signed time calculations yield negative results: the original values are lost in the conversion to unsigned, calculation errors go undetected.

This patch therefore
* sets all critical time types from unsigned to suseconds_t
* avoids comparison between signed/unsigned via type-casting
* provides ample warning messages in case time calculations are negative

These warning messages can be removed at a later stage when the code has undergone more testing.

---
 net/dccp/ccids/ccid3.c |   56 ++++++++++++++++++++++++++++---------------------
 net/dccp/dccp.h        |    1 
 2 files changed, 33 insertions(+), 24 deletions(-)
net/dccp/dccp.h +1 -0
@@ -434,6 +434,7 @@ static inline void timeval_sub_usecs(str
 		tv->tv_sec--;
 		tv->tv_usec += USEC_PER_SEC;
 	}
+	DCCP_BUG_ON(tv->tv_sec < 0);
 }
 
 #ifdef CONFIG_SYSCTL
net/dccp/ccids/ccid3.c +32 -21

140 lines not on this page · raw message

Acked-by on v1 7/7
#1 lore raw
Quoted 2 lines · Gerrit Renker

[DCCP]: Debug timeval operations

Signature · 3 lines
Web: http://wand.net.nz/~iam4
Blog: http://imcdnzl.blogspot.com
WAND Network Research Group